fuse/include/fuse.h

97 lines
2.0 KiB
C
Raw Normal View History

2022-11-14 21:46:44 -06:00
#ifndef FUSE_H
#define FUSE_H
#include <sys/types.h>
#define DEFAULTINODEMAX 128
#define DEFAULTBLOCKSIZE 512 // Size in bytes
#define DEFAULTBLOCKMAX 16384
2022-11-14 21:46:44 -06:00
typedef struct fuseArgStruct
{
int create;
int list;
int add;
int remove;
int extract;
char* toAdd;
char* toRemove;
char* toExtract;
char* fsname;
int fd;
int newfs;
int filefsname;
} fuseArgStruct;
typedef struct SuperBlock
{
blksize_t blockSize;
blkcnt_t blockCount;
unsigned long inodeCount;
} SuperBlock;
typedef struct FreeBlockList
{
int freeList[DEFAULTINODEMAX/32];
} FreeBlockList;
// 128 Blocks
typedef struct DataBlock
{
char byte[DEFAULTBLOCKSIZE];
} DataBlock;
// 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;
// Inode * 128 + number
// Directblock == Files/Directories inside an inode?
typedef struct DirectBlock
{
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;
2022-11-14 21:46:44 -06:00
void Fuse(int argc, char* argv[]);
2022-12-02 13:35:38 -06:00
void GetArguments(int argc, char* argv[], fuseArgStruct* fuseArgs);
void OpenFS(fuseArgStruct* fuseArgs, char* programPath);
FileSystem* SetupFS(fuseArgStruct* fuseArgs);
void RunFuse(FileSystem* fs, fuseArgStruct* fuseArgs);
2022-12-02 13:35:38 -06:00
void TearDownFS(void);
2022-11-14 21:46:44 -06:00
void FuseStructInit(fuseArgStruct* fuseStruct);
void FuseUsageError(char* programPath);
int zerosize(int fd);
int FindEmptyBitPosition(int number);
ino_t GetFreeInodeNumber(Inode inodes[]);
ino_t GetFreeBlockNumber(int fbl[]);
void SetFileSystemDefaults(FileSystem* fs);
void SetupRootDirectory(FileSystem* fs);
2022-11-14 21:46:44 -06:00
#endif