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> |
33 |
< |
|
34 |
< |
#ifdef __NR__llseek |
35 |
< |
_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, loff_t *, res, uint, wh); |
36 |
< |
#else |
37 |
< |
static int _llseek(uint fd, ulong hi, ulong lo, loff_t *res, uint wh) |
38 |
< |
{ |
39 |
< |
if (hi) |
40 |
< |
return -1; |
41 |
< |
*res = lseek(fd, lo, wh); |
42 |
< |
if (*res == -1) |
43 |
< |
return -1; |
44 |
< |
return 0; |
45 |
< |
} |
46 |
< |
#endif |
37 |
> |
#include <dirent.h> |
38 |
|
#endif |
39 |
|
|
40 |
< |
#ifdef __FreeBSD__ |
40 |
> |
#if defined(__FreeBSD__) || defined(__NetBSD__) |
41 |
|
#include <sys/cdio.h> |
42 |
|
#endif |
43 |
|
|
66 |
|
int cdrom_cap; // CD-ROM capability flags (only valid if is_cdrom is true) |
67 |
|
#elif defined(__FreeBSD__) |
68 |
|
struct ioc_capability cdrom_cap; |
69 |
+ |
#elif defined(__APPLE__) && defined(__MACH__) |
70 |
+ |
char *ioctl_name; // For CDs on OS X - a device for special ioctls |
71 |
+ |
int ioctl_fd; |
72 |
|
#endif |
73 |
|
}; |
74 |
|
|
113 |
|
void SysAddFloppyPrefs(void) |
114 |
|
{ |
115 |
|
#if defined(__linux__) |
116 |
< |
PrefsAddString("floppy", "/dev/fd0H1440"); |
117 |
< |
PrefsAddString("floppy", "/dev/fd1H1440"); |
116 |
> |
if (access("/dev/.devfsd", F_OK) < 0) { |
117 |
> |
PrefsAddString("floppy", "/dev/fd0u1440"); |
118 |
> |
PrefsAddString("floppy", "/dev/fd1u1440"); |
119 |
> |
} else { |
120 |
> |
DIR *fd_dir = opendir("/dev/floppy"); |
121 |
> |
if (fd_dir) { |
122 |
> |
struct dirent *floppy_dev; |
123 |
> |
while ((floppy_dev = readdir(fd_dir)) != NULL) { |
124 |
> |
if (strstr(floppy_dev->d_name, "u1440") != NULL) { |
125 |
> |
char fd_dev[20]; |
126 |
> |
sprintf(fd_dev, "/dev/floppy/%s", floppy_dev->d_name); |
127 |
> |
PrefsAddString("floppy", fd_dev); |
128 |
> |
} |
129 |
> |
} |
130 |
> |
closedir(fd_dir); |
131 |
> |
} |
132 |
> |
} |
133 |
> |
#elif defined(__NetBSD__) |
134 |
> |
PrefsAddString("floppy", "/dev/fd0a"); |
135 |
> |
PrefsAddString("floppy", "/dev/fd1a"); |
136 |
> |
#elif defined(__APPLE__) && defined(__MACH__) |
137 |
> |
#if defined(AQUA) || defined(HAVE_FRAMEWORK_COREFOUNDATION) |
138 |
> |
extern void DarwinAddFloppyPrefs(void); |
139 |
> |
|
140 |
> |
DarwinAddFloppyPrefs(); |
141 |
> |
#else |
142 |
> |
// Until I can convince the other guys that my Darwin code is useful, |
143 |
> |
// we just add something safe (a non-existant device): |
144 |
> |
PrefsAddString("floppy", "/dev/null"); |
145 |
> |
#endif |
146 |
|
#else |
147 |
|
PrefsAddString("floppy", "/dev/fd0"); |
148 |
|
PrefsAddString("floppy", "/dev/fd1"); |
153 |
|
/* |
154 |
|
* This gets called when no "disk" prefs items are found |
155 |
|
* It scans for available HFS volumes and adds appropriate prefs items |
156 |
+ |
* On OS X, we could do the same, but on an OS X machine I think it is |
157 |
+ |
* very unlikely that any mounted volumes would contain a system which |
158 |
+ |
* is old enough to boot a 68k Mac, so we just do nothing here for now. |
159 |
|
*/ |
160 |
|
|
161 |
|
void SysAddDiskPrefs(void) |
167 |
|
while(fgets(line, 255, f)) { |
168 |
|
// Read line |
169 |
|
int len = strlen(line); |
170 |
< |
if (len == 0) |
170 |
> |
if (len == 0 || line[0] == '#') |
171 |
|
continue; |
172 |
|
line[len-1] = 0; |
173 |
|
|
174 |
|
// Parse line |
175 |
|
char *dev, *mnt_point, *fstype; |
176 |
< |
if (sscanf(line, "%s %s %s", &dev, &mnt_point, &fstype) == 3) { |
176 |
> |
if (sscanf(line, "%as %as %as", &dev, &mnt_point, &fstype) == 3) { |
177 |
|
if (strcmp(fstype, "hfs") == 0) |
178 |
|
PrefsAddString("disk", dev); |
179 |
|
} |
180 |
+ |
free(dev); free(mnt_point); free(fstype); |
181 |
|
} |
182 |
|
fclose(f); |
183 |
|
} |
197 |
|
return; |
198 |
|
|
199 |
|
#if defined(__linux__) |
200 |
< |
PrefsAddString("cdrom", "/dev/cdrom"); |
201 |
< |
#elif defined(__FreeBSD__) |
200 |
> |
if (access("/dev/.devfsd", F_OK) < 0) |
201 |
> |
PrefsAddString("cdrom", "/dev/cdrom"); |
202 |
> |
else { |
203 |
> |
DIR *cd_dir = opendir("/dev/cdroms"); |
204 |
> |
if (cd_dir) { |
205 |
> |
struct dirent *cdrom_dev; |
206 |
> |
while ((cdrom_dev = readdir(cd_dir)) != NULL) { |
207 |
> |
if (strcmp(cdrom_dev->d_name, ".") != 0 && strcmp(cdrom_dev->d_name, "..") != 0) { |
208 |
> |
char cd_dev[20]; |
209 |
> |
sprintf(cd_dev, "/dev/cdroms/%s", cdrom_dev->d_name); |
210 |
> |
PrefsAddString("cdrom", cd_dev); |
211 |
> |
} |
212 |
> |
} |
213 |
> |
closedir(cd_dir); |
214 |
> |
} |
215 |
> |
} |
216 |
> |
#elif defined(__APPLE__) && defined(__MACH__) |
217 |
> |
#if defined(AQUA) || defined(HAVE_FRAMEWORK_COREFOUNDATION) |
218 |
> |
extern void DarwinAddCDROMPrefs(void); |
219 |
> |
|
220 |
> |
DarwinAddCDROMPrefs(); |
221 |
> |
#else |
222 |
> |
// Until I can convince the other guys that my Darwin code is useful, |
223 |
> |
// we just do nothing (it is safe to have no cdrom device) |
224 |
> |
#endif |
225 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
226 |
|
PrefsAddString("cdrom", "/dev/cd0c"); |
227 |
|
#endif |
228 |
|
} |
235 |
|
void SysAddSerialPrefs(void) |
236 |
|
{ |
237 |
|
#if defined(__linux__) |
238 |
< |
PrefsAddString("seriala", "/dev/ttyS0"); |
239 |
< |
PrefsAddString("serialb", "/dev/ttyS1"); |
238 |
> |
if (access("/dev/.devfsd", F_OK) < 0) { |
239 |
> |
PrefsAddString("seriala", "/dev/ttyS0"); |
240 |
> |
PrefsAddString("serialb", "/dev/ttyS1"); |
241 |
> |
} else { |
242 |
> |
PrefsAddString("seriala", "/dev/tts/0"); |
243 |
> |
PrefsAddString("serialb", "/dev/tts/1"); |
244 |
> |
} |
245 |
|
#elif defined(__FreeBSD__) |
246 |
|
PrefsAddString("seriala", "/dev/cuaa0"); |
247 |
|
PrefsAddString("serialb", "/dev/cuaa1"); |
248 |
+ |
#elif defined(__NetBSD__) |
249 |
+ |
PrefsAddString("seriala", "/dev/tty00"); |
250 |
+ |
PrefsAddString("serialb", "/dev/tty01"); |
251 |
+ |
#elif defined(__APPLE__) && defined(__MACH__) |
252 |
+ |
#if defined(AQUA) || defined(HAVE_FRAMEWORK_COREFOUNDATION) |
253 |
+ |
extern void DarwinAddSerialPrefs(void); |
254 |
+ |
|
255 |
+ |
DarwinAddSerialPrefs(); |
256 |
+ |
#else |
257 |
+ |
// Until I can convince the other guys that my Darwin code is useful, |
258 |
+ |
// we just add something safe (non-existant devices): |
259 |
+ |
PrefsAddString("seriala", "/dev/null"); |
260 |
+ |
PrefsAddString("serialb", "/dev/null"); |
261 |
+ |
#endif |
262 |
|
#endif |
263 |
|
} |
264 |
|
|
283 |
|
// Parse line |
284 |
|
if (strncmp(line, dev_name, strlen(dev_name)) == 0) { |
285 |
|
mount_name[0] = 0; |
286 |
< |
char dummy[256]; |
287 |
< |
sscanf(line, "%s %s", dummy, mount_name); |
286 |
> |
char *dummy; |
287 |
> |
sscanf(line, "%as %s", &dummy, mount_name); |
288 |
> |
free(dummy); |
289 |
|
fclose(f); |
290 |
|
return true; |
291 |
|
} |
304 |
|
void *Sys_open(const char *name, bool read_only) |
305 |
|
{ |
306 |
|
bool is_file = strncmp(name, "/dev/", 5) != 0; |
307 |
< |
#ifdef __FreeBSD__ |
307 |
> |
#if defined(__FreeBSD__) |
308 |
|
// SCSI IDE |
309 |
|
bool is_cdrom = strncmp(name, "/dev/cd", 7) == 0 || strncmp(name, "/dev/acd", 8) == 0; |
310 |
|
#else |
311 |
|
bool is_cdrom = strncmp(name, "/dev/cd", 7) == 0; |
312 |
|
#endif |
313 |
|
|
314 |
+ |
#if defined(__APPLE__) && defined(__MACH__) |
315 |
+ |
// |
316 |
+ |
// There is no set filename in /dev which is the cdrom, |
317 |
+ |
// so we have to see if it is any of the devices that we found earlier |
318 |
+ |
// |
319 |
+ |
const char *cdrom; |
320 |
+ |
int tmp = 0; |
321 |
+ |
|
322 |
+ |
while ( (cdrom = PrefsFindString("cdrom", tmp) ) != NULL ) |
323 |
+ |
{ |
324 |
+ |
if ( strcmp(name, cdrom) == 0 ) |
325 |
+ |
{ |
326 |
+ |
is_cdrom = 1; |
327 |
+ |
read_only = 1; |
328 |
+ |
break; |
329 |
+ |
} |
330 |
+ |
++tmp; |
331 |
+ |
} |
332 |
+ |
#endif |
333 |
+ |
|
334 |
|
D(bug("Sys_open(%s, %s)\n", name, read_only ? "read-only" : "read/write")); |
335 |
|
|
336 |
|
// Check if write access is allowed, set read-only flag if not |
352 |
|
} |
353 |
|
|
354 |
|
// Open file/device |
355 |
< |
#ifdef __linux__ |
355 |
> |
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) |
356 |
|
int fd = open(name, (read_only ? O_RDONLY : O_RDWR) | (is_cdrom ? O_NONBLOCK : 0)); |
357 |
|
#else |
358 |
|
int fd = open(name, read_only ? O_RDONLY : O_RDWR); |
374 |
|
if (fh->is_file) { |
375 |
|
// Detect disk image file layout |
376 |
|
loff_t size = 0; |
287 |
– |
#ifdef __linux__ |
288 |
– |
_llseek(fh->fd, 0, 0, &size, SEEK_END); |
289 |
– |
#else |
377 |
|
size = lseek(fd, 0, SEEK_END); |
291 |
– |
#endif |
378 |
|
uint8 data[256]; |
379 |
|
lseek(fd, 0, SEEK_SET); |
380 |
|
read(fd, data, 256); |
405 |
|
#else |
406 |
|
fh->cdrom_cap = 0; |
407 |
|
#endif |
408 |
+ |
#elif defined(__NetBSD__) |
409 |
+ |
fh->is_floppy = ((st.st_rdev >> 16) == 2); |
410 |
|
#endif |
411 |
|
} |
412 |
+ |
#if defined(__APPLE__) && defined(__MACH__) |
413 |
+ |
|
414 |
+ |
// In OS X, the device name is OK for sending ioctls to, |
415 |
+ |
// but not for reading raw CDROM data from. |
416 |
+ |
// (it seems to have extra data padded in) |
417 |
+ |
// |
418 |
+ |
// So, we keep the already opened fiole handle, |
419 |
+ |
// and open a slightly different file for CDROM data |
420 |
+ |
// |
421 |
+ |
if ( is_cdrom ) |
422 |
+ |
{ |
423 |
+ |
fh->ioctl_name = fh->name; |
424 |
+ |
fh->ioctl_fd = fh->fd; |
425 |
+ |
|
426 |
+ |
fh->name = (char *) malloc(strlen(name) + 2); |
427 |
+ |
if ( fh->name ) |
428 |
+ |
{ |
429 |
+ |
*fh->name = '\0'; |
430 |
+ |
strcat(fh->name, name); |
431 |
+ |
strcat(fh->name, "s1"); |
432 |
+ |
fh->fd = open(fh->name, (read_only ? O_RDONLY : O_RDWR)); |
433 |
+ |
if ( fh->fd < 0 ) { |
434 |
+ |
printf("WARNING: Cannot open %s (%s)\n", |
435 |
+ |
fh->name, strerror(errno)); |
436 |
+ |
return NULL; |
437 |
+ |
} |
438 |
+ |
} |
439 |
+ |
} |
440 |
+ |
#endif |
441 |
|
} |
442 |
|
} |
443 |
|
if (fh->is_floppy && first_floppy == NULL) |
479 |
|
return 0; |
480 |
|
|
481 |
|
// Seek to position |
365 |
– |
#ifdef __linux__ |
366 |
– |
loff_t pos = offset + fh->start_byte, res; |
367 |
– |
if (_llseek(fh->fd, pos >> 32, pos, &res, SEEK_SET) < 0) |
368 |
– |
return 0; |
369 |
– |
#else |
482 |
|
if (lseek(fh->fd, offset + fh->start_byte, SEEK_SET) < 0) |
483 |
|
return 0; |
372 |
– |
#endif |
484 |
|
|
485 |
|
// Read data |
486 |
|
return read(fh->fd, buffer, length); |
499 |
|
return 0; |
500 |
|
|
501 |
|
// Seek to position |
391 |
– |
#ifdef __linux__ |
392 |
– |
loff_t pos = offset + fh->start_byte, res; |
393 |
– |
if (_llseek(fh->fd, pos >> 32, pos, &res, SEEK_SET) < 0) |
394 |
– |
return 0; |
395 |
– |
#else |
502 |
|
if (lseek(fh->fd, offset + fh->start_byte, SEEK_SET) < 0) |
503 |
|
return 0; |
398 |
– |
#endif |
504 |
|
|
505 |
|
// Write data |
506 |
|
return write(fh->fd, buffer, length); |
520 |
|
if (fh->is_file) |
521 |
|
return fh->file_size; |
522 |
|
else { |
523 |
< |
#ifdef __linux__ |
524 |
< |
loff_t pos = 0; |
525 |
< |
_llseek(fh->fd, 0, 0, &pos, SEEK_END); |
526 |
< |
return pos - fh->start_byte; |
523 |
> |
#if defined(__linux__) |
524 |
> |
long blocks; |
525 |
> |
if (ioctl(fh->fd, BLKGETSIZE, &blocks) < 0) |
526 |
> |
return 0; |
527 |
> |
D(bug(" BLKGETSIZE returns %d blocks\n", blocks)); |
528 |
> |
return (loff_t)blocks * 512; |
529 |
|
#else |
530 |
|
return lseek(fh->fd, 0, SEEK_END) - fh->start_byte; |
531 |
|
#endif |
548 |
|
fsync(fh->fd); |
549 |
|
ioctl(fh->fd, FDFLUSH); |
550 |
|
ioctl(fh->fd, FDEJECT); |
551 |
+ |
close(fh->fd); // Close and reopen so the driver will see the media change |
552 |
+ |
fh->fd = open(fh->name, fh->read_only ? O_RDONLY : O_RDWR); |
553 |
|
} else if (fh->is_cdrom) { |
554 |
|
ioctl(fh->fd, CDROMEJECT); |
555 |
|
close(fh->fd); // Close and reopen so the driver will see the media change |
556 |
|
fh->fd = open(fh->name, O_RDONLY | O_NONBLOCK); |
557 |
|
} |
558 |
< |
#elif defined(__FreeBSD__) |
558 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
559 |
|
if (fh->is_floppy) { |
560 |
|
fsync(fh->fd); |
452 |
– |
//ioctl(fh->fd, FDFLUSH); |
453 |
– |
//ioctl(fh->fd, FDEJECT); |
561 |
|
} else if (fh->is_cdrom) { |
562 |
|
ioctl(fh->fd, CDIOCEJECT); |
563 |
|
close(fh->fd); // Close and reopen so the driver will see the media change |
564 |
|
fh->fd = open(fh->name, O_RDONLY | O_NONBLOCK); |
565 |
|
} |
566 |
+ |
#elif defined(__APPLE__) && defined(__MACH__) |
567 |
+ |
if ( fh->is_cdrom ) { |
568 |
+ |
|
569 |
+ |
// Stolen from IOKit/storage/IOMediaBSDClient.h |
570 |
+ |
#define DKIOCEJECT _IO('d', 21) |
571 |
+ |
|
572 |
+ |
close(fh->fd); |
573 |
+ |
if ( ioctl(fh->ioctl_fd, DKIOCEJECT) < 0 ) |
574 |
+ |
{ |
575 |
+ |
printf("ioctl(DKIOCEJECT) failed on file %s: %s\n", |
576 |
+ |
fh->ioctl_name, strerror(errno)); |
577 |
+ |
|
578 |
+ |
// If we are running OSX, the device may be is busy |
579 |
+ |
// due to the Finder having the disk mounted and open, |
580 |
+ |
// so we have to use another method. |
581 |
+ |
|
582 |
+ |
// The only problem is that this takes about 5 seconds: |
583 |
+ |
|
584 |
+ |
char *cmd = (char *) malloc(30+sizeof(fh->name)); |
585 |
+ |
|
586 |
+ |
if ( ! cmd ) |
587 |
+ |
return; |
588 |
+ |
close(fh->ioctl_fd); |
589 |
+ |
sprintf(cmd, "diskutil eject %s 2>&1 >/dev/null", fh->name); |
590 |
+ |
system(cmd); |
591 |
+ |
} |
592 |
+ |
} |
593 |
|
#endif |
594 |
|
} |
595 |
|
|
619 |
|
if (!fh) |
620 |
|
return true; |
621 |
|
|
622 |
< |
#ifdef __linux__ |
622 |
> |
#if defined(__linux__) |
623 |
|
if (fh->is_floppy) { |
624 |
|
struct floppy_drive_struct stat; |
625 |
|
ioctl(fh->fd, FDGETDRVSTAT, &stat); |
666 |
|
} else if (fh->is_floppy) { |
667 |
|
char block[512]; |
668 |
|
lseek(fh->fd, 0, SEEK_SET); |
669 |
< |
return read(fh->fd, block, 512) == 512; |
669 |
> |
ssize_t actual = read(fh->fd, block, 512); |
670 |
> |
if (actual < 0) { |
671 |
> |
close(fh->fd); // Close and reopen so the driver will see the media change |
672 |
> |
fh->fd = open(fh->name, fh->read_only ? O_RDONLY : O_RDWR); |
673 |
> |
actual = read(fh->fd, block, 512); |
674 |
> |
} |
675 |
> |
return actual == 512; |
676 |
|
} else if (fh->is_cdrom) { |
677 |
+ |
#ifdef CDROM_MEDIA_CHANGED |
678 |
+ |
if (fh->cdrom_cap & CDC_MEDIA_CHANGED) { |
679 |
+ |
// If we don't do this, all attempts to read from a disc fail |
680 |
+ |
// once the tray has been opened (altough the TOC reads fine). |
681 |
+ |
// Can somebody explain this to me? |
682 |
+ |
if (ioctl(fh->fd, CDROM_MEDIA_CHANGED) == 1) { |
683 |
+ |
close(fh->fd); |
684 |
+ |
fh->fd = open(fh->name, O_RDONLY | O_NONBLOCK); |
685 |
+ |
} |
686 |
+ |
} |
687 |
+ |
#endif |
688 |
|
#ifdef CDROM_DRIVE_STATUS |
689 |
|
if (fh->cdrom_cap & CDC_DRIVE_STATUS) { |
690 |
|
return ioctl(fh->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) == CDS_DISC_OK; |
692 |
|
#endif |
693 |
|
cdrom_tochdr header; |
694 |
|
return ioctl(fh->fd, CDROMREADTOCHDR, &header) == 0; |
695 |
< |
#elif defined(__FreeBSD__) |
695 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
696 |
|
} else if (fh->is_floppy) { |
697 |
|
return false; //!! |
698 |
|
} else if (fh->is_cdrom) { |
796 |
|
*toc++ = toc_size >> 8; |
797 |
|
*toc++ = toc_size & 0xff; |
798 |
|
return true; |
799 |
+ |
#elif defined(__APPLE__) && defined(__MACH__) && defined(MAC_OS_X_VERSION_10_2) && defined(HAVE_FRAMEWORK_COREFOUNDATION) |
800 |
+ |
extern bool DarwinCDReadTOC(char *name, uint8 *toc); |
801 |
+ |
|
802 |
+ |
return DarwinCDReadTOC(fh->name, toc); |
803 |
|
#elif defined(__FreeBSD__) |
804 |
|
uint8 *p = toc + 2; |
805 |
|
|
846 |
|
*toc++ = toc_size >> 8; |
847 |
|
*toc++ = toc_size & 0xff; |
848 |
|
return true; |
849 |
+ |
#elif defined(__NetBSD__) |
850 |
+ |
uint8 *p = toc + 2; |
851 |
+ |
|
852 |
+ |
// Header |
853 |
+ |
struct ioc_toc_header header; |
854 |
+ |
if (ioctl(fh->fd, CDIOREADTOCHEADER, &header) < 0) |
855 |
+ |
return false; |
856 |
+ |
*p++ = header.starting_track; |
857 |
+ |
*p++ = header.ending_track; |
858 |
+ |
|
859 |
+ |
// Tracks (this is nice... :-) |
860 |
+ |
struct ioc_read_toc_entry entries; |
861 |
+ |
entries.address_format = CD_MSF_FORMAT; |
862 |
+ |
entries.starting_track = 1; |
863 |
+ |
entries.data_len = 800; |
864 |
+ |
entries.data = (cd_toc_entry *)p; |
865 |
+ |
if (ioctl(fh->fd, CDIOREADTOCENTRIES, &entries) < 0) |
866 |
+ |
return false; |
867 |
+ |
|
868 |
+ |
// TOC size |
869 |
+ |
int toc_size = p - toc; |
870 |
+ |
*toc++ = toc_size >> 8; |
871 |
+ |
*toc++ = toc_size & 0xff; |
872 |
+ |
return true; |
873 |
+ |
#else |
874 |
+ |
return false; |
875 |
|
#endif |
876 |
|
} else |
877 |
|
return false; |
911 |
|
*pos++ = chan.cdsc_reladdr.msf.second; |
912 |
|
*pos++ = chan.cdsc_reladdr.msf.frame; |
913 |
|
return true; |
914 |
< |
#elif defined(__FreeBSD__) |
914 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
915 |
|
struct ioc_read_subchannel chan; |
916 |
|
chan.data_format = CD_MSF_FORMAT; |
917 |
|
chan.address_format = CD_MSF_FORMAT; |
935 |
|
*pos++ = chan.data->what.position.reladdr.msf.second; |
936 |
|
*pos++ = chan.data->what.position.reladdr.msf.frame; |
937 |
|
return true; |
938 |
+ |
#else |
939 |
+ |
return false; |
940 |
|
#endif |
941 |
|
} else |
942 |
|
return false; |
963 |
|
play.cdmsf_sec1 = end_s; |
964 |
|
play.cdmsf_frame1 = end_f; |
965 |
|
return ioctl(fh->fd, CDROMPLAYMSF, &play) == 0; |
966 |
< |
#elif defined(__FreeBSD__) |
966 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
967 |
|
struct ioc_play_msf play; |
968 |
|
play.start_m = start_m; |
969 |
|
play.start_s = start_s; |
972 |
|
play.end_s = end_s; |
973 |
|
play.end_f = end_f; |
974 |
|
return ioctl(fh->fd, CDIOCPLAYMSF, &play) == 0; |
975 |
+ |
#else |
976 |
+ |
return false; |
977 |
|
#endif |
978 |
|
} else |
979 |
|
return false; |
993 |
|
if (fh->is_cdrom) { |
994 |
|
#if defined(__linux__) |
995 |
|
return ioctl(fh->fd, CDROMPAUSE) == 0; |
996 |
< |
#elif defined(__FreeBSD__) |
996 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
997 |
|
return ioctl(fh->fd, CDIOCPAUSE) == 0; |
998 |
+ |
#else |
999 |
+ |
return false; |
1000 |
|
#endif |
1001 |
|
} else |
1002 |
|
return false; |
1016 |
|
if (fh->is_cdrom) { |
1017 |
|
#if defined(__linux__) |
1018 |
|
return ioctl(fh->fd, CDROMRESUME) == 0; |
1019 |
< |
#elif defined(__FreeBSD__) |
1019 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
1020 |
|
return ioctl(fh->fd, CDIOCRESUME) == 0; |
1021 |
+ |
#else |
1022 |
+ |
return false; |
1023 |
|
#endif |
1024 |
|
} else |
1025 |
|
return false; |
1039 |
|
if (fh->is_cdrom) { |
1040 |
|
#if defined(__linux__) |
1041 |
|
return ioctl(fh->fd, CDROMSTOP) == 0; |
1042 |
< |
#elif defined(__FreeBSD__) |
1042 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
1043 |
|
return ioctl(fh->fd, CDIOCSTOP) == 0; |
1044 |
+ |
#else |
1045 |
+ |
return false; |
1046 |
|
#endif |
1047 |
|
} else |
1048 |
|
return false; |
1080 |
|
vol.channel0 = vol.channel2 = left; |
1081 |
|
vol.channel1 = vol.channel3 = right; |
1082 |
|
ioctl(fh->fd, CDROMVOLCTRL, &vol); |
1083 |
< |
#elif defined(__FreeBSD__) |
1083 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
1084 |
|
struct ioc_vol vol; |
1085 |
|
vol.vol[0] = vol.vol[2] = left; |
1086 |
|
vol.vol[1] = vol.vol[3] = right; |
1107 |
|
ioctl(fh->fd, CDROMVOLREAD, &vol); |
1108 |
|
left = vol.channel0; |
1109 |
|
right = vol.channel1; |
1110 |
< |
#elif defined(__FreeBSD__) |
1110 |
> |
#elif defined(__FreeBSD__) || defined(__NetBSD__) |
1111 |
|
struct ioc_vol vol; |
1112 |
|
ioctl(fh->fd, CDIOCGETVOL, &vol); |
1113 |
|
left = vol.vol[0]; |