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