Mercurial > sos > sos
changeset 87:480f5685b3c2
Fixed bugs in delete, moved arrayLookup to sarpn
arrayLookup was a specialized function that, though useful, did not belong in
the standard library
delete was not properly determining the location for the end block and also not
actually updating the disk with the re-written table. Both fixed.
author | Jonathan Pevarnek <pevarnj@gmail.com> |
---|---|
date | Wed, 27 Apr 2011 22:49:00 -0400 |
parents | cc10ad44c2c2 |
children | 7962969a9abd |
files | include/std.h src/fs.c src/sarpn.c src/std.c |
diffstat | 4 files changed, 14 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/include/std.h Wed Apr 27 22:11:51 2011 -0400 +++ b/include/std.h Wed Apr 27 22:49:00 2011 -0400 @@ -29,8 +29,6 @@ void strcpy(char *dest, const char *src); int strcmp(const char *a, const char *b); -int arrayLookup(char *text, const char array[][10], int last); - char* append(char *dest, char *src); void* memcpy(void *destination, const void *source, size_t num);
--- a/src/fs.c Wed Apr 27 22:11:51 2011 -0400 +++ b/src/fs.c Wed Apr 27 22:49:00 2011 -0400 @@ -117,16 +117,19 @@ if(!root) return ERR_FSBLKREADFAIL; u32 rootSize = root->size; u32 numDE = rootSize/sizeof(Direntry); + u32 toBlkNo = root->blocks[fileNo/DEPBLK]; //block that the DE used to occupy + u32 endBlkNo = root->blocks[numDE/DEPBLK]; //block for the last DE Direntry *td = readFSBlock(root->blocks[fileNo/DEPBLK]); if(!td) return ERR_FSBLKREADFAIL; td += fileNo%DEPBLK; - Direntry *end = readFSBlock(numDE/DEPBLK); //this will fail if there is only - //space for one item in cache and - //the 2 DEs are in different blks + Direntry *end = readFSBlock(endBlkNo); + //this will fail if there is only space for one item in cache and the 2 DEs + //are in different blocks. There will be no indication of failure if(!end) return ERR_FSBLKREADFAIL; end += numDE%DEPBLK; *td = *end; if(isError(err = setFileSize(rootLoc, rootSize - sizeof(Direntry)))) return err; + if(isError(err = sync(toBlkNo))) return err; //end does not need to be synchronized return 0; }
--- a/src/sarpn.c Wed Apr 27 22:11:51 2011 -0400 +++ b/src/sarpn.c Wed Apr 27 22:49:00 2011 -0400 @@ -6,6 +6,14 @@ #include <operations.h> #include <stack.h> +int arrayLookup(char *text, const char array[][10], int last) +{ + int i; + for(i = 0; i < last; i++) + if(!strcmp(array[i], text)) return i; + return last; +} + void start(u64 __memsize) { init_all(__memsize);
--- a/src/std.c Wed Apr 27 22:11:51 2011 -0400 +++ b/src/std.c Wed Apr 27 22:49:00 2011 -0400 @@ -145,14 +145,6 @@ return a; } -int arrayLookup(char *text, const char array[][10], int last) -{ - int i; - for(i = 0; i < last; i++) - if(!strcmp(array[i], text)) return i; - return last; -} - char* append(char *dest, char *src) { char *ret = dest;