1 |
|
/* |
2 |
|
* sys_unix.cpp - System dependent routines, Unix implementation |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2000 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2002 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 |
33 |
|
#include <linux/unistd.h> |
34 |
|
|
35 |
|
#ifdef __NR__llseek |
36 |
< |
_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, loff_t *, res, uint, wh); |
36 |
> |
_syscall5(int, _llseek, unsigned int, fd, unsigned long, hi, unsigned long, lo, loff_t *, res, unsigned int, wh); |
37 |
|
#else |
38 |
< |
static int _llseek(uint fd, ulong hi, ulong lo, loff_t *res, uint wh) |
38 |
> |
static int _llseek(unsigned int fd, unsigned long hi, unsigned long lo, loff_t *res, unsigned int wh) |
39 |
|
{ |
40 |
|
if (hi) |
41 |
|
return -1; |
120 |
|
void SysAddFloppyPrefs(void) |
121 |
|
{ |
122 |
|
#if defined(__linux__) |
123 |
< |
PrefsAddString("floppy", "/dev/fd0H1440"); |
124 |
< |
PrefsAddString("floppy", "/dev/fd1H1440"); |
123 |
> |
PrefsAddString("floppy", "/dev/fd0u1440"); |
124 |
> |
PrefsAddString("floppy", "/dev/fd1u1440"); |
125 |
|
#elif defined(__NetBSD__) |
126 |
|
PrefsAddString("floppy", "/dev/fd0a"); |
127 |
|
PrefsAddString("floppy", "/dev/fd1a"); |
146 |
|
while(fgets(line, 255, f)) { |
147 |
|
// Read line |
148 |
|
int len = strlen(line); |
149 |
< |
if (len == 0) |
149 |
> |
if (len == 0 || line[0] == '#') |
150 |
|
continue; |
151 |
|
line[len-1] = 0; |
152 |
|
|
273 |
|
} |
274 |
|
|
275 |
|
// Open file/device |
276 |
< |
#if defined(__linux__) |
276 |
> |
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) |
277 |
|
int fd = open(name, (read_only ? O_RDONLY : O_RDWR) | (is_cdrom ? O_NONBLOCK : 0)); |
278 |
|
#else |
279 |
|
int fd = open(name, read_only ? O_RDONLY : O_RDWR); |
549 |
|
lseek(fh->fd, 0, SEEK_SET); |
550 |
|
return read(fh->fd, block, 512) == 512; |
551 |
|
} else if (fh->is_cdrom) { |
552 |
+ |
#ifdef CDROM_MEDIA_CHANGED |
553 |
+ |
if (fh->cdrom_cap & CDC_MEDIA_CHANGED) { |
554 |
+ |
// If we don't do this, all attempts to read from a disc fail |
555 |
+ |
// once the tray has been open (altough the TOC reads fine). |
556 |
+ |
// Can somebody explain this to me? |
557 |
+ |
if (ioctl(fh->fd, CDROM_MEDIA_CHANGED) == 1) { |
558 |
+ |
close(fh->fd); |
559 |
+ |
fh->fd = open(fh->name, O_RDONLY | O_NONBLOCK); |
560 |
+ |
} |
561 |
+ |
} |
562 |
+ |
#endif |
563 |
|
#ifdef CDROM_DRIVE_STATUS |
564 |
|
if (fh->cdrom_cap & CDC_DRIVE_STATUS) { |
565 |
|
return ioctl(fh->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) == CDS_DISC_OK; |