aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2017-10-25 22:05:17 -0400
committerTucker Evans <tuckerevans24@gmail.com>2017-10-25 22:05:17 -0400
commit2988dd2a77503a2576ba3a40a641b779a18da380 (patch)
treeab8ad4b3dcc12fe2919361b86a718cbf7be57a72
parentd161084ff8e16640eff77be99eaa67fb692d522e (diff)
CS3871/assignments/filesystem: Changed i_table from array to linked list
-rw-r--r--filesystem/tfs.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/filesystem/tfs.c b/filesystem/tfs.c
index dfab5f7..2a44fdf 100644
--- a/filesystem/tfs.c
+++ b/filesystem/tfs.c
@@ -35,7 +35,14 @@ typedef struct filestuff{
};
-struct inode i_table[MAX_INODES];
+struct inode_list{
+ struct inode node;
+ struct inode_list *next;
+}
+
+
+int inode_list_size = 0;
+struct inode_list *root;
char bitmap[128][4096/8];
@@ -115,6 +122,8 @@ int inode_init()
int n = MAX_INODES / 4;
int i;
char *ptr;
+ struct inode_list tmp;
+
if (MAX_INODES % 4 > 0)
n++;
@@ -125,9 +134,13 @@ int inode_init()
}
ptr = buf;
+ tmp = root;
for(i=0; i< MAX_INODES; i++) {
- memcpy(&i_table[i], ptr, 64);
+ tmp->next = malloc(sizeof(struct inode_list));
+ memcpy(&tmp->node, ptr, 64);
ptr += 64;
+ tmp = tmp->next
+ inode_list_size++;
}
}
@@ -136,10 +149,12 @@ void inode_save()
{
int i, j;
char *buf = malloc(512);
+ struct inode_list tmp = root;
- for (i = 0; i < MAX_INODES && i_table->info.name[0] != 0; i++) {
+ for (i = 0; i < MAX_INODES && tmp->next;i++) {
for (j = 0; j < 4; j++){
- memcpy(buf + j, &i_table[(i * 4) + j], sizeof(struct inode));
+ tmp = tmp->next;
+ memcpy(buf + j, tmp->node, sizeof(struct inode));
}
wsector(0, INODE_START + i, buf);
}