273 |
|
} |
274 |
|
|
275 |
|
// Open file/device |
276 |
< |
#if defined(__linux__) |
276 |
> |
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) |
277 |
|
int fd = open(name, (read_only ? O_RDONLY : O_RDWR) | (is_cdrom ? O_NONBLOCK : 0)); |
278 |
|
#else |
279 |
|
int fd = open(name, read_only ? O_RDONLY : O_RDWR); |
549 |
|
lseek(fh->fd, 0, SEEK_SET); |
550 |
|
return read(fh->fd, block, 512) == 512; |
551 |
|
} else if (fh->is_cdrom) { |
552 |
+ |
#ifdef CDROM_MEDIA_CHANGED |
553 |
+ |
if (fh->cdrom_cap & CDC_MEDIA_CHANGED) { |
554 |
+ |
// If we don't do this, all attempts to read from a disc fail |
555 |
+ |
// once the tray has been open (altough the TOC reads fine). |
556 |
+ |
// Can somebody explain this to me? |
557 |
+ |
if (ioctl(fh->fd, CDROM_MEDIA_CHANGED) == 1) { |
558 |
+ |
close(fh->fd); |
559 |
+ |
fh->fd = open(fh->name, O_RDONLY | O_NONBLOCK); |
560 |
+ |
} |
561 |
+ |
} |
562 |
+ |
#endif |
563 |
|
#ifdef CDROM_DRIVE_STATUS |
564 |
|
if (fh->cdrom_cap & CDC_DRIVE_STATUS) { |
565 |
|
return ioctl(fh->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) == CDS_DISC_OK; |