ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/sys_unix.cpp
(Generate patch)

Comparing BasiliskII/src/Unix/sys_unix.cpp (file contents):
Revision 1.13 by cebix, 2002-02-22T17:48:31Z vs.
Revision 1.14 by cebix, 2002-02-23T17:54:24Z

# Line 456 | Line 456 | void SysEject(void *arg)
456                  fsync(fh->fd);
457                  ioctl(fh->fd, FDFLUSH);
458                  ioctl(fh->fd, FDEJECT);
459 +                close(fh->fd);  // Close and reopen so the driver will see the media change
460 +                fh->fd = open(fh->name, fh->read_only ? O_RDONLY : O_RDWR);
461          } else if (fh->is_cdrom) {
462                  ioctl(fh->fd, CDROMEJECT);
463                  close(fh->fd);  // Close and reopen so the driver will see the media change
# Line 464 | Line 466 | void SysEject(void *arg)
466   #elif defined(__FreeBSD__) || defined(__NetBSD__)
467          if (fh->is_floppy) {
468                  fsync(fh->fd);
467                //ioctl(fh->fd, FDFLUSH);
468                //ioctl(fh->fd, FDEJECT);
469          } else if (fh->is_cdrom) {
470                  ioctl(fh->fd, CDIOCEJECT);
471                  close(fh->fd);  // Close and reopen so the driver will see the media change
# Line 547 | Line 547 | bool SysIsDiskInserted(void *arg)
547          } else if (fh->is_floppy) {
548                  char block[512];
549                  lseek(fh->fd, 0, SEEK_SET);
550 <                return read(fh->fd, block, 512) == 512;
550 >                ssize_t actual = read(fh->fd, block, 512);
551 >                if (actual < 0) {
552 >                        close(fh->fd);  // Close and reopen so the driver will see the media change
553 >                        fh->fd = open(fh->name, fh->read_only ? O_RDONLY : O_RDWR);
554 >                        actual = read(fh->fd, block, 512);
555 >                }
556 >                return actual == 512;
557          } else if (fh->is_cdrom) {
558   #ifdef CDROM_MEDIA_CHANGED
559                  if (fh->cdrom_cap & CDC_MEDIA_CHANGED) {
560                          // If we don't do this, all attempts to read from a disc fail
561 <                        // once the tray has been open (altough the TOC reads fine).
561 >                        // once the tray has been opened (altough the TOC reads fine).
562                          // Can somebody explain this to me?
563                          if (ioctl(fh->fd, CDROM_MEDIA_CHANGED) == 1) {
564                                  close(fh->fd);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines