1 |
|
/* |
2 |
|
* sys_unix.cpp - System dependent routines, Unix implementation |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2005 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
24 |
|
#include <sys/stat.h> |
25 |
|
#include <errno.h> |
26 |
|
|
27 |
+ |
#ifdef HAVE_AVAILABILITYMACROS_H |
28 |
+ |
#include <AvailabilityMacros.h> |
29 |
+ |
#endif |
30 |
+ |
|
31 |
|
#ifdef __linux__ |
32 |
+ |
#include <sys/mount.h> |
33 |
|
#include <linux/cdrom.h> |
34 |
|
#include <linux/fd.h> |
35 |
|
#include <linux/major.h> |
36 |
|
#include <linux/kdev_t.h> |
37 |
|
#include <linux/unistd.h> |
38 |
+ |
#include <dirent.h> |
39 |
|
|
40 |
|
#ifdef __NR__llseek |
41 |
< |
_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, loff_t *, res, uint, wh); |
41 |
> |
_syscall5(int, _llseek, unsigned int, fd, unsigned long, hi, unsigned long, lo, loff_t *, res, unsigned int, wh); |
42 |
|
#else |
43 |
< |
static int _llseek(uint fd, ulong hi, ulong lo, loff_t *res, uint wh) |
43 |
> |
static int _llseek(unsigned int fd, unsigned long hi, unsigned long lo, loff_t *res, unsigned int wh) |
44 |
|
{ |
45 |
|
if (hi) |
46 |
|
return -1; |
52 |
|
#endif |
53 |
|
#endif |
54 |
|
|
55 |
< |
#ifdef __FreeBSD__ |
55 |
> |
#if defined(__FreeBSD__) || defined(__NetBSD__) |
56 |
|
#include <sys/cdio.h> |
57 |
|
#endif |
58 |
|
|
81 |
|
int cdrom_cap; // CD-ROM capability flags (only valid if is_cdrom is true) |
82 |
|
#elif defined(__FreeBSD__) |
83 |
|
struct ioc_capability cdrom_cap; |
84 |
+ |
#elif defined(__APPLE__) && defined(__MACH__) |
85 |
+ |
char *ioctl_name; // For CDs on OS X - a device for special ioctls |
86 |
+ |
int ioctl_fd; |
87 |
|
#endif |
88 |
|
}; |
89 |
|
|
128 |
|
void SysAddFloppyPrefs(void) |
129 |
|
{ |
130 |
|
#if defined(__linux__) |
131 |
< |
PrefsAddString("floppy", "/dev/fd0H1440"); |
132 |
< |
PrefsAddString("floppy", "/dev/fd1H1440"); |
131 |
> |
if (access("/dev/.devfsd", F_OK) < 0) { |
132 |
> |
PrefsAddString("floppy", "/dev/fd0u1440"); |
133 |
> |
PrefsAddString("floppy", "/dev/fd1u1440"); |
134 |
> |
} else { |
135 |
> |
DIR *fd_dir = opendir("/dev/floppy"); |
136 |
> |
if (fd_dir) { |
137 |
> |
struct dirent *floppy_dev; |
138 |
> |
while ((floppy_dev = readdir(fd_dir)) != NULL) { |
139 |
> |
if (strstr(floppy_dev->d_name, "u1440") != NULL) { |
140 |
> |
char fd_dev[20]; |
141 |
> |
sprintf(fd_dev, "/dev/floppy/%s", floppy_dev->d_name); |
142 |
> |
PrefsAddString("floppy", fd_dev); |
143 |
> |
} |
144 |
> |
} |
145 |
> |
closedir(fd_dir); |
146 |
> |
} |
147 |
> |
} |
148 |
> |
#elif defined(__NetBSD__) |
149 |
> |
PrefsAddString("floppy", "/dev/fd0a"); |
150 |
> |
PrefsAddString("floppy", "/dev/fd1a"); |
151 |
> |
#elif defined(__APPLE__) && defined(__MACH__) |
152 |
> |
#if defined(AQUA) || defined(HAVE_FRAMEWORK_IOKIT) |
153 |
> |
extern void DarwinAddFloppyPrefs(void); |
154 |
> |
|
155 |
> |
DarwinAddFloppyPrefs(); |
156 |
> |
#else |
157 |
> |
// Until I can convince the other guys that my Darwin code is useful, |
158 |
> |
// we just add something safe (a non-existant device): |
159 |
> |
PrefsAddString("floppy", "/dev/null"); |
160 |
> |
#endif |
161 |
|
#else |
162 |
|
PrefsAddString("floppy", "/dev/fd0"); |
163 |
|
PrefsAddString("floppy", "/dev/fd1"); |
168 |
|
/* |
169 |
|
* This gets called when no "disk" prefs items are found |
170 |
|
* It scans for available HFS volumes and adds appropriate prefs items |
171 |
+ |
* On OS X, we could do the same, but on an OS X machine I think it is |
172 |
+ |
* very unlikely that any mounted volumes would contain a system which |
173 |
+ |
* is old enough to boot a 68k Mac, so we just do nothing here for now. |
174 |
|
*/ |
175 |
|
|
176 |
|
void SysAddDiskPrefs(void) |
182 |
|
while(fgets(line, 255, f)) { |
183 |
|
// Read line |
184 |
|
int len = strlen(line); |
185 |
< |
if (len == 0) |
185 |
> |
if (len == 0 || line[0] == '#') |
186 |
|
continue; |
187 |
|
line[len-1] = 0; |
188 |
|
|
189 |
|
// Parse line |
190 |
|
char *dev, *mnt_point, *fstype; |
191 |
< |
if (sscanf(line, "%s %s %s", &dev, &mnt_point, &fstype) == 3) { |
191 |
> |
if (sscanf(line, "%as %as %as", &dev, &mnt_point, &fstype) == 3) { |
192 |
|
if (strcmp(fstype, "hfs") == 0) |
193 |
|
PrefsAddString("disk", dev); |
194 |
|
} |
195 |
+ |
free(dev); free(mnt_point); free(fstype); |
196 |
|
} |
197 |
|
fclose(f); |
198 |
|
} |
212 |
|
return; |
213 |
|
|
214 |
|
#if defined(__linux__) |
215 |
< |
PrefsAddString("cdrom", "/dev/cdrom"); |
216 |
< |
#elif defined(__FreeBSD__) |
215 |
> |
if (access("/dev/.devfsd", F_OK) < 0) |
216 |
> |
PrefsAddString("cdrom", "/dev/cdrom"); |
217 |
> |
else { |
218 |
> |
DIR *cd_dir = opendir("/dev/cdroms"); |
219 |
> |
if (cd_dir) { |
220 |
> |
struct dirent *cdrom_dev; |
221 |
> |
while ((cdrom_dev = readdir(cd_dir)) != NULL) { |
222 |
> |
if (strcmp(cdrom_dev->d_name, ".") != 0 && strcmp(cdrom_dev->d_name, "..") != 0) { |
223 |
> |
char cd_dev[20]; |
224 |
> |
sprintf(cd_dev, "/dev/cdroms/%s", cdrom_dev->d_name); |
225 |
> |
PrefsAddString("cdrom", cd_dev); |
226 |
> |
} |
227 |
> |
} |
228 |
> |
closedir(cd_dir); |
229 |
> |
} |
230 |
> |
} |
231 |
> |
#elif defined(__APPLE__) && defined(__MACH__) |
232 |
> |
#if defined(AQUA) || defined(HAVE_FRAMEWORK_IOKIT) |
233 |
> |
extern void DarwinAddCDROMPrefs(void); |
234 |
> |
|
235 |
> |
DarwinAddCDROMPrefs(); |
236 |
> |
#else |
237 |
> |
// Until I can convince the other guys that my Darwin code is useful, |
238 |
> |
// we just do nothing (it is safe to have no cdrom device) |
239 |
> |
#endif |
240 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
241 |
|
PrefsAddString("cdrom", "/dev/cd0c"); |
242 |
|
#endif |
243 |
|
} |
250 |
|
void SysAddSerialPrefs(void) |
251 |
|
{ |
252 |
|
#if defined(__linux__) |
253 |
< |
PrefsAddString("seriala", "/dev/ttyS0"); |
254 |
< |
PrefsAddString("serialb", "/dev/ttyS1"); |
253 |
> |
if (access("/dev/.devfsd", F_OK) < 0) { |
254 |
> |
PrefsAddString("seriala", "/dev/ttyS0"); |
255 |
> |
PrefsAddString("serialb", "/dev/ttyS1"); |
256 |
> |
} else { |
257 |
> |
PrefsAddString("seriala", "/dev/tts/0"); |
258 |
> |
PrefsAddString("serialb", "/dev/tts/1"); |
259 |
> |
} |
260 |
|
#elif defined(__FreeBSD__) |
261 |
|
PrefsAddString("seriala", "/dev/cuaa0"); |
262 |
|
PrefsAddString("serialb", "/dev/cuaa1"); |
263 |
+ |
#elif defined(__NetBSD__) |
264 |
+ |
PrefsAddString("seriala", "/dev/tty00"); |
265 |
+ |
PrefsAddString("serialb", "/dev/tty01"); |
266 |
+ |
#elif defined(__APPLE__) && defined(__MACH__) |
267 |
+ |
#if defined(AQUA) || defined(HAVE_FRAMEWORK_IOKIT) |
268 |
+ |
extern void DarwinAddSerialPrefs(void); |
269 |
+ |
|
270 |
+ |
DarwinAddSerialPrefs(); |
271 |
+ |
#else |
272 |
+ |
// Until I can convince the other guys that my Darwin code is useful, |
273 |
+ |
// we just add something safe (non-existant devices): |
274 |
+ |
PrefsAddString("seriala", "/dev/null"); |
275 |
+ |
PrefsAddString("serialb", "/dev/null"); |
276 |
+ |
#endif |
277 |
|
#endif |
278 |
|
} |
279 |
|
|
298 |
|
// Parse line |
299 |
|
if (strncmp(line, dev_name, strlen(dev_name)) == 0) { |
300 |
|
mount_name[0] = 0; |
301 |
< |
char dummy[256]; |
302 |
< |
sscanf(line, "%s %s", dummy, mount_name); |
301 |
> |
char *dummy; |
302 |
> |
sscanf(line, "%as %s", &dummy, mount_name); |
303 |
> |
free(dummy); |
304 |
|
fclose(f); |
305 |
|
return true; |
306 |
|
} |
319 |
|
void *Sys_open(const char *name, bool read_only) |
320 |
|
{ |
321 |
|
bool is_file = strncmp(name, "/dev/", 5) != 0; |
322 |
< |
#ifdef __FreeBSD__ |
322 |
> |
#if defined(__FreeBSD__) |
323 |
|
// SCSI IDE |
324 |
|
bool is_cdrom = strncmp(name, "/dev/cd", 7) == 0 || strncmp(name, "/dev/acd", 8) == 0; |
325 |
|
#else |
326 |
|
bool is_cdrom = strncmp(name, "/dev/cd", 7) == 0; |
327 |
|
#endif |
328 |
|
|
329 |
+ |
#if defined(__APPLE__) && defined(__MACH__) |
330 |
+ |
// |
331 |
+ |
// There is no set filename in /dev which is the cdrom, |
332 |
+ |
// so we have to see if it is any of the devices that we found earlier |
333 |
+ |
// |
334 |
+ |
const char *cdrom; |
335 |
+ |
int tmp = 0; |
336 |
+ |
|
337 |
+ |
while ( (cdrom = PrefsFindString("cdrom", tmp) ) != NULL ) |
338 |
+ |
{ |
339 |
+ |
if ( strcmp(name, cdrom) == 0 ) |
340 |
+ |
{ |
341 |
+ |
is_cdrom = 1; |
342 |
+ |
read_only = 1; |
343 |
+ |
break; |
344 |
+ |
} |
345 |
+ |
++tmp; |
346 |
+ |
} |
347 |
+ |
#endif |
348 |
+ |
|
349 |
|
D(bug("Sys_open(%s, %s)\n", name, read_only ? "read-only" : "read/write")); |
350 |
|
|
351 |
|
// Check if write access is allowed, set read-only flag if not |
367 |
|
} |
368 |
|
|
369 |
|
// Open file/device |
370 |
< |
#ifdef __linux__ |
370 |
> |
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) |
371 |
|
int fd = open(name, (read_only ? O_RDONLY : O_RDWR) | (is_cdrom ? O_NONBLOCK : 0)); |
372 |
|
#else |
373 |
|
int fd = open(name, read_only ? O_RDONLY : O_RDWR); |
389 |
|
if (fh->is_file) { |
390 |
|
// Detect disk image file layout |
391 |
|
loff_t size = 0; |
392 |
< |
#ifdef __linux__ |
392 |
> |
#if defined(__linux__) |
393 |
|
_llseek(fh->fd, 0, 0, &size, SEEK_END); |
394 |
|
#else |
395 |
|
size = lseek(fd, 0, SEEK_END); |
424 |
|
#else |
425 |
|
fh->cdrom_cap = 0; |
426 |
|
#endif |
427 |
+ |
#elif defined(__NetBSD__) |
428 |
+ |
fh->is_floppy = ((st.st_rdev >> 16) == 2); |
429 |
|
#endif |
430 |
|
} |
431 |
+ |
#if defined(__APPLE__) && defined(__MACH__) |
432 |
+ |
|
433 |
+ |
// In OS X, the device name is OK for sending ioctls to, |
434 |
+ |
// but not for reading raw CDROM data from. |
435 |
+ |
// (it seems to have extra data padded in) |
436 |
+ |
// |
437 |
+ |
// So, we keep the already opened fiole handle, |
438 |
+ |
// and open a slightly different file for CDROM data |
439 |
+ |
// |
440 |
+ |
if ( is_cdrom ) |
441 |
+ |
{ |
442 |
+ |
fh->ioctl_name = fh->name; |
443 |
+ |
fh->ioctl_fd = fh->fd; |
444 |
+ |
|
445 |
+ |
fh->name = (char *) malloc(strlen(name) + 2); |
446 |
+ |
if ( fh->name ) |
447 |
+ |
{ |
448 |
+ |
*fh->name = '\0'; |
449 |
+ |
strcat(fh->name, name); |
450 |
+ |
strcat(fh->name, "s1"); |
451 |
+ |
fh->fd = open(fh->name, (read_only ? O_RDONLY : O_RDWR)); |
452 |
+ |
if ( fh->fd < 0 ) { |
453 |
+ |
printf("WARNING: Cannot open %s (%s)\n", |
454 |
+ |
fh->name, strerror(errno)); |
455 |
+ |
return NULL; |
456 |
+ |
} |
457 |
+ |
} |
458 |
+ |
} |
459 |
+ |
#endif |
460 |
|
} |
461 |
|
} |
462 |
|
if (fh->is_floppy && first_floppy == NULL) |
498 |
|
return 0; |
499 |
|
|
500 |
|
// Seek to position |
501 |
< |
#ifdef __linux__ |
501 |
> |
#if defined(__linux__) |
502 |
|
loff_t pos = offset + fh->start_byte, res; |
503 |
|
if (_llseek(fh->fd, pos >> 32, pos, &res, SEEK_SET) < 0) |
504 |
|
return 0; |
524 |
|
return 0; |
525 |
|
|
526 |
|
// Seek to position |
527 |
< |
#ifdef __linux__ |
527 |
> |
#if defined(__linux__) |
528 |
|
loff_t pos = offset + fh->start_byte, res; |
529 |
|
if (_llseek(fh->fd, pos >> 32, pos, &res, SEEK_SET) < 0) |
530 |
|
return 0; |
551 |
|
if (fh->is_file) |
552 |
|
return fh->file_size; |
553 |
|
else { |
554 |
< |
#ifdef __linux__ |
555 |
< |
loff_t pos = 0; |
556 |
< |
_llseek(fh->fd, 0, 0, &pos, SEEK_END); |
557 |
< |
return pos - fh->start_byte; |
554 |
> |
#if defined(__linux__) |
555 |
> |
long blocks; |
556 |
> |
if (ioctl(fh->fd, BLKGETSIZE, &blocks) < 0) |
557 |
> |
return 0; |
558 |
> |
D(bug(" BLKGETSIZE returns %d blocks\n", blocks)); |
559 |
> |
return (loff_t)blocks * 512; |
560 |
|
#else |
561 |
|
return lseek(fh->fd, 0, SEEK_END) - fh->start_byte; |
562 |
|
#endif |
579 |
|
fsync(fh->fd); |
580 |
|
ioctl(fh->fd, FDFLUSH); |
581 |
|
ioctl(fh->fd, FDEJECT); |
582 |
+ |
close(fh->fd); // Close and reopen so the driver will see the media change |
583 |
+ |
fh->fd = open(fh->name, fh->read_only ? O_RDONLY : O_RDWR); |
584 |
|
} else if (fh->is_cdrom) { |
585 |
|
ioctl(fh->fd, CDROMEJECT); |
586 |
|
close(fh->fd); // Close and reopen so the driver will see the media change |
587 |
|
fh->fd = open(fh->name, O_RDONLY | O_NONBLOCK); |
588 |
|
} |
589 |
< |
#elif defined(__FreeBSD__) |
589 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
590 |
|
if (fh->is_floppy) { |
591 |
|
fsync(fh->fd); |
452 |
– |
//ioctl(fh->fd, FDFLUSH); |
453 |
– |
//ioctl(fh->fd, FDEJECT); |
592 |
|
} else if (fh->is_cdrom) { |
593 |
|
ioctl(fh->fd, CDIOCEJECT); |
594 |
|
close(fh->fd); // Close and reopen so the driver will see the media change |
595 |
|
fh->fd = open(fh->name, O_RDONLY | O_NONBLOCK); |
596 |
|
} |
597 |
+ |
#elif defined(__APPLE__) && defined(__MACH__) |
598 |
+ |
if ( fh->is_cdrom ) { |
599 |
+ |
|
600 |
+ |
// Stolen from IOKit/storage/IOMediaBSDClient.h |
601 |
+ |
#define DKIOCEJECT _IO('d', 21) |
602 |
+ |
|
603 |
+ |
close(fh->fd); |
604 |
+ |
if ( ioctl(fh->ioctl_fd, DKIOCEJECT) < 0 ) |
605 |
+ |
{ |
606 |
+ |
printf("ioctl(DKIOCEJECT) failed on file %s: %s\n", |
607 |
+ |
fh->ioctl_name, strerror(errno)); |
608 |
+ |
|
609 |
+ |
// If we are running OSX, the device may be is busy |
610 |
+ |
// due to the Finder having the disk mounted and open, |
611 |
+ |
// so we have to use another method. |
612 |
+ |
|
613 |
+ |
// The only problem is that this takes about 5 seconds: |
614 |
+ |
|
615 |
+ |
char *cmd = (char *) malloc(30+sizeof(fh->name)); |
616 |
+ |
|
617 |
+ |
if ( ! cmd ) |
618 |
+ |
return; |
619 |
+ |
close(fh->ioctl_fd); |
620 |
+ |
sprintf(cmd, "diskutil eject %s 2>&1 >/dev/null", fh->name); |
621 |
+ |
system(cmd); |
622 |
+ |
} |
623 |
+ |
} |
624 |
|
#endif |
625 |
|
} |
626 |
|
|
650 |
|
if (!fh) |
651 |
|
return true; |
652 |
|
|
653 |
< |
#ifdef __linux__ |
653 |
> |
#if defined(__linux__) |
654 |
|
if (fh->is_floppy) { |
655 |
|
struct floppy_drive_struct stat; |
656 |
|
ioctl(fh->fd, FDGETDRVSTAT, &stat); |
697 |
|
} else if (fh->is_floppy) { |
698 |
|
char block[512]; |
699 |
|
lseek(fh->fd, 0, SEEK_SET); |
700 |
< |
return read(fh->fd, block, 512) == 512; |
700 |
> |
ssize_t actual = read(fh->fd, block, 512); |
701 |
> |
if (actual < 0) { |
702 |
> |
close(fh->fd); // Close and reopen so the driver will see the media change |
703 |
> |
fh->fd = open(fh->name, fh->read_only ? O_RDONLY : O_RDWR); |
704 |
> |
actual = read(fh->fd, block, 512); |
705 |
> |
} |
706 |
> |
return actual == 512; |
707 |
|
} else if (fh->is_cdrom) { |
708 |
+ |
#ifdef CDROM_MEDIA_CHANGED |
709 |
+ |
if (fh->cdrom_cap & CDC_MEDIA_CHANGED) { |
710 |
+ |
// If we don't do this, all attempts to read from a disc fail |
711 |
+ |
// once the tray has been opened (altough the TOC reads fine). |
712 |
+ |
// Can somebody explain this to me? |
713 |
+ |
if (ioctl(fh->fd, CDROM_MEDIA_CHANGED) == 1) { |
714 |
+ |
close(fh->fd); |
715 |
+ |
fh->fd = open(fh->name, O_RDONLY | O_NONBLOCK); |
716 |
+ |
} |
717 |
+ |
} |
718 |
+ |
#endif |
719 |
|
#ifdef CDROM_DRIVE_STATUS |
720 |
|
if (fh->cdrom_cap & CDC_DRIVE_STATUS) { |
721 |
|
return ioctl(fh->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) == CDS_DISC_OK; |
723 |
|
#endif |
724 |
|
cdrom_tochdr header; |
725 |
|
return ioctl(fh->fd, CDROMREADTOCHDR, &header) == 0; |
726 |
< |
#elif defined(__FreeBSD__) |
726 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
727 |
|
} else if (fh->is_floppy) { |
728 |
|
return false; //!! |
729 |
|
} else if (fh->is_cdrom) { |
763 |
|
if (!fh) |
764 |
|
return; |
765 |
|
|
766 |
< |
#ifdef defined(__linux__) && defined(CDROM_LOCKDOOR) |
766 |
> |
#if defined(__linux__) && defined(CDROM_LOCKDOOR) |
767 |
|
if (fh->is_cdrom) |
768 |
|
ioctl(fh->fd, CDROM_LOCKDOOR, 0); |
769 |
|
#endif |
827 |
|
*toc++ = toc_size >> 8; |
828 |
|
*toc++ = toc_size & 0xff; |
829 |
|
return true; |
830 |
+ |
#elif defined(__APPLE__) && defined(__MACH__) && defined(MAC_OS_X_VERSION_10_2) |
831 |
+ |
extern bool DarwinCDReadTOC(char *name, uint8 *toc); |
832 |
+ |
|
833 |
+ |
return DarwinCDReadTOC(fh->name, toc); |
834 |
|
#elif defined(__FreeBSD__) |
835 |
|
uint8 *p = toc + 2; |
836 |
|
|
877 |
|
*toc++ = toc_size >> 8; |
878 |
|
*toc++ = toc_size & 0xff; |
879 |
|
return true; |
880 |
+ |
#elif defined(__NetBSD__) |
881 |
+ |
uint8 *p = toc + 2; |
882 |
+ |
|
883 |
+ |
// Header |
884 |
+ |
struct ioc_toc_header header; |
885 |
+ |
if (ioctl(fh->fd, CDIOREADTOCHEADER, &header) < 0) |
886 |
+ |
return false; |
887 |
+ |
*p++ = header.starting_track; |
888 |
+ |
*p++ = header.ending_track; |
889 |
+ |
|
890 |
+ |
// Tracks (this is nice... :-) |
891 |
+ |
struct ioc_read_toc_entry entries; |
892 |
+ |
entries.address_format = CD_MSF_FORMAT; |
893 |
+ |
entries.starting_track = 1; |
894 |
+ |
entries.data_len = 800; |
895 |
+ |
entries.data = (cd_toc_entry *)p; |
896 |
+ |
if (ioctl(fh->fd, CDIOREADTOCENTRIES, &entries) < 0) |
897 |
+ |
return false; |
898 |
+ |
|
899 |
+ |
// TOC size |
900 |
+ |
int toc_size = p - toc; |
901 |
+ |
*toc++ = toc_size >> 8; |
902 |
+ |
*toc++ = toc_size & 0xff; |
903 |
+ |
return true; |
904 |
+ |
#else |
905 |
+ |
return false; |
906 |
|
#endif |
907 |
|
} else |
908 |
|
return false; |
942 |
|
*pos++ = chan.cdsc_reladdr.msf.second; |
943 |
|
*pos++ = chan.cdsc_reladdr.msf.frame; |
944 |
|
return true; |
945 |
< |
#elif defined(__FreeBSD__) |
945 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
946 |
|
struct ioc_read_subchannel chan; |
947 |
|
chan.data_format = CD_MSF_FORMAT; |
948 |
|
chan.address_format = CD_MSF_FORMAT; |
966 |
|
*pos++ = chan.data->what.position.reladdr.msf.second; |
967 |
|
*pos++ = chan.data->what.position.reladdr.msf.frame; |
968 |
|
return true; |
969 |
+ |
#else |
970 |
+ |
return false; |
971 |
|
#endif |
972 |
|
} else |
973 |
|
return false; |
994 |
|
play.cdmsf_sec1 = end_s; |
995 |
|
play.cdmsf_frame1 = end_f; |
996 |
|
return ioctl(fh->fd, CDROMPLAYMSF, &play) == 0; |
997 |
< |
#elif defined(__FreeBSD__) |
997 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
998 |
|
struct ioc_play_msf play; |
999 |
|
play.start_m = start_m; |
1000 |
|
play.start_s = start_s; |
1003 |
|
play.end_s = end_s; |
1004 |
|
play.end_f = end_f; |
1005 |
|
return ioctl(fh->fd, CDIOCPLAYMSF, &play) == 0; |
1006 |
+ |
#else |
1007 |
+ |
return false; |
1008 |
|
#endif |
1009 |
|
} else |
1010 |
|
return false; |
1024 |
|
if (fh->is_cdrom) { |
1025 |
|
#if defined(__linux__) |
1026 |
|
return ioctl(fh->fd, CDROMPAUSE) == 0; |
1027 |
< |
#elif defined(__FreeBSD__) |
1027 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
1028 |
|
return ioctl(fh->fd, CDIOCPAUSE) == 0; |
1029 |
+ |
#else |
1030 |
+ |
return false; |
1031 |
|
#endif |
1032 |
|
} else |
1033 |
|
return false; |
1047 |
|
if (fh->is_cdrom) { |
1048 |
|
#if defined(__linux__) |
1049 |
|
return ioctl(fh->fd, CDROMRESUME) == 0; |
1050 |
< |
#elif defined(__FreeBSD__) |
1050 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
1051 |
|
return ioctl(fh->fd, CDIOCRESUME) == 0; |
1052 |
+ |
#else |
1053 |
+ |
return false; |
1054 |
|
#endif |
1055 |
|
} else |
1056 |
|
return false; |
1070 |
|
if (fh->is_cdrom) { |
1071 |
|
#if defined(__linux__) |
1072 |
|
return ioctl(fh->fd, CDROMSTOP) == 0; |
1073 |
< |
#elif defined(__FreeBSD__) |
1073 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
1074 |
|
return ioctl(fh->fd, CDIOCSTOP) == 0; |
1075 |
+ |
#else |
1076 |
+ |
return false; |
1077 |
|
#endif |
1078 |
|
} else |
1079 |
|
return false; |
1111 |
|
vol.channel0 = vol.channel2 = left; |
1112 |
|
vol.channel1 = vol.channel3 = right; |
1113 |
|
ioctl(fh->fd, CDROMVOLCTRL, &vol); |
1114 |
< |
#elif defined(__FreeBSD__) |
1114 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
1115 |
|
struct ioc_vol vol; |
1116 |
|
vol.vol[0] = vol.vol[2] = left; |
1117 |
|
vol.vol[1] = vol.vol[3] = right; |
1138 |
|
ioctl(fh->fd, CDROMVOLREAD, &vol); |
1139 |
|
left = vol.channel0; |
1140 |
|
right = vol.channel1; |
1141 |
< |
#elif defined(__FreeBSD__) |
1141 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
1142 |
|
struct ioc_vol vol; |
1143 |
|
ioctl(fh->fd, CDIOCGETVOL, &vol); |
1144 |
|
left = vol.vol[0]; |