make
to build the module. Assuming that worked, you can now run:
sudo insmod ./hw9fs.ko
to load the module. To see if the module is loaded, take a look in /proc/filesystems
and look for hw9fs
. Also, try running tail /var/log/messages
, to see some debug output. With the module loaded, we can now use our filesystem. Run
sudo mount -t hw9fs -o ro,loop test.img mnt
to mount the disk image test.img
in read-only mode, using our filesystem hw9fs
, and
sudo mount -t hw9fs -o loop test.img mnt
for read-write access (the last several parts below). Read-only access is less demanding, you might want to try that first.
The directory mnt
, which used to be a regular directory, now contains our mounted filesystem. See if your output looks like mine:
jakob@ubuntu:~/hw9$ ls mnt ls: cannot access mnt/nonexisting_file: No such file or directory existing_file nonexisting_fileClearly, there is something wrong with
nonexisting_file
, but let's not worry about it. Let's see what's in existing_file
.
jakob@ubuntu:~/hw9$ cat mnt/existing_file File 3 comes second to last, and it is a long file. File 3 comes second to last, and it is a long file. File 3 comes second to last, and it is a long file. ... File 3 comes second to last, and it is a long file. File 3 comes second to last, and it jakob@ubuntu:~/hw9$If you got this far, you're ready to get started. To remove the module, first unmount the filesystem:
sudo umount mnt
then unload the module
sudo rmmod hw9fs
hexdump -C test.img
. It consists of two types of 1024-byte blocks: a single disk header block (superblock) which comes first, followed by a number of data blocks. The header consists of up to 30 adjacent structs like this:
Filename | Size![]() |
---|---|
char[26] | int |
mkcs385fs test_directory/ test.img
creates the supplied disk image.
HINT: check your logs in a separate window, using tail -f var/log/kern.log
. You will be docked points for kernel warning messages appearing in this file (not your debug output).
ls mnt
and ls -l
mnt should show no error messages or question marks. For an example output, try ls -l test_directory
. Filename and size must be correct, and the files must be readable, the rest is not important, but no question marks or error messages are allowed.
cat
. To do this, you will mostly need a way to map a "file block" into a disk block. The output of cat mnt/*
should be identical to cat test_directory/*
.
touch mnt/mynewfile ls -l mntyou should now see "mynewfile" appear in the listing, with a size of zero. hint: you'll need to add a function pointer to your inode_operations struct.
sync_dirty_buffer
to write this out to disk in an easy way. Double-check your updated disk image with hexdump -C test.img | less
echo my test > mnt/testfile ls -l mnt cat mnt/testfilethe
ls -l
should show the new file with size 8, and the cat
should output "my test". Make sure that your written output survives an unmount/mount.
hint: you'll need to add several function pointers to your address_space_operations and file_operations. Look at the fat
implementation to get some ideas.
cat hw10fs.c > mnt/testfile
to try with a large file.
sudo sysctl kernel.printk=7
Next, switch your virtual machine to a text console, by hitting ctrl-alt-f1, or cmd-ctrl-fn-f1 on a mac. This is for monitoring kernel output only: do not use this console for running things or editing text. Copyright 2016 The Board of Trustees of the University of Illinois.webmaster@cs.uic.edu |
WISEST Helping Women Faculty Advance Funded by NSF | ![]() | ![]() |