40
40
unsigned device_no;
42
/* Use the _llseek system call directly, because there (once?) was a bug in
43
* the glibc implementation of it. */
44
#include <linux/unistd.h>
45
#if defined(__alpha) || defined (__ia64__)
46
/* On alpha, the syscall is simply lseek, because it's a 64 bit system. */
47
static loff_t llseek( int fd, loff_t offset, int whence )
49
return lseek(fd, offset, whence);
53
# error _llseek system call not present
55
static _syscall5( int, _llseek, uint, fd, ulong, hi, ulong, lo,
56
loff_t *, res, uint, wh );
58
static loff_t llseek( int fd, loff_t offset, int whence )
62
if (_llseek(fd, offset>>32, offset&0xffffffff, &actual, whence) != 0)
44
#include "volume.h" /* DOS lowlevel disk access functions */
46
static loff_t llseek( int fd, loff_t offset, int whence )
48
if ((whence != SEEK_SET) || (fd == 4711)) return -1; /* only those supported */
49
return VolumeSeek(offset);
51
#define open OpenVolume
52
#define close CloseVolume
53
#define read(a,b,c) ReadVolume(b,c)
54
#define write(a,b,c) WriteVolume(b,c)
69
57
void fs_open(char *path,int rw)
75
63
changes = last = NULL;
78
67
if (fstat(fd,&stbuf) < 0)
68
pdie("fstat %s",path);
80
69
device_no = S_ISBLK(stbuf.st_mode) ? (stbuf.st_rdev >> 8) & 0xff : 0;
71
if (IsWorkingOnImageFile()) {
72
if (fstat(GetVolumeHandle(),&stbuf) < 0)
73
pdie("fstat image %s",path);
77
/* return 2 for floppy, 1 for ramdisk, 7 for loopback */
78
/* used by boot.c in Atari mode: floppy always FAT12, */
79
/* loopback / ramdisk only FAT12 if usual floppy size, */
80
/* harddisk always FAT16 on Atari... */
81
device_no = (GetVolumeHandle() < 2) ? 2 : 1;
82
/* telling "floppy" for A:/B:, "ramdisk" for the rest */
146
150
changes = changes->next;
147
151
if (llseek(fd,this->pos,0) != this->pos)
148
152
fprintf(stderr,"Seek to %lld failed: %s\n Did not write %d bytes.\n",
149
this->pos,strerror(errno),this->size);
153
(long long)this->pos,strerror(errno),this->size);
150
154
else if ((size = write(fd,this->data,this->size)) < 0)
151
155
fprintf(stderr,"Writing %d bytes at %lld failed: %s\n",this->size,
152
this->pos,strerror(errno));
156
(long long)this->pos,strerror(errno));
153
157
else if (size != this->size)
154
158
fprintf(stderr,"Wrote %d bytes instead of %d bytes at %lld."
155
"\n",size,this->size,this->pos);
159
"\n",size,this->size,(long long)this->pos);
156
160
free(this->data);