2006-07-21 15:18:04 +02:00
|
|
|
// on-disk file system format
|
|
|
|
|
2006-08-09 03:09:36 +02:00
|
|
|
#define BSIZE 512 // block size
|
|
|
|
|
|
|
|
// sector 1 (2nd sector)
|
2006-07-21 15:18:04 +02:00
|
|
|
struct superblock{
|
2006-08-09 03:09:36 +02:00
|
|
|
uint size;
|
|
|
|
uint nblocks;
|
|
|
|
uint ninodes;
|
2006-07-21 15:18:04 +02:00
|
|
|
};
|
|
|
|
|
2006-08-25 03:11:30 +02:00
|
|
|
#define NADDRS (NDIRECT+1)
|
2006-08-24 04:44:41 +02:00
|
|
|
#define NDIRECT 12
|
|
|
|
#define INDIRECT 12
|
|
|
|
#define NINDIRECT (BSIZE / sizeof(uint))
|
|
|
|
#define MAXFILE (NDIRECT + NINDIRECT)
|
2006-07-21 15:18:04 +02:00
|
|
|
|
|
|
|
struct dinode {
|
|
|
|
short type;
|
2006-08-08 20:07:37 +02:00
|
|
|
short major;
|
|
|
|
short minor;
|
2006-07-21 15:18:04 +02:00
|
|
|
short nlink;
|
|
|
|
uint size;
|
2006-08-24 04:44:41 +02:00
|
|
|
uint addrs[NADDRS];
|
2006-07-21 15:18:04 +02:00
|
|
|
};
|
2006-08-08 20:07:37 +02:00
|
|
|
|
2006-07-21 15:18:04 +02:00
|
|
|
#define T_DIR 1
|
|
|
|
#define T_FILE 2
|
2006-08-08 20:07:37 +02:00
|
|
|
#define T_DEV 3
|
2006-07-21 15:18:04 +02:00
|
|
|
|
2006-08-09 03:09:36 +02:00
|
|
|
// sector 0 is unused, sector 1 is superblock, inodes start at sector 2
|
|
|
|
#define IPB (BSIZE / sizeof(struct dinode))
|
|
|
|
#define IBLOCK(inum) (inum / IPB + 2) // start of inode
|
|
|
|
#define BPB (BSIZE*8)
|
|
|
|
#define BBLOCK(b,ninodes) (b/BPB + (ninodes/IPB) + 3) // start of bitmap
|
2006-07-21 15:18:04 +02:00
|
|
|
|
2006-07-22 00:10:40 +02:00
|
|
|
#define DIRSIZ 14
|
|
|
|
|
2006-07-21 15:18:04 +02:00
|
|
|
struct dirent {
|
|
|
|
ushort inum;
|
2006-07-22 00:10:40 +02:00
|
|
|
char name[DIRSIZ];
|
2006-07-21 15:18:04 +02:00
|
|
|
};
|
2006-08-15 17:53:46 +02:00
|
|
|
|
|
|
|
|