diff --git a/src/sys/ubixfsv2/fsAbstract.h b/src/sys/ubixfsv2/fsAbstract.h index 5a03a79..16354cb 100644 --- a/src/sys/ubixfsv2/fsAbstract.h +++ b/src/sys/ubixfsv2/fsAbstract.h @@ -26,7 +26,7 @@ /* FS Functions */ virtual int vfs_init(void) { return -1; }; - virtual int vfs_format(dev_t *) { return -1; }; + virtual int vfs_format(device_t *) { return -1; }; virtual int vfs_stop(void) { return -1; }; virtual int vfs_sync(void) { return -1; }; virtual void * vfs_mknod(const char *, mode_t) { return NULL; }; diff --git a/src/sys/ubixfsv2/ubixfs.cpp b/src/sys/ubixfsv2/ubixfs.cpp index fac1ba6..13e8ddc 100644 --- a/src/sys/ubixfsv2/ubixfs.cpp +++ b/src/sys/ubixfsv2/ubixfs.cpp @@ -71,10 +71,12 @@ if (freeBlockList != NULL) delete [] freeBlockList; freeBlockList = new signed char[superBlock->batSectors*512]; assert(freeBlockList); + memset(freeBlockList, 0, superBlock->batSectors*512); + cout << "reading in freeBlockList" << endl; device->read(device, freeBlockList, - device->sectors-superBlock->batSectors-1, + device->sectors - superBlock->batSectors-1, superBlock->batSectors ); // device->read() @@ -394,11 +396,16 @@ inode->parent.iAddr.start = 0; inode->parent.iAddr.len = 0; + inode->blocks.direct[0].allocationGroup = 0; + inode->blocks.direct[0].start = 1; + inode->blocks.direct[0].len = 1; +// inode->blocks.maxDirectRange = 1; + strcpy(inode->name, "/"); inode->uid = getuid(); inode->gid = getgid(); // inode->mode - // inode->flags + inode->flags = INODE_DIRECTORY; // inode->createTime // inode->lastModifiedTime // inode->type diff --git a/src/sys/ubixfsv2/ubixfs.h b/src/sys/ubixfsv2/ubixfs.h index b87e0fb..0c8d989 100644 --- a/src/sys/ubixfsv2/ubixfs.h +++ b/src/sys/ubixfsv2/ubixfs.h @@ -7,6 +7,7 @@ #include "types.h" #define INODE_IN_USE 0x00000001 +#define INODE_DIRECTORY 0x00000002 #define ATTR_INODE 0x00000004 #define INODE_LOGGED 0x00000008 #define INODE_DELETED 0x00000010 @@ -18,15 +19,19 @@ #define NUM_DIRECT_BLOCKS 64 #define MAX_FILENAME_LENGTH 256 -#define UBIXFS_MAGIC1 0x0A0A0A0A -#define UBIXFS_MAGIC2 0x0B0B0B0B -#define UBIXFS_MAGIC3 0x0C0C0C0C +#define UBIXFS_MAGIC1 0xA0A0A0A +#define UBIXFS_MAGIC2 0xB0B0B0B +#define UBIXFS_MAGIC3 0xC0C0C0C +/* befs magic numbers +#define SUPER_BLOCK_MAGIC1 0x42465331 // BFS1 +#define SUPER_BLOCK_MAGIC2 0xdd121031 +#define SUPER_BLOCK_MAGIC3 0x15b6830e +#define INODE_MAGIC 0x3bbe0ad9 + */ #define UBIXFS_CLEAN 0x434C454E // CLEN #define UBIXFS_DIRTY 0x44495254 // DIRT -struct bNode; -struct ubixfsInode; typedef struct blockRun { int allocationGroup __attribute__ ((packed)); @@ -34,10 +39,16 @@ unsigned short len __attribute__ ((packed)); } inodeAddr; +struct bNode; +struct ubixfsInode; +class bTree; + typedef union uPtr { inodeAddr iAddr; bNode * bPtr; + bTree * btPtr; ubixfsInode * iPtr; + void * vPtr; off_t offset; }; @@ -86,16 +97,15 @@ } diskSuperBlock; typedef struct dataStream { - struct blockRun direct[NUM_DIRECT_BLOCKS]; - off_t maxDirectRange; - struct blockRun indirect; - off_t maxIndirectRange; - struct blockRun double_indirect; - off_t maxDoubleIndirectRange; - off_t size; + struct blockRun direct[NUM_DIRECT_BLOCKS] __attribute__ ((packed)); + off_t maxDirectRange __attribute__ ((packed)); + struct blockRun indirect __attribute__ ((packed)); + off_t maxIndirectRange __attribute__ ((packed)); + struct blockRun double_indirect __attribute__ ((packed)); + off_t maxDoubleIndirectRange __attribute__ ((packed)); + off_t size __attribute__ ((packed)); } dataStream; - typedef struct ubixfsInode { int32 magic1 __attribute__ ((packed)); inodeAddr inodeNum __attribute__ ((packed)); @@ -112,9 +122,9 @@ uPtr parent __attribute__ ((packed)); uPtr next __attribute__ ((packed)); uPtr prev __attribute__ ((packed)); -// binodeEtc *etc ?? - dataStream data __attribute__ ((packed)); - char smallData[3220] __attribute__ ((packed)); + uPtr data __attribute__ ((packed)); + dataStream blocks __attribute__ ((packed)); + char smallData[3212] __attribute__ ((packed)); } ubixfsInode; class UbixFS : public vfs_abstract {