27 |
|
#ifdef __linux__ |
28 |
|
#include <linux/cdrom.h> |
29 |
|
#include <linux/fd.h> |
30 |
+ |
#include <linux/fs.h> |
31 |
|
#include <linux/major.h> |
32 |
|
#include <linux/kdev_t.h> |
33 |
|
#include <linux/unistd.h> |
320 |
|
#else |
321 |
|
fh->cdrom_cap = 0; |
322 |
|
#endif |
323 |
< |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
323 |
> |
#elif defined(__FreeBSD__) |
324 |
|
fh->is_floppy = ((st.st_rdev >> 16) == 2); |
325 |
|
#ifdef CDIOCCAPABILITY |
326 |
|
if (is_cdrom) { |
330 |
|
#else |
331 |
|
fh->cdrom_cap = 0; |
332 |
|
#endif |
333 |
+ |
#elif defined(__NetBSD__) |
334 |
+ |
fh->is_floppy = ((st.st_rdev >> 16) == 2); |
335 |
|
#endif |
336 |
|
} |
337 |
|
} |
429 |
|
return fh->file_size; |
430 |
|
else { |
431 |
|
#if defined(__linux__) |
432 |
< |
loff_t pos = 0; |
433 |
< |
_llseek(fh->fd, 0, 0, &pos, SEEK_END); |
434 |
< |
return pos - fh->start_byte; |
432 |
> |
long blocks; |
433 |
> |
if (ioctl(fh->fd, BLKGETSIZE, &blocks) < 0) |
434 |
> |
return 0; |
435 |
> |
D(bug(" BLKGETSIZE returns %d blocks\n", blocks)); |
436 |
> |
return (loff_t)blocks * 512; |
437 |
|
#else |
438 |
|
return lseek(fh->fd, 0, SEEK_END) - fh->start_byte; |
439 |
|
#endif |
660 |
|
*toc++ = toc_size >> 8; |
661 |
|
*toc++ = toc_size & 0xff; |
662 |
|
return true; |
663 |
< |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
663 |
> |
#elif defined(__FreeBSD__) |
664 |
|
uint8 *p = toc + 2; |
665 |
|
|
666 |
|
// Header |
703 |
|
|
704 |
|
// TOC size |
705 |
|
int toc_size = p - toc; |
706 |
+ |
*toc++ = toc_size >> 8; |
707 |
+ |
*toc++ = toc_size & 0xff; |
708 |
+ |
return true; |
709 |
+ |
#elif defined(__NetBSD__) |
710 |
+ |
uint8 *p = toc + 2; |
711 |
+ |
|
712 |
+ |
// Header |
713 |
+ |
struct ioc_toc_header header; |
714 |
+ |
if (ioctl(fh->fd, CDIOREADTOCHEADER, &header) < 0) |
715 |
+ |
return false; |
716 |
+ |
*p++ = header.starting_track; |
717 |
+ |
*p++ = header.ending_track; |
718 |
+ |
|
719 |
+ |
// Tracks (this is nice... :-) |
720 |
+ |
struct ioc_read_toc_entry entries; |
721 |
+ |
entries.address_format = CD_MSF_FORMAT; |
722 |
+ |
entries.starting_track = 1; |
723 |
+ |
entries.data_len = 800; |
724 |
+ |
entries.data = (cd_toc_entry *)p; |
725 |
+ |
if (ioctl(fh->fd, CDIOREADTOCENTRIES, &entries) < 0) |
726 |
+ |
return false; |
727 |
+ |
|
728 |
+ |
// TOC size |
729 |
+ |
int toc_size = p - toc; |
730 |
|
*toc++ = toc_size >> 8; |
731 |
|
*toc++ = toc_size & 0xff; |
732 |
|
return true; |