Fixed structure of inodes, setup testing for opening and adding fs
This commit is contained in:
+49
-23
@@ -5,6 +5,7 @@
|
||||
|
||||
#define DEFAULTINODEMAX 128
|
||||
#define DEFAULTBLOCKSIZE 512 // Size in bytes
|
||||
#define DEFAULTBLOCKMAX 16384
|
||||
|
||||
typedef struct fuseArgStruct
|
||||
{
|
||||
@@ -22,49 +23,74 @@ typedef struct fuseArgStruct
|
||||
int filefsname;
|
||||
} fuseArgStruct;
|
||||
|
||||
typedef struct SuperBlockStruct
|
||||
typedef struct SuperBlock
|
||||
{
|
||||
blksize_t blockSize;
|
||||
blkcnt_t blockCount;
|
||||
} SuperBlockStruct;
|
||||
unsigned long inodeCount;
|
||||
} SuperBlock;
|
||||
|
||||
typedef struct FBLStruct
|
||||
typedef struct FreeBlockList
|
||||
{
|
||||
int freeList[DEFAULTINODEMAX/32];
|
||||
} FBLStruct;
|
||||
} FreeBlockList;
|
||||
|
||||
typedef struct BlockStruct
|
||||
// 128 Blocks
|
||||
typedef struct DataBlock
|
||||
{
|
||||
char byte[DEFAULTBLOCKSIZE];
|
||||
} BlockStruct;
|
||||
} DataBlock;
|
||||
|
||||
// TODO: Adjust Inodes to be 128 inodes with 128 direct block references *each*
|
||||
// Slides exist for inode structure
|
||||
typedef struct InodeStruct
|
||||
{
|
||||
char filePath[256];
|
||||
off_t fileSize;
|
||||
BlockStruct dataBlock;
|
||||
} InodeStruct;
|
||||
// typedef struct InodeInfo
|
||||
// {
|
||||
// // char filePath[256];
|
||||
// // off_t fileSize;
|
||||
// ino_t inode;
|
||||
// unsigned int isDirectory : 1;
|
||||
// unsigned int isPrinted : 1;
|
||||
// unsigned int isValid : 1;
|
||||
// } InodeInfo;
|
||||
|
||||
typedef struct FileSystemStruct
|
||||
// Inode * 128 + number
|
||||
// Directblock == Files/Directories inside an inode?
|
||||
typedef struct DirectBlock
|
||||
{
|
||||
SuperBlockStruct superBlock;
|
||||
FBLStruct fbl;
|
||||
InodeStruct inodes[DEFAULTINODEMAX];
|
||||
} FileSystemStruct;
|
||||
unsigned int isValid : 1;
|
||||
unsigned int isDirectory : 1;
|
||||
char name[256];
|
||||
ino_t inode;
|
||||
off_t size;
|
||||
} DirectBlock;
|
||||
|
||||
// Inode 0 is root
|
||||
// Inode * 128
|
||||
typedef struct Inode
|
||||
{
|
||||
unsigned int isValid : 1;
|
||||
DirectBlock inodeBlocks[DEFAULTINODEMAX];
|
||||
} Inode;
|
||||
|
||||
typedef struct FileSystem
|
||||
{
|
||||
SuperBlock superBlock;
|
||||
FreeBlockList fbl;
|
||||
Inode inodes[DEFAULTINODEMAX];
|
||||
DataBlock dataBlocks[DEFAULTBLOCKMAX];
|
||||
} FileSystem;
|
||||
|
||||
void Fuse(int argc, char* argv[]);
|
||||
void GetArguments(int argc, char* argv[], fuseArgStruct* fuseArgs);
|
||||
void OpenFS(fuseArgStruct* fuseArgs, char* programPath);
|
||||
FileSystemStruct* SetupFS(fuseArgStruct* fuseArgs);
|
||||
void RunFuse(FileSystemStruct* fs, fuseArgStruct* fuseArgs);
|
||||
FileSystem* SetupFS(fuseArgStruct* fuseArgs);
|
||||
void RunFuse(FileSystem* fs, fuseArgStruct* fuseArgs);
|
||||
void TearDownFS(void);
|
||||
void FuseStructInit(fuseArgStruct* fuseStruct);
|
||||
void FuseUsageError(char* programPath);
|
||||
int zerosize(int fd);
|
||||
int FindEmptyBitPosition(int number);
|
||||
ino_t GetFreeInodeNumber(int fbl[]);
|
||||
void SetFileSystemDefaults(FileSystemStruct* fs);
|
||||
ino_t GetFreeInodeNumber(Inode inodes[]);
|
||||
ino_t GetFreeBlockNumber(int fbl[]);
|
||||
void SetFileSystemDefaults(FileSystem* fs);
|
||||
void SetupRootDirectory(FileSystem* fs);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,11 +9,14 @@ extern unsigned char* tempfs;
|
||||
|
||||
void MapFS(int fd);
|
||||
void UnmapFS(void);
|
||||
void FormatFS(FileSystemStruct* fs);
|
||||
void LoadFS(FileSystemStruct** fs);
|
||||
void ListFS(FileSystemStruct* fs);
|
||||
void AddFileToFS(FileSystemStruct* fs, char* fname);
|
||||
void RemoveFileFromFS(FileSystemStruct* fs, char* fname);
|
||||
void ExtractFileFromFS(FileSystemStruct* fs, char* fname);
|
||||
void FormatFS(FileSystem* fs);
|
||||
void LoadFS(FileSystem** fs);
|
||||
void ListFS(FileSystem* fs);
|
||||
void _RecursivePrintFS_(FileSystem* fs, ino_t inodePosition);
|
||||
int FindNextDirectory(char* fname);
|
||||
void AddFileToFS(FileSystem* fs, char* fname);
|
||||
void _RecursiveAddFS_(FileSystem* fs, char* fname);
|
||||
void RemoveFileFromFS(FileSystem* fs, char* fname);
|
||||
void ExtractFileFromFS(FileSystem* fs, char* fname);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user