Added bash script for testing during makefile test
This commit is contained in:
+6
-6
@@ -77,16 +77,16 @@ void FuseGivenTest(fuseArgStruct* fuseArgs, char* programPath)
|
||||
}
|
||||
MapFS(&fileSystem, fuseArgs->fd);
|
||||
if (fuseArgs->newfs)
|
||||
FormatFS();
|
||||
LoadFS();
|
||||
FormatFS(&fileSystem);
|
||||
LoadFS(&fileSystem);
|
||||
if (fuseArgs->add)
|
||||
AddFileToFS(fuseArgs->toAdd);
|
||||
AddFileToFS(&fileSystem, fuseArgs->toAdd);
|
||||
if (fuseArgs->remove)
|
||||
RemoveFileFromFS(fuseArgs->toRemove);
|
||||
RemoveFileFromFS(&fileSystem, fuseArgs->toRemove);
|
||||
if (fuseArgs->extract)
|
||||
ExtractFileFromFS(fuseArgs->toExtract);
|
||||
ExtractFileFromFS(&fileSystem, fuseArgs->toExtract);
|
||||
if(fuseArgs->list)
|
||||
ListFS();
|
||||
ListFS(&fileSystem);
|
||||
UnmapFS(&fileSystem);
|
||||
}
|
||||
|
||||
|
||||
+50
-19
@@ -1,7 +1,11 @@
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include "fuseactions.h"
|
||||
|
||||
void MapFS(FileSystemStruct* fs, int fd)
|
||||
@@ -19,32 +23,59 @@ void UnmapFS(FileSystemStruct* fs)
|
||||
munmap(fs, FSSIZE);
|
||||
}
|
||||
|
||||
void FormatFS(void)
|
||||
void FormatFS(FileSystemStruct* fs)
|
||||
{
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
fs->fbl.freeList[i] = 0;
|
||||
}
|
||||
|
||||
void LoadFS(void)
|
||||
void LoadFS(FileSystemStruct* fs)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ListFS(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AddFileToFS(char* fname)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RemoveFileFromFS(char* fname)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ExtractFileFromFS(char* fname)
|
||||
void ListFS(FileSystemStruct* fs)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 32; j++)
|
||||
if ((fs->fbl.freeList[i] & (1 << j)) == (1 << j))
|
||||
printf("%s\n", fs->inodes[i*32 + j].filePath);
|
||||
}
|
||||
|
||||
void AddFileToFS(FileSystemStruct* fs, char* fname)
|
||||
{
|
||||
struct stat statBuffer;
|
||||
int inodeNumber = -1;
|
||||
int i = -1;
|
||||
while ((inodeNumber < 0) && (i < 4))
|
||||
{
|
||||
i++;
|
||||
inodeNumber = FindEmptyBitPosition(fs->fbl.freeList[i]);
|
||||
}
|
||||
fs->fbl.freeList[i] = (fs->fbl.freeList[i]) | (1 << inodeNumber);
|
||||
printf("FBL: %i\n", fs->fbl.freeList[i]);
|
||||
inodeNumber = (i * 32) + inodeNumber;
|
||||
printf("Inode location: %i\n", inodeNumber);
|
||||
printf("Filename: %s\n", fname);
|
||||
strcpy(fs->inodes[inodeNumber].filePath, fname);
|
||||
stat(fname, &statBuffer);
|
||||
fs->inodes[inodeNumber].fileSize = statBuffer.st_size;
|
||||
int fd = open(fname, O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
perror(fname);
|
||||
exit(1);
|
||||
}
|
||||
read(fd, fs->inodes[inodeNumber].dataBlock.byte, sizeof(BlockStruct));
|
||||
close(fd);
|
||||
}
|
||||
|
||||
void RemoveFileFromFS(FileSystemStruct* fs, char* fname)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ExtractFileFromFS(FileSystemStruct* fs, char* fname)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user