Assignment 3. File System
Assignment 3. File System
File System
Operating Systems 2021
Assignment
Implement your own driver for a (simple) file system: SFS
4 KB 32 KB 8 MB
M
a
g Rootdir Block table Data blocks
i
c
SFS Directories
Root directory of 64 entries, subdirectories 16 entries
4 2 58 struct sfs_entry {
char filename[58];
d size block filename blockidx_t first_block;
uint32_t size;
1 bit 28 bit } __attribute__((__packed__));
SFS Block Table
Directory entry refers to first blockidx of a file/directory
Special values:
direntry.first_block = 4
0xffff: Block unused (free)
0xfffe: End of chain 0xffff
0xffff
6
0xffff
2
Update from last year (2020): free blocks are now 0xffff, and blockidx 0 0xffff
corresponds to the first block (not 1) 0xfffe
0xffff
...
Disk I/O
We use an image on the host file system, instead of an actual disk partition
Arbitrary sizes/offsets allowed (no need to read/write in aligned full disk blocks)
You are now allowed to cache any data in memory (i.e., must read from disk for
every operation).
Getting started
More details on SFS and framework in PDF/readme
Check out sfs.h for all required data types and constant values
Timestamps:
00:00 framework tool overview
08:05 framework code overview
18:24 readdir implementation
29:11 getattr implementation
Getting started - next steps
Follow along with included tests (make check):
root blocktable
SFS_ROOTDIR_OFF
foo
strtok(mypath, “/”)
Getting started - how to traverse paths?
For example, a getattr of /foo/bar/baz:
root blocktable
readme .filename=foo
SFS_ROOTDIR_OFF
foo .size=0x80000000
.first_block=7
spam
foo
strtok(mypath, “/”)
Getting started - how to traverse paths?
For example, a getattr of /foo/bar/baz:
root blocktable
.filename=bar
readme .filename=foo bar .size=0x80000000
SFS_ROOTDIR_OFF
foo .size=0x80000000 eggs .first_block=17
.first_block=7
spam
foo bar
strtok(mypath, “/”)
Getting started - how to traverse paths?
For example, a getattr of /foo/bar/baz:
root blocktable
.filename=bar
readme .filename=foo bar .size=0x80000000
SFS_ROOTDIR_OFF .filename=baz
foo .size=0x80000000 eggs .first_block=17
.first_block=7 baz .size=700
.first_block=13
spam
root blocktable
ffff
ffff
ffff
ffff
fffe Return buffer
ffff .filename=baz
ffff .size=700
ffff
ffff .first_block=13 512 bytes 188 bytes
ffff
ffff
ffff 700 bytes
ffff
4 Get direntry same
ffff
way as for getattr
...
(make helper func!)
Getting started - how to read file?
For example, a read of /foo/bar/baz, size=700:
root blocktable
ffff
ffff
ffff
ffff
fffe Return buffer
ffff .filename=baz
ffff .size=700
ffff
ffff .first_block=13 512 bytes 188 bytes
ffff
ffff
ffff 700 bytes
ffff
4
ffff
...
Submission
Deadline December 15th 23:59 CET. This is a strict deadline - no extensions!
As always: do not share your solution, or copy from someone else or the internet.