Initial fixes and corrections. Fix ExAll behaviour so that it doesn't only operate on a single data entry, with the same filesystem object, for 4GB worth of data (or forever..) ...

This commit is contained in:
Kalamatee 2023-05-02 13:15:45 +01:00 committed by deadwood
parent 6d32ebffcc
commit a90e0750f7
3 changed files with 69 additions and 69 deletions

View File

@ -83,7 +83,7 @@ LONG markspace(BLCK block,ULONG blocks) {
_XDEBUG((DEBUG_BITMAP,"markspace: Marking %ld blocks from block %ld\n",blocks,block));
if((availablespace(block, blocks))<blocks) {
if(((ULONG)availablespace(block, blocks))<blocks) {
req_unusual("Attempted to mark %ld blocks from block %ld,\n but some of them were already full.", blocks, block);
return(-1);
}
@ -248,13 +248,13 @@ LONG availablespace(BLCK block,ULONG maxneeded) {
while(nextblock<maxbitmapblock && (errorcode=readcachebuffercheck(&cb,nextblock++,BITMAP_ID))==0) {
b=cb->data;
if((bitend=bmffz(b->bitmap,longs,bitstart))<(32*longs)) {
if((bitend=bmffz(b->bitmap,longs,bitstart))< ((LONG)(32*longs))) {
blocksfound+=bitend-bitstart;
return(blocksfound);
}
blocksfound+=globals->blocks_inbitmap-bitstart;
if(blocksfound>=maxneeded) {
if((ULONG)blocksfound>=maxneeded) {
return(blocksfound);
}
@ -292,13 +292,13 @@ LONG allocatedspace(BLCK block,ULONG maxneeded) {
while(nextblock<maxbitmapblock && (errorcode=readcachebuffercheck(&cb,nextblock++,BITMAP_ID))==0) {
b=cb->data;
if((bitend=bmffo(b->bitmap,longs,bitstart))<(32*longs)) {
if((bitend=bmffo(b->bitmap,longs,bitstart))<((LONG)(32*longs))) {
blocksfound+=bitend-bitstart;
return(blocksfound);
}
blocksfound+=globals->blocks_inbitmap-bitstart;
if(blocksfound>=maxneeded) {
if((ULONG)blocksfound>=maxneeded) {
return(blocksfound);
}
@ -386,11 +386,11 @@ LONG findspace2(ULONG maxneeded, BLCK start, BLCK end, BLCK *returned_block, ULO
free blocks at the start of this bitmap block, space will
be set to zero, since in that case the space isn't adjacent. */
while((bitstart=bmffo(b->bitmap, longs, bitend))<globals->blocks_inbitmap) {
while((bitstart=bmffo(b->bitmap, longs, bitend)) < (LONG)globals->blocks_inbitmap) {
/* found the start of an empty space, now find out how large it is */
if(bitstart >= localbreakpoint) { // Oct 3 1999: Check if the start of this empty space is within bounds.
if((ULONG)bitstart >= localbreakpoint) { // Oct 3 1999: Check if the start of this empty space is within bounds.
break;
}
@ -400,7 +400,7 @@ LONG findspace2(ULONG maxneeded, BLCK start, BLCK end, BLCK *returned_block, ULO
bitend=bmffz(b->bitmap, longs, bitstart);
if(bitend > localbreakpoint) {
if((ULONG)bitend > localbreakpoint) {
bitend=localbreakpoint;
}
@ -415,7 +415,7 @@ LONG findspace2(ULONG maxneeded, BLCK start, BLCK end, BLCK *returned_block, ULO
*returned_blocks=space;
}
if(bitend>=localbreakpoint) {
if((ULONG)bitend>=localbreakpoint) {
break;
}
}
@ -426,7 +426,7 @@ LONG findspace2(ULONG maxneeded, BLCK start, BLCK end, BLCK *returned_block, ULO
/* no (more) empty spaces found in this block */
if(bitend!=globals->blocks_inbitmap) {
if((ULONG)bitend!=globals->blocks_inbitmap) {
space=0;
}
@ -560,7 +560,7 @@ LONG smartfindandmarkspace(BLCK startblock,ULONG blocksneeded) {
_XDEBUG((DEBUG_BITMAP,"sfams: availablespace returned %ld for block %ld while we needed %ld blocks\n",freeblocks,block,blocksneeded));
if(freeblocks>0) {
if(freeblocks>=blocksneeded) {
if((ULONG)freeblocks>=blocksneeded) {
entry=0;
globals->spacelist[entry].block=block;
globals->spacelist[entry++].blocks=freeblocks;
@ -743,7 +743,7 @@ LONG findspace2_backwards(ULONG maxneeded, BLCK start, BLCK end, BLCK *returned_
struct fsBitmap *b=cb->data;
LONG localbreakpoint=breakpoint-block;
if(localbreakpoint<0 || localbreakpoint>=globals->blocks_inbitmap) {
if(localbreakpoint<0 || (ULONG)localbreakpoint>=globals->blocks_inbitmap) {
localbreakpoint=0;
}
@ -755,7 +755,7 @@ LONG findspace2_backwards(ULONG maxneeded, BLCK start, BLCK end, BLCK *returned_
break;
}
if(bitend!=globals->blocks_inbitmap-1) {
if((ULONG)bitend!=globals->blocks_inbitmap-1) {
space=0;
}

View File

@ -57,13 +57,13 @@ void removebnode(ULONG key,struct BTreeContainer *btc);
static void __inline copywordsforward(UWORD *src,UWORD *dst,UWORD len) {
__inline static void copywordsforward(UWORD *src,UWORD *dst,UWORD len) {
while(len-->0) {
*dst++=*src++;
}
}
static void __inline copywordsbackward(UWORD *src,UWORD *dst,UWORD len) {
__inline static void copywordsbackward(UWORD *src,UWORD *dst,UWORD len) {
while(len-->0) {
*--dst=*--src;
}

View File

@ -108,7 +108,7 @@ struct SFSBase *globals=NULL;
static struct DosPacket *getpacket(struct Process *);
static struct DosPacket *waitpacket(struct Process *);
static void returnpacket(SIPTR,LONG);
static void returnpacket(SIPTR,SIPTR);
static void sdlhtask(void);
/* Prototypes of cachebuffer related functions */
@ -490,21 +490,21 @@ static void sfsCopyBSTRSafe(BSTR src, char *dst, ULONG len)
}
static int sfsExamineAll(struct ExAllControl *eac,
struct ExAllData *ead,
struct ExAllData **ead,
struct ExAllData **prevead,
struct CacheBuffer *cb,
struct fsObject *o,
struct fsObject **o,
char *oname,
ULONG *eadsize,
ULONG *stringsize,
LONG *spaceleft,
LONG *errorcode)
{
WORD namelength=strlen(oname);
WORD namelength = strlen(oname);
WORD keepentry;
*stringsize=0;
*eadsize=0;
*stringsize = 0;
*eadsize = 0;
switch(globals->packet->dp_Arg4) {
default:
@ -512,7 +512,7 @@ static int sfsExamineAll(struct ExAllControl *eac,
*eadsize += 4; /* ed_OwnedGID, ed_OwnedUID */
// fall through
case ED_COMMENT:
*stringsize += strlen(oname + namelength + 1) + 1;
*stringsize += strlen((char *)((IPTR)oname + namelength + 1)) + 1;
*eadsize += sizeof(UBYTE *); /* ed_Comment */
// fall through
case ED_DATE:
@ -542,15 +542,15 @@ static int sfsExamineAll(struct ExAllControl *eac,
switch(globals->packet->dp_Arg4) {
default:
case ED_OWNER:
ead->ed_OwnerUID=BE2W(o->be_owneruid);
ead->ed_OwnerGID=BE2W(o->be_ownergid);
(*ead)->ed_OwnerUID=BE2W((*o)->be_owneruid);
(*ead)->ed_OwnerGID=BE2W((*o)->be_ownergid);
// fall through
case ED_COMMENT:
{
UBYTE *src=oname+namelength+1;
UBYTE *dest=(UBYTE *)ead+*eadsize;
UBYTE *src=(UBYTE *)((IPTR)oname + namelength + 1);
UBYTE *dest=(UBYTE *)((IPTR)*ead + *eadsize);
ead->ed_Comment=dest;
(*ead)->ed_Comment=dest;
while(*src!=0) {
*dest++=*src++;
@ -562,38 +562,38 @@ static int sfsExamineAll(struct ExAllControl *eac,
}
// fall through
case ED_DATE:
datetodatestamp(BE2L(o->be_datemodified),(struct DateStamp *)&ead->ed_Days);
datetodatestamp(BE2L((*o)->be_datemodified),(struct DateStamp *)&(*ead)->ed_Days);
// fall through
case ED_PROTECTION:
ead->ed_Prot=BE2L(o->be_protection)^(FIBF_READ|FIBF_WRITE|FIBF_EXECUTE|FIBF_DELETE);
(*ead)->ed_Prot=BE2L((*o)->be_protection)^(FIBF_READ|FIBF_WRITE|FIBF_EXECUTE|FIBF_DELETE);
// fall through
case ED_SIZE:
if((o->bits & OTYPE_DIR)==0) {
ead->ed_Size=BE2L(o->object.file.be_size);
if(((*o)->bits & OTYPE_DIR)==0) {
(*ead)->ed_Size=BE2L((*o)->object.file.be_size);
} else {
ead->ed_Size=0;
(*ead)->ed_Size=0;
}
// fall through
case ED_TYPE:
_DEBUG(("examine ED_TYPE, o->bits=%x, o->objectnode=%d\n", o->bits, BE2L(o->be_objectnode)));
if((o->bits & OTYPE_LINK)!=0) {
ead->ed_Type = ST_SOFTLINK;
_DEBUG(("examine ED_TYPE, o->bits=%x, o->objectnode=%d\n", (*o)->bits, BE2L((*o)->be_objectnode)));
if(((*o)->bits & OTYPE_LINK)!=0) {
(*ead)->ed_Type = ST_SOFTLINK;
}
if((o->bits & OTYPE_DIR)==0) {
ead->ed_Type = ST_FILE;
if(((*o)->bits & OTYPE_DIR)==0) {
(*ead)->ed_Type = ST_FILE;
}
else if (o->be_objectnode == L2BE(ROOTNODE)) {
ead->ed_Type = ST_ROOT;
else if ((*o)->be_objectnode == L2BE(ROOTNODE)) {
(*ead)->ed_Type = ST_ROOT;
} else {
ead->ed_Type = ST_USERDIR;
(*ead)->ed_Type = ST_USERDIR;
}
// fall through
case ED_NAME:
{
UBYTE *src = oname;
UBYTE *dest = (UBYTE *)ead+*eadsize;
UBYTE *dest = (UBYTE *)((IPTR)*ead + *eadsize);
ead->ed_Name=dest;
(*ead)->ed_Name = dest;
while(*src!=0) {
*dest++=*src++;
@ -602,33 +602,33 @@ static int sfsExamineAll(struct ExAllControl *eac,
*dest=0;
*eadsize += 1;
// _DEBUG(("Stored entry %s\n",ead->ed_Name));
// _DEBUG(("Stored entry %s\n",(*ead)->ed_Name));
}
}
if(eac->eac_MatchString!=0) {
keepentry=MatchPatternNoCase(eac->eac_MatchString,ead->ed_Name);
if(eac->eac_MatchString != NULL) {
keepentry=MatchPatternNoCase(eac->eac_MatchString,(*ead)->ed_Name);
} else {
keepentry=DOSTRUE;
}
if(keepentry!=DOSFALSE && eac->eac_MatchFunc!=0) {
if(keepentry == DOSTRUE && eac->eac_MatchFunc != NULL) {
#ifdef __AROS__
keepentry=CALLHOOKPKT(eac->eac_MatchFunc, (APTR)globals->packet->dp_Arg4, ead);
keepentry=CALLHOOKPKT(eac->eac_MatchFunc, (APTR)globals->packet->dp_Arg4, *ead);
#else
LONG __asm(*hookfunc)(register __a0 struct Hook *,register __a1 struct ExAllData *,register __a2 ULONG)=(LONG __asm(*)(register __a0 struct Hook *,register __a1 struct ExAllData *,register __a2 ULONG))eac->eac_MatchFunc->h_Entry;
keepentry=hookfunc(eac->eac_MatchFunc,ead,packet->dp_Arg4);
keepentry=hookfunc(eac->eac_MatchFunc, *ead,packet->dp_Arg4);
#endif
}
if(keepentry!=DOSFALSE && (o->bits & OTYPE_HIDDEN)==0) {
ead->ed_Next = 0;
if(keepentry == DOSTRUE && ((*o)->bits & OTYPE_HIDDEN)==0) {
(*ead)->ed_Next = 0;
*eadsize = (*eadsize + sizeof(APTR) - 1) & ~(sizeof(APTR) - 1);
if(*prevead != 0) {
(*prevead)->ed_Next=ead;
if(*prevead != NULL) {
(*prevead)->ed_Next = *ead;
}
*prevead = ead;
ead = (struct ExAllData *)((UBYTE *)ead+*eadsize);
*prevead = *ead;
*ead = (struct ExAllData *)((IPTR)*ead + *eadsize);
*spaceleft -= *eadsize;
eac->eac_Entries++;
}
@ -637,17 +637,17 @@ static int sfsExamineAll(struct ExAllControl *eac,
struct fsObjectContainer *oc=cb->data;
UBYTE *endadr;
o=nextobject(o);
*o = nextobject(*o);
endadr=(UBYTE *)oc+globals->bytes_block-sizeof(struct fsObject)-2;
endadr=(UBYTE *)((IPTR)oc + globals->bytes_block - sizeof(struct fsObject) - 2);
if((UBYTE *)o>=endadr || oname[0]==0) {
if((UBYTE *)*o >= endadr || oname[0]==0) {
if(oc->be_next!=0) {
if((*errorcode=readcachebuffercheck(&cb,BE2L(oc->be_next),OBJECTCONTAINER_ID))==0) {
struct fsObjectContainer *oc=cb->data;
if((*errorcode = readcachebuffercheck(&cb, BE2L(oc->be_next), OBJECTCONTAINER_ID))==0) {
struct fsObjectContainer *oc = cb->data;
o=oc->object;
eac->eac_LastKey=BE2L(o->be_objectnode);
*o = oc->object;
eac->eac_LastKey= 0 + BE2L((*o)->be_objectnode);
}
}
else {
@ -655,7 +655,7 @@ static int sfsExamineAll(struct ExAllControl *eac,
}
}
else {
eac->eac_LastKey=BE2L(o->be_objectnode);
eac->eac_LastKey= 0 + BE2L((*o)->be_objectnode);
}
}
return 1;
@ -2155,7 +2155,7 @@ void mainloop(void) {
{
struct ExtFileLock *lock;
struct ExAllData *ead;
struct ExAllData *prevead=0;
struct ExAllData *prevead = NULL;
struct ExAllControl *eac;
struct CacheBuffer *cb;
struct fsObject *o;
@ -2167,7 +2167,7 @@ void mainloop(void) {
lock=(struct ExtFileLock *)BADDR(globals->packet->dp_Arg1);
ead=(struct ExAllData *)globals->packet->dp_Arg2;
eac=(struct ExAllControl *)globals->packet->dp_Arg5;
spaceleft=globals->packet->dp_Arg3;
spaceleft=(LONG)globals->packet->dp_Arg3;
eac->eac_Entries=0;
@ -2184,8 +2184,8 @@ void mainloop(void) {
}
if(eac->eac_LastKey==0) {
if((errorcode=readobject(lock->objectnode,&cb,&o))==0) {
if((o->bits & OTYPE_DIR)!=0) {
if(o->object.dir.be_firstdirblock!=0) {
if((o->bits & OTYPE_DIR) != 0) {
if(o->object.dir.be_firstdirblock != 0) {
if((errorcode=readcachebuffercheck(&cb,BE2L(o->object.dir.be_firstdirblock),OBJECTCONTAINER_ID))==0) {
struct fsObjectContainer *oc=cb->data;
o=oc->object;
@ -2209,7 +2209,7 @@ void mainloop(void) {
}
while(errorcode==0) {
if (!sfsExamineAll(eac, ead, &prevead, cb, o, (char *)&o->name[0], &eadsize, &stringsize, &spaceleft, &errorcode))
if (!sfsExamineAll(eac, &ead, &prevead, cb, &o, (char *)&o->name[0], &eadsize, &stringsize, &spaceleft, &errorcode))
{
break;
}
@ -2985,7 +2985,7 @@ static struct DosPacket *waitpacket(struct Process *p) {
static void returnpacket(SIPTR res1,LONG res2) {
static void returnpacket(SIPTR res1, SIPTR res2) {
struct Message *msg;
struct MsgPort *replyport;
@ -3007,7 +3007,7 @@ static void returnpacket(SIPTR res1,LONG res2) {
static void returnpacket2(struct DosPacket *packet, SIPTR res1, LONG res2)
static void returnpacket2(struct DosPacket *packet, SIPTR res1, SIPTR res2)
{
struct Message *msg;
struct MsgPort *replyport;