aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2017-10-26 01:31:53 -0400
committerTucker Evans <tuckerevans24@gmail.com>2017-10-26 01:31:53 -0400
commit1356cc5400a49710e3a037a7355d2af2a537f238 (patch)
treec35a32acd891cba5ae2cfbcaf2a68c526d2dd48e
parentd0c3f57244251552bf1ed9b5933a6deeca51a93c (diff)
CS3871/assignments/filesystem: Added write(), and ulink();
-rw-r--r--filesystem/tfs.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/filesystem/tfs.c b/filesystem/tfs.c
index b8d79bb..831f602 100644
--- a/filesystem/tfs.c
+++ b/filesystem/tfs.c
@@ -26,7 +26,8 @@ struct meta_data{
};
struct inode {
- struct meta_data info; struct block_ptr data[20];
+ struct meta_data info;
+ struct block_ptr data[20];
};
@@ -265,21 +266,47 @@ int read(fd, buf)
int fd;
char *buf;
{
+ if (files[fd].free || files[fd].mode || (files[fd].next_sec = 20))
+ return -1;
+ rsector(files[fd].node->data[files[fd].next_sec].track, files[fd].node->data[files[fd].next_sec].sector, buf);
+ files[fd].next_sec++;
+ return 512;
}
int write(fd, buf)
int fd;
char *buf;
{
-
+ if ((files[fd].next_sec = 20) || !files[fd].mode)
+ return 0;
+
+ struct blockll *tmp = get_blocks(500);
+ files[fd].node->data[files[fd].next_sec].track = tmp->data.track;
+ files[fd].node->data[files[fd].next_sec].sector = tmp->data.sector;
+
+ wsector(files[fd].node->data[files[fd].next_sec].track, files[fd].node->data[files[fd].next_sec].sector, buf);
+ return 1;
}
int ulink(fname)
char *fname;
{
+ struct inode_list *tmp = root;
+ struct inode *d;
+ int i;
+
+ for(i = 0; i < MAX_INODES && i < inode_list_size; i++){
+ tmp = tmp->next;
+ if(strcmp(fname, tmp->next->node->info.name) == 0)
+ break;;
+ }
-}
+ d = tmp->next->node;
+ tmp->next = tmp->next->next;
+ free(d);
+ return 1;
+ }
int main()
{