"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "offset.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.

offset.c  (mtools-4.0.35.tar.bz2):offset.c  (mtools-4.0.36.tar.bz2)
skipping to change at line 26 skipping to change at line 26
* *
* filter to support filesystems stored at an offset into their image * filter to support filesystems stored at an offset into their image
*/ */
#include "sysincludes.h" #include "sysincludes.h"
#include "msdos.h" #include "msdos.h"
#include "mtools.h" #include "mtools.h"
#include "offset.h" #include "offset.h"
typedef struct Offset_t { typedef struct Offset_t {
struct Class_t *Class; struct Stream_t head;
int refs;
struct Stream_t *Next;
struct Stream_t *Buffer;
mt_off_t offset; mt_off_t offset;
} Offset_t; } Offset_t;
static ssize_t offset_read(Stream_t *Stream, char *buf, static ssize_t offset_pread(Stream_t *Stream, char *buf,
mt_off_t start, size_t len) mt_off_t start, size_t len)
{ {
DeclareThis(Offset_t); DeclareThis(Offset_t);
return READS(This->Next, buf, start+This->offset, len); return PREADS(This->head.Next, buf, start+This->offset, len);
} }
static ssize_t offset_write(Stream_t *Stream, char *buf, static ssize_t offset_pwrite(Stream_t *Stream, char *buf,
mt_off_t start, size_t len) mt_off_t start, size_t len)
{ {
DeclareThis(Offset_t); DeclareThis(Offset_t);
return WRITES(This->Next, buf, start+This->offset, len); return PWRITES(This->head.Next, buf, start+This->offset, len);
} }
static Class_t OffsetClass = { static Class_t OffsetClass = {
offset_read, 0,
offset_write, 0,
offset_pread,
offset_pwrite,
0, /* flush */ 0, /* flush */
0, /* free */ 0, /* free */
set_geom_pass_through, /* set_geom */ set_geom_pass_through, /* set_geom */
0, /* get_data */ 0, /* get_data */
0, /* pre-allocate */ 0, /* pre-allocate */
get_dosConvert_pass_through, /* dos convert */ get_dosConvert_pass_through, /* dos convert */
0, /* discard */ 0, /* discard */
}; };
Stream_t *OpenOffset(Stream_t *Next, struct device *dev, off_t offset, Stream_t *OpenOffset(Stream_t *Next, struct device *dev, off_t offset,
char *errmsg, mt_off_t *maxSize) { char *errmsg, mt_off_t *maxSize) {
Offset_t *This; Offset_t *This;
This = New(Offset_t); This = New(Offset_t);
if (!This){ if (!This){
printOom(); printOom();
return 0; return 0;
} }
memset((void*)This, 0, sizeof(Offset_t)); memset((void*)This, 0, sizeof(Offset_t));
This->Class = &OffsetClass; init_head(&This->head, &OffsetClass, Next);
This->refs = 1;
This->Next = Next;
This->offset = offset; This->offset = offset;
if(maxSize) { if(maxSize) {
if(This->offset > *maxSize) { if(This->offset > *maxSize) {
if(errmsg) if(errmsg)
sprintf(errmsg,"init: Big disks not supported"); sprintf(errmsg,"init: Big disks not supported");
goto exit_0; goto exit_0;
} }
*maxSize -= This->offset; *maxSize -= This->offset;
} }
if(adjust_tot_sectors(dev, This->offset, errmsg) < 0) if(adjust_tot_sectors(dev, This->offset, errmsg) < 0)
goto exit_0; goto exit_0;
return (Stream_t *) This; return &This->head;
exit_0: exit_0:
Free(This); Free(This);
return NULL; return NULL;
} }
 End of changes. 8 change blocks. 
16 lines changed or deleted 13 lines changed or added

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