Mercurial > sos > sos
changeset 53:b22b6a83cf04
Added a function to check whether a specific block is in use
author | Jonathan Pevarnek <pevarnj@gmail.com> |
---|---|
date | Sat, 09 Apr 2011 11:18:57 -0400 |
parents | 2de1c2597a60 |
children | 39fcefab46ed |
files | include/fs.h src/fs.c |
diffstat | 2 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/include/fs.h Sat Apr 09 01:28:06 2011 -0400 +++ b/include/fs.h Sat Apr 09 11:18:57 2011 -0400 @@ -32,6 +32,7 @@ u32 lookupFile(char *fname); int getFSize(u32 fid, u32 *size); int getFData(u32 fid, void *ptr); +short isBlockAt(u32 block); void printFname(char *name); void getFname(char *fname); int fnameCmp(const char *a, const char *b);
--- a/src/fs.c Sat Apr 09 01:28:06 2011 -0400 +++ b/src/fs.c Sat Apr 09 11:18:57 2011 -0400 @@ -56,7 +56,6 @@ return 0; } - //REQUIRES: ptr is large enough to hold everything int getFData(u32 fid, void *ptr) { @@ -82,6 +81,15 @@ return 0; } +short isBlockAt(u32 block) +{ //TODO reconsider return value + u32 inBlock = block/0x2000 + 2; //which block the bit is in + u32 blockSpot = (block%0x2000)/8; //which u8 the bit is in + u32 spotSpot = 7 - block%8; //which bit the bit is + u8 buffer[1024]; + if(readFSBlock(DevID, inBlock, buffer)) return -1; //TODO should this be optimized and only read one block? + return (buffer[blockSpot] >> spotSpot) & 1; +} void printFname(char *name) {