Adding files and printing works mostly, issue with first directory not solved
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
#ifndef FSACTIONS_H
|
||||
#define FSACTIONS_H
|
||||
|
||||
#include "fusestructs.h"
|
||||
|
||||
void AddFileToFS(FileSystem* fs, char* fname);
|
||||
void ListFS(FileSystem* fs);
|
||||
void _ListFS_(FileSystem* fs, ino_t inodeNumber, short unsigned numtabs);
|
||||
void RemoveFileFromFS(FileSystem* fs, char* fname);
|
||||
void ExtractFileFromFS(FileSystem* fs, char* fname);
|
||||
|
||||
ino_t GetFreeInodeNumber(Inode inodes[]);
|
||||
ino_t GetFreeBlockNumber(int fbl[], unsigned short size);
|
||||
int FindEmptyBitPosition(int number);
|
||||
int FindNextDirectory(char* fname);
|
||||
int IsDirectorySetup(Inode inode, ino_t* inodePosition, char* directoryName);
|
||||
void SetFileSystemDefaults(FileSystem* fs);
|
||||
void SetupRootDirectory(FileSystem* fs);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef FSINTERFACE_H
|
||||
#define FSINTERFACE_H
|
||||
|
||||
#include "fusestructs.h"
|
||||
|
||||
void OpenFS(fuseArgStruct* fuseArgs, char* programPath);
|
||||
FileSystem* SetupFS(fuseArgStruct* fuseArgs);
|
||||
void MapFS(int fd);
|
||||
void UnmapFS(void);
|
||||
void FormatFS(FileSystem* fs);
|
||||
void LoadFS(FileSystem** fs);
|
||||
void TearDownFS(void);
|
||||
int zerosize(int fd);
|
||||
|
||||
|
||||
#endif
|
||||
+3
-86
@@ -2,95 +2,12 @@
|
||||
#define FUSE_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#define DEFAULTINODEMAX 128
|
||||
#define DEFAULTBLOCKSIZE 512 // Size in bytes
|
||||
#define DEFAULTBLOCKMAX 16384
|
||||
|
||||
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;
|
||||
#include "fusestructs.h"
|
||||
|
||||
void Fuse(int argc, char* argv[]);
|
||||
void GetArguments(int argc, char* argv[], fuseArgStruct* fuseArgs);
|
||||
void OpenFS(fuseArgStruct* fuseArgs, char* programPath);
|
||||
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(Inode inodes[]);
|
||||
ino_t GetFreeBlockNumber(int fbl[]);
|
||||
void SetFileSystemDefaults(FileSystem* fs);
|
||||
void SetupRootDirectory(FileSystem* fs);
|
||||
void GetArguments(int argc, char* argv[], fuseArgStruct* fuseArgs);
|
||||
void RunFuse(FileSystem* fs, fuseArgStruct* fuseArgs);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
#ifndef FUSEACTIONS_H
|
||||
#define FUSEACTIONS_H
|
||||
|
||||
#include "fuse.h"
|
||||
|
||||
#define FSSIZE 10000000
|
||||
|
||||
extern unsigned char* tempfs;
|
||||
|
||||
void MapFS(int fd);
|
||||
void UnmapFS(void);
|
||||
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
|
||||
@@ -0,0 +1,72 @@
|
||||
#ifndef FUSESTRUCTS_H
|
||||
#define FUSESTRUCTS_H
|
||||
|
||||
#define DEFAULTINODEMAX 128
|
||||
#define DEFAULTBLOCKSIZE 512 // Size in bytes
|
||||
#define DEFAULTBLOCKMAX 16384
|
||||
#define FSSIZE 10000000
|
||||
|
||||
extern unsigned char* tempfs;
|
||||
|
||||
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[DEFAULTBLOCKMAX/32];
|
||||
} FreeBlockList;
|
||||
|
||||
// 128 Blocks
|
||||
typedef struct DataBlock
|
||||
{
|
||||
char byte[DEFAULTBLOCKSIZE];
|
||||
} DataBlock;
|
||||
|
||||
// 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 blocks[DEFAULTINODEMAX];
|
||||
} Inode;
|
||||
|
||||
typedef struct FileSystem
|
||||
{
|
||||
SuperBlock superBlock;
|
||||
FreeBlockList fbl;
|
||||
Inode inodes[DEFAULTINODEMAX];
|
||||
DataBlock dataBlocks[DEFAULTBLOCKMAX];
|
||||
} FileSystem;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user