floppyd_io.c (mtools-4.0.35.tar.bz2) | : | floppyd_io.c (mtools-4.0.36.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 48 | skipping to change at line 48 | |||
"Auth success", | "Auth success", | |||
"Auth failed: Packet oversized", | "Auth failed: Packet oversized", | |||
"Auth failed: X-Cookie doesn't match", | "Auth failed: X-Cookie doesn't match", | |||
"Auth failed: Wrong transmission protocol version", | "Auth failed: Wrong transmission protocol version", | |||
"Auth failed: Device locked" | "Auth failed: Device locked" | |||
"Auth failed: Bad packet", | "Auth failed: Bad packet", | |||
"Auth failed: I/O Error" | "Auth failed: I/O Error" | |||
}; | }; | |||
typedef struct RemoteFile_t { | typedef struct RemoteFile_t { | |||
Class_t *Class; | struct Stream_t head; | |||
int refs; | ||||
Stream_t *Next; | ||||
Stream_t *Buffer; | ||||
int fd; | int fd; | |||
mt_off_t offset; | mt_off_t offset; | |||
mt_off_t lastwhere; | mt_off_t lastwhere; | |||
mt_off_t size; | mt_off_t size; | |||
unsigned int version; | unsigned int version; | |||
unsigned int capabilities; | unsigned int capabilities; | |||
int drive; | int drive; | |||
} RemoteFile_t; | } RemoteFile_t; | |||
#include "byte_dword.h" | #include "byte_dword.h" | |||
skipping to change at line 344 | skipping to change at line 342 | |||
(len > INT32_MAX) ? (uint32_t)INT32_MAX+1 : (uint32_t) len); | (len > INT32_MAX) ? (uint32_t)INT32_MAX+1 : (uint32_t) len); | |||
if ( ret == -1 ){ | if ( ret == -1 ){ | |||
perror("floppyd_io"); | perror("floppyd_io"); | |||
This->lastwhere = -1; | This->lastwhere = -1; | |||
return -1; | return -1; | |||
} | } | |||
This->lastwhere = where + ret; | This->lastwhere = where + ret; | |||
return ret; | return ret; | |||
} | } | |||
static ssize_t floppyd_read(Stream_t *Stream, char *buf, | static ssize_t floppyd_pread(Stream_t *Stream, char *buf, | |||
mt_off_t where, size_t len) | mt_off_t where, size_t len) | |||
{ | { | |||
return floppyd_io(Stream, buf, where, len, floppyd_reader); | return floppyd_io(Stream, buf, where, len, floppyd_reader); | |||
} | } | |||
static ssize_t floppyd_write(Stream_t *Stream, char *buf, | static ssize_t floppyd_pwrite(Stream_t *Stream, char *buf, | |||
mt_off_t where, size_t len) | mt_off_t where, size_t len) | |||
{ | { | |||
return floppyd_io(Stream, buf, where, len, floppyd_writer); | return floppyd_io(Stream, buf, where, len, floppyd_writer); | |||
} | } | |||
static int floppyd_flush(Stream_t *Stream) | static int floppyd_flush(Stream_t *Stream) | |||
{ | { | |||
Byte buf[16]; | Byte buf[16]; | |||
DeclareThis(RemoteFile_t); | DeclareThis(RemoteFile_t); | |||
skipping to change at line 431 | skipping to change at line 429 | |||
if(type) | if(type) | |||
*type = 0; /* not a directory */ | *type = 0; /* not a directory */ | |||
if(address) | if(address) | |||
*address = 0; | *address = 0; | |||
return 0; | return 0; | |||
} | } | |||
/* ######################################################################## */ | /* ######################################################################## */ | |||
static Class_t FloppydFileClass = { | static Class_t FloppydFileClass = { | |||
floppyd_read, | 0, | |||
floppyd_write, | 0, | |||
floppyd_pread, | ||||
floppyd_pwrite, | ||||
floppyd_flush, | floppyd_flush, | |||
floppyd_free, | floppyd_free, | |||
set_geom_noop, | set_geom_noop, | |||
floppyd_data, | floppyd_data, | |||
0, /* pre_allocate */ | 0, /* pre_allocate */ | |||
0, /* get_dosConvert */ | 0, /* get_dosConvert */ | |||
0 /* discard */ | 0 /* discard */ | |||
}; | }; | |||
/* ######################################################################## */ | /* ######################################################################## */ | |||
skipping to change at line 571 | skipping to change at line 571 | |||
RemoteFile_t *This; | RemoteFile_t *This; | |||
if (!dev || !(dev->misc_flags & FLOPPYD_FLAG)) | if (!dev || !(dev->misc_flags & FLOPPYD_FLAG)) | |||
return NULL; | return NULL; | |||
This = New(RemoteFile_t); | This = New(RemoteFile_t); | |||
if (!This){ | if (!This){ | |||
printOom(); | printOom(); | |||
return NULL; | return NULL; | |||
} | } | |||
This->Class = &FloppydFileClass; | init_head(&This->head, &FloppydFileClass, NULL); | |||
This->Next = 0; | ||||
This->offset = 0; | This->offset = 0; | |||
This->lastwhere = 0; | This->lastwhere = 0; | |||
This->refs = 1; | ||||
This->Buffer = 0; | ||||
This->fd = ConnectToFloppyd(This, name, errmsg); | This->fd = ConnectToFloppyd(This, name, errmsg); | |||
if (This->fd == -1) { | if (This->fd == -1) { | |||
Free(This); | Free(This); | |||
return NULL; | return NULL; | |||
} | } | |||
if(floppyd_open(This, mode) < 0) { | if(floppyd_open(This, mode) < 0) { | |||
sprintf(errmsg, | sprintf(errmsg, | |||
"Can't open remote drive: %s", strerror(errno)); | "Can't open remote drive: %s", strerror(errno)); | |||
close(This->fd); | close(This->fd); | |||
Free(This); | Free(This); | |||
return NULL; | return NULL; | |||
} | } | |||
if(maxSize) { | if(maxSize) { | |||
*maxSize = | *maxSize = | |||
((This->capabilities & FLOPPYD_CAP_LARGE_SEEK) ? | ((This->capabilities & FLOPPYD_CAP_LARGE_SEEK) ? | |||
max_off_t_seek : max_off_t_31); | max_off_t_seek : max_off_t_31); | |||
} | } | |||
return (Stream_t *) This; | return &This->head; | |||
} | } | |||
static int ConnectToFloppyd(RemoteFile_t *floppyd, const char* name, | static int ConnectToFloppyd(RemoteFile_t *floppyd, const char* name, | |||
char *errmsg) | char *errmsg) | |||
{ | { | |||
char* hostname; | char* hostname; | |||
char* display; | char* display; | |||
uint16_t port; | uint16_t port; | |||
int rval = get_host_and_port_and_drive(name, &hostname, &display, | int rval = get_host_and_port_and_drive(name, &hostname, &display, | |||
&port, &floppyd->drive); | &port, &floppyd->drive); | |||
End of changes. 7 change blocks. | ||||
15 lines changed or deleted | 13 lines changed or added |