"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "scsi_io.c" between
mtools-4.0.35.tar.bz2 and mtools-4.0.36.tar.bz2

About: Mtools is a collection of utilities to access MS-DOS disks from Unix without mounting them.

scsi_io.c  (mtools-4.0.35.tar.bz2):scsi_io.c  (mtools-4.0.36.tar.bz2)
skipping to change at line 39 skipping to change at line 39
#include "msdos.h" #include "msdos.h"
#include "llong.h" #include "llong.h"
#include "open_image.h" #include "open_image.h"
#include "scsi.h" #include "scsi.h"
#include "plain_io.h" #include "plain_io.h"
#include "scsi_io.h" #include "scsi_io.h"
typedef struct ScsiDevice_t { typedef struct ScsiDevice_t {
Class_t *Class; struct Stream_t head;
int refs;
Stream_t *Next;
Stream_t *Buffer;
int fd; int fd;
int privileged; int privileged;
uint32_t scsi_sector_size; uint32_t scsi_sector_size;
mt_off_t device_size; mt_off_t device_size;
uint32_t tot_sectors; uint32_t tot_sectors;
void *extra_data; /* extra system dependent information for scsi. void *extra_data; /* extra system dependent information for scsi.
On some platforms, filled in by scsi_open, and to On some platforms, filled in by scsi_open, and to
be supplied to scsi_cmd */ be supplied to scsi_cmd */
skipping to change at line 233 skipping to change at line 230
#ifdef JPD #ifdef JPD
printf("zip: read or write OK\n"); printf("zip: read or write OK\n");
#endif #endif
if (offset>0) if (offset>0)
memmove(buf,buf+offset, nsect*This->scsi_sector_size-offset); memmove(buf,buf+offset, nsect*This->scsi_sector_size-offset);
if (len==256) return 256; if (len==256) return 256;
else if (len==512) return 512; else if (len==512) return 512;
else return (ssize_t)(nsect*This->scsi_sector_size-offset); else return (ssize_t)(nsect*This->scsi_sector_size-offset);
} }
static ssize_t scsi_read(Stream_t *Stream, char *buf, mt_off_t where, size_t len static ssize_t scsi_pread(Stream_t *Stream, char *buf,
) mt_off_t where, size_t len)
{ {
#ifdef JPD #ifdef JPD
printf("zip: to read %d bytes at %d\n", len, where); printf("zip: to read %d bytes at %d\n", len, where);
#endif #endif
return scsi_io(Stream, buf, where, len, SCSI_IO_READ); return scsi_io(Stream, buf, where, len, SCSI_IO_READ);
} }
static ssize_t scsi_write(Stream_t *Stream, char *buf, static ssize_t scsi_pwrite(Stream_t *Stream, char *buf,
mt_off_t where, size_t len) mt_off_t where, size_t len)
{ {
#ifdef JPD #ifdef JPD
Printf("zip: to write %d bytes at %d\n", len, where); Printf("zip: to write %d bytes at %d\n", len, where);
#endif #endif
return scsi_io(Stream, buf, where, len, SCSI_IO_WRITE); return scsi_io(Stream, buf, where, len, SCSI_IO_WRITE);
} }
static int scsi_get_data(Stream_t *Stream, time_t *date, mt_off_t *size, static int scsi_get_data(Stream_t *Stream, time_t *date, mt_off_t *size,
int *type, uint32_t *address) int *type, uint32_t *address)
{ {
DeclareThis(ScsiDevice_t); DeclareThis(ScsiDevice_t);
if(date || type || address) if(date || type || address)
fprintf(stderr, "Get_data call not supported\n"); fprintf(stderr, "Get_data call not supported\n");
if(size) if(size)
*size = This->device_size; *size = This->device_size;
return 0; return 0;
} }
static Class_t ScsiDeviceClass = { static Class_t ScsiDeviceClass = {
scsi_read, 0,
scsi_write, 0,
scsi_pread,
scsi_pwrite,
0, 0,
0, 0,
set_geom_noop, set_geom_noop,
scsi_get_data, /* get_data */ scsi_get_data, /* get_data */
0, /* pre-allocate */ 0, /* pre-allocate */
0, /* dos-convert */ 0, /* dos-convert */
0 /* discard */ 0 /* discard */
}; };
Stream_t *OpenScsi(struct device *dev, Stream_t *OpenScsi(struct device *dev,
skipping to change at line 290 skipping to change at line 290
ScsiDevice_t *This; ScsiDevice_t *This;
if (!IS_SCSI(dev)) if (!IS_SCSI(dev))
return NULL; return NULL;
This = New(ScsiDevice_t); This = New(ScsiDevice_t);
if (!This){ if (!This){
printOom(); printOom();
return 0; return 0;
} }
memset((void*)This, 0, sizeof(ScsiDevice_t)); memset((void*)This, 0, sizeof(ScsiDevice_t));
init_head(&This->head, &ScsiDeviceClass, NULL);
This->scsi_sector_size = 512; This->scsi_sector_size = 512;
This->Class = &ScsiDeviceClass;
if(dev) { if(dev) {
if(!(mode2 & NO_PRIV)) if(!(mode2 & NO_PRIV))
This->privileged = IS_PRIVILEGED(dev); This->privileged = IS_PRIVILEGED(dev);
mode |= dev->mode; mode |= dev->mode;
} }
precmd(dev); precmd(dev);
if(IS_PRIVILEGED(dev) && !(mode2 & NO_PRIV)) if(IS_PRIVILEGED(dev) && !(mode2 & NO_PRIV))
reclaim_privs(); reclaim_privs();
skipping to change at line 329 skipping to change at line 329
#endif #endif
} }
goto exit_1; goto exit_1;
} }
if(IS_PRIVILEGED(dev) && !(mode2 & NO_PRIV)) if(IS_PRIVILEGED(dev) && !(mode2 & NO_PRIV))
closeExec(This->fd); closeExec(This->fd);
if(LockDevice(This->fd, dev, locked, lockMode, errmsg) < 0) if(LockDevice(This->fd, dev, locked, lockMode, errmsg) < 0)
goto exit_0; goto exit_0;
This->refs = 1;
This->Next = 0;
This->Buffer = 0;
if(maxSize) if(maxSize)
*maxSize = MAX_OFF_T_B(31+log_2(This->scsi_sector_size)); *maxSize = MAX_OFF_T_B(31+log_2(This->scsi_sector_size));
This->Class = &ScsiDeviceClass;
if(This->privileged) if(This->privileged)
reclaim_privs(); reclaim_privs();
ret=scsi_init(This); ret=scsi_init(This);
if(This->privileged) if(This->privileged)
drop_privs(); drop_privs();
if(ret < 0) if(ret < 0)
goto exit_0; goto exit_0;
dev->tot_sectors = This->tot_sectors; dev->tot_sectors = This->tot_sectors;
return (Stream_t *) This; return &This->head;
exit_0: exit_0:
close(This->fd); close(This->fd);
exit_1: exit_1:
Free(This); Free(This);
return NULL; return NULL;
} }
 End of changes. 9 change blocks. 
16 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)