refactor: update filesystem

This commit is contained in:
Allenn
2024-02-04 16:10:53 +08:00
parent 6bdf5cc0ce
commit df6543d41a
26 changed files with 312 additions and 172341 deletions

View File

@@ -38,7 +38,7 @@ Author: AIIT XUOS Lab
Modification:
1. Increse the number of blocks and inodes
2. support more than one indirect blocks
3. remove unused stat
3. remove unused stat and nlink property of inode struct
*************************************************/
#include <assert.h>
@@ -136,7 +136,7 @@ int main(int argc, char* argv[])
wsect(1, buf);
// build root
rootino = ialloc(T_DIR);
rootino = ialloc(FS_DIRECTORY);
assert(rootino == ROOT_INUM);
bzero(&de, sizeof(de));
@@ -165,7 +165,7 @@ int main(int argc, char* argv[])
if (argv[i][0] == '_')
++argv[i];
inum = ialloc(T_FILE);
inum = ialloc(FS_FILE);
bzero(&de, sizeof(de));
de.inum = xshort(inum);
@@ -251,7 +251,6 @@ uint ialloc(ushort type)
bzero(&din, sizeof(din));
din.type = xshort(type);
din.nlink = xshort(1);
din.size = xint(0);
din.inum = inum;
winode(inum, &din);

View File

@@ -37,14 +37,14 @@ History:
Author: AIIT XUOS Lab
Modification:
1. Increse the number of indirect blocks
2. Rename some variables' name for readability
2. Remove unused nlink of inode struct
*************************************************/
#pragma once
#define T_DIR 1 // Directory
#define T_FILE 2 // File
#define T_DEV 3 // Device
#define FS_DIRECTORY 1 // Directory
#define FS_FILE 2 // File
#define FS_DEVICE 3 // Device
#define ROOT_INUM 1 // root inode number
#define BLOCK_SIZE 512 // block size
@@ -74,8 +74,7 @@ struct SuperBlock {
// Inode structure
struct Inode {
uint inum; // inode number
short type; // File type
short nlink; // Number of links to inode in file system
uint type; // File type
uint size; // Size of file (bytes)
uint addrs[NR_DIRECT_BLOCKS + NR_INDIRECT_BLOCKS]; // Data block addresses
};