Listing fully works, attempting to fix name issue with add
This commit is contained in:
parent
88087f6050
commit
5bfa0a79e4
@ -44,13 +44,15 @@ void AddFileToFS(FileSystem* fs, char* fname)
|
|||||||
// Second: get a number for the next free direct block
|
// Second: get a number for the next free direct block
|
||||||
// Third: get a free inode number
|
// Third: get a free inode number
|
||||||
// Fourth: set info for direct block
|
// Fourth: set info for direct block
|
||||||
tempname = strndup(fname, splitLocation - 1);
|
tempname = strndup(fname, splitLocation);
|
||||||
if (IsDirectorySetup(fs->inodes[currentInode], ¤tInode, tempname))
|
if (!IsDirectorySetup(fs->inodes[currentInode], ¤tInode, tempname))
|
||||||
continue;
|
{
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
tempfbl[i] = (currentInode*4) + i;
|
tempfbl[i] = (currentInode*4) + i;
|
||||||
newDirectBlock = GetFreeBlockNumber(tempfbl, 4);
|
newDirectBlock = GetFreeBlockNumber(tempfbl, 4);
|
||||||
newInode = GetFreeInodeNumber(fs->inodes);
|
newInode = GetFreeInodeNumber(fs->inodes);
|
||||||
|
printf("Name held: |%s|\n", tempname);
|
||||||
|
printf("Block: |%i|\n", newDirectBlock);
|
||||||
strcpy(fs->inodes[currentInode].blocks[newDirectBlock].name, tempname);
|
strcpy(fs->inodes[currentInode].blocks[newDirectBlock].name, tempname);
|
||||||
free(tempname);
|
free(tempname);
|
||||||
fs->inodes[currentInode].blocks[newDirectBlock].isValid = 1;
|
fs->inodes[currentInode].blocks[newDirectBlock].isValid = 1;
|
||||||
@ -58,10 +60,7 @@ void AddFileToFS(FileSystem* fs, char* fname)
|
|||||||
fs->inodes[currentInode].blocks[newDirectBlock].inode = newInode;
|
fs->inodes[currentInode].blocks[newDirectBlock].inode = newInode;
|
||||||
currentInode = newInode;
|
currentInode = newInode;
|
||||||
fs->inodes[currentInode].isValid = 1;
|
fs->inodes[currentInode].isValid = 1;
|
||||||
// SetDirectBlock(fs->inodes[currentInode].blocks[newDirectBlock]);
|
}
|
||||||
// SetNewInode();
|
|
||||||
// fs->inodes[currentInode].blocks;
|
|
||||||
// inodeNumber = GetFreeInodeNumber(fs->inodes);
|
|
||||||
fname = fname + splitLocation + 1;
|
fname = fname + splitLocation + 1;
|
||||||
splitLocation = FindNextDirectory(fname);
|
splitLocation = FindNextDirectory(fname);
|
||||||
}
|
}
|
||||||
@ -71,12 +70,10 @@ void AddFileToFS(FileSystem* fs, char* fname)
|
|||||||
fs->inodes[currentInode].blocks[newDirectBlock].isValid = 1;
|
fs->inodes[currentInode].blocks[newDirectBlock].isValid = 1;
|
||||||
fs->inodes[currentInode].blocks[newDirectBlock].size = tempstat.st_size;
|
fs->inodes[currentInode].blocks[newDirectBlock].size = tempstat.st_size;
|
||||||
strcpy(fs->inodes[currentInode].blocks[newDirectBlock].name, fname);
|
strcpy(fs->inodes[currentInode].blocks[newDirectBlock].name, fname);
|
||||||
// SetFileInDirectory();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// List path names of all used inodes
|
// List path names of all used inodes
|
||||||
// TODO: Fix implementation to print starting at Inode 0
|
|
||||||
void ListFS(FileSystem* fs)
|
void ListFS(FileSystem* fs)
|
||||||
{
|
{
|
||||||
Inode* fsRoot = &(fs->inodes[0]);
|
Inode* fsRoot = &(fs->inodes[0]);
|
||||||
|
@ -64,6 +64,9 @@ void Test_FileSystem_Should_AddFile(void)
|
|||||||
argv[1] = "-a";
|
argv[1] = "-a";
|
||||||
GetArguments(argc, argv, &dummyFuse);
|
GetArguments(argc, argv, &dummyFuse);
|
||||||
RunFuse(fakefs, &dummyFuse);
|
RunFuse(fakefs, &dummyFuse);
|
||||||
|
argv[2] = "test/files/test2.txt";
|
||||||
|
GetArguments(argc, argv, &dummyFuse);
|
||||||
|
RunFuse(fakefs, &dummyFuse);
|
||||||
TEST_ASSERT_EQUAL(1, fakefs->inodes[1].isValid);
|
TEST_ASSERT_EQUAL(1, fakefs->inodes[1].isValid);
|
||||||
TEST_ASSERT_EQUAL_CHAR_ARRAY("test1.txt", fakefs->inodes[2].blocks[0].name, 9);
|
TEST_ASSERT_EQUAL_CHAR_ARRAY("test1.txt", fakefs->inodes[2].blocks[0].name, 9);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user