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.3 by cebix, 1999-10-14T11:37:47Z vs.
Revision 1.5 by cebix, 1999-10-31T23:18:37Z

# Line 27 | Line 27
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>
# Line 319 | Line 320 | void *Sys_open(const char *name, bool re
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) {
# Line 329 | Line 330 | void *Sys_open(const char *name, bool re
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                          }
# Line 426 | Line 429 | loff_t SysGetFileSize(void *arg)
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
# Line 655 | Line 660 | bool SysCDReadTOC(void *arg, uint8 *toc)
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
# Line 698 | Line 703 | bool SysCDReadTOC(void *arg, uint8 *toc)
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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines