Issue still unresolved, submitting
This commit is contained in:
parent
4444defd27
commit
a96a215147
@ -12,6 +12,7 @@ void ExtractFileFromFS(FileSystem* fs, char* fname);
|
||||
|
||||
ino_t GetFreeInodeNumber(Inode inodes[]);
|
||||
ino_t GetFreeBlockNumber(int fbl[], unsigned short size);
|
||||
void UpdateFreeBlockList(int* number, int position);
|
||||
int FindEmptyBitPosition(int number);
|
||||
int FindNextDirectory(char* fname);
|
||||
int FindDirectory(Inode inode, char* directoryName);
|
||||
|
@ -37,7 +37,7 @@ void AddFileToFS(FileSystem* fs, char* fname)
|
||||
{
|
||||
tempname = strndup(fname, splitLocation);
|
||||
newInode = FindDirectory(fs->inodes[currentInode], tempname);
|
||||
if (newInode == -1)
|
||||
if ((newInode == -1) || (newInode == currentInode))
|
||||
{
|
||||
newDirectBlock = GetFreeBlockNumber(fs->fbl.freeList + (currentInode*4), 4);
|
||||
newInode = GetFreeInodeNumber(fs->inodes);
|
||||
@ -71,6 +71,8 @@ void ListFS(FileSystem* fs)
|
||||
|
||||
void _ListFS_(FileSystem* fs, ino_t inodeNumber, short unsigned numtabs)
|
||||
{
|
||||
if (!(fs->inodes[inodeNumber].isValid))
|
||||
return;
|
||||
for (int i = 0; i < fs->superBlock.inodeCount; i++)
|
||||
{
|
||||
if (!(fs->inodes[inodeNumber].blocks[i].isValid))
|
||||
@ -78,9 +80,15 @@ void _ListFS_(FileSystem* fs, ino_t inodeNumber, short unsigned numtabs)
|
||||
for (int j = 0; j < numtabs; j++)
|
||||
printf("\t");
|
||||
printf("%s\n", fs->inodes[inodeNumber].blocks[i].name);
|
||||
if (fs->inodes[inodeNumber].blocks[i].isDirectory)
|
||||
_ListFS_(fs, fs->inodes[inodeNumber].blocks[i].inode, numtabs + 1);
|
||||
if (!(fs->inodes[inodeNumber].blocks[i].isDirectory))
|
||||
continue;
|
||||
if (!(fs->inodes[fs->inodes[inodeNumber].blocks[i].inode].isValid))
|
||||
continue;
|
||||
if (fs->inodes[inodeNumber].blocks[i].inode == inodeNumber)
|
||||
return;
|
||||
_ListFS_(fs, fs->inodes[inodeNumber].blocks[i].inode, numtabs + 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove a file from the filesystem
|
||||
@ -106,7 +114,10 @@ int _RemoveFileFromFS_(FileSystem* fs, ino_t inodeNumber, char* fname)
|
||||
continue;
|
||||
}
|
||||
if (strcmp(fs->inodes[inodeNumber].blocks[i].name, fname) == 0)
|
||||
{
|
||||
fs->inodes[inodeNumber].blocks[i].isValid = 0;
|
||||
UpdateFreeBlockList(&(fs->fbl.freeList[inodeNumber * 4]), i);
|
||||
}
|
||||
else
|
||||
emptyDir = 0;
|
||||
}
|
||||
@ -184,6 +195,13 @@ ino_t GetFreeBlockNumber(int fbl[], unsigned short size)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Frees the used block in the fbl
|
||||
void UpdateFreeBlockList(int* number, int position)
|
||||
{
|
||||
*number = *number - (1 << position);
|
||||
return;
|
||||
}
|
||||
|
||||
// Finds next empty bit in Free Block List
|
||||
int FindEmptyBitPosition(int number)
|
||||
{
|
||||
|
11
src/fuse.c
11
src/fuse.c
@ -11,17 +11,6 @@
|
||||
#include "fsactions.h"
|
||||
#include "fsinterface.h"
|
||||
|
||||
/*
|
||||
* Steps to formatting inodes:
|
||||
* 1) Check if file exists already in directory
|
||||
* 2) If file does not exist in directory, provide new inode
|
||||
* 3) Inodes are placed inside of inodes that are directories
|
||||
*
|
||||
*/
|
||||
|
||||
// TODO: Take BlockStruct out of InodeStruct
|
||||
// Make a method for turning names into Inodes
|
||||
|
||||
// Main handler for Fuse
|
||||
void Fuse(int argc, char* argv[])
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user