Mercurial > sos > sos
view include/fs.h @ 69:19000e354e36
Start working on redoing the error codes
author | Jonathan Pevarnek <pevarnj@gmail.com> |
---|---|
date | Sun, 24 Apr 2011 18:28:12 -0400 |
parents | 9816d3510467 |
children | 3b73044b740f |
line wrap: on
line source
#include <std.h> #include <error.h> #ifndef __FS_H #define __FS_H #define CACHESPACE 1 //percentage of heap to use for the FS Cache #define FNAMELEN 28 //How long the filenames are #define FSBLKSIZE 1024 #define DSKBLKSIZE 512 #define MAXBLOCKS 248 #define DEPBLK (FSBLKSIZE / sizeof(Direntry)) //director entries per block struct SUPERBLOCK { u32 magic; // == 0x42420374 u32 root_inode; // the disk block containing the root inode u32 nblocks; // number of block on the disk u32 _pad[253]; // unused (should be '\0' filled) }; typedef struct SUPERBLOCK Superblock; struct INODE { u32 size; // file length in bytes u32 _pad0; // unused (should be 0) u64 ctime; // creation time stamp u64 mtime; // last modification time stamp u16 nblocks; // number of data blocks in this file u16 _pad1; // unused (should be 0) u32 _pad2; // unused (should be 0) u32 blocks[MAXBLOCKS]; // file block ptrs }; typedef struct INODE Inode; struct FSBLK { u8 blocks[FSBLKSIZE]; }; typedef struct FSBLK FSBlk; struct DSKBLK { u8 blocks[DSKBLKSIZE]; }; typedef struct DSKBLK DskBlk; struct DIRENTRY { //32 bytes char fname[FNAMELEN]; u32 inode; }; typedef struct DIRENTRY Direntry; ErrCode init_fs(u32 devnum, u64 __memsize); ErrCode getFInfo(u32 n, void* de); ErrCode lookupFile(char *fname, u32 *fid); ErrCode getFileSize(u32 fid, u32 *size); int getFileData(u32 fid, void *ptr); int setFileData(u32 fid, const void *ptr, size_t size); short isBlockAt(u32 block); void printFname(char *name); void getFname(char *fname); int fnameCmp(const char *a, const char *b); #endif //__FSH_H