C语言代写|HW8 Pantry

这是一篇美国的文件系统C语言代写

As with previous assignments, we will be using GitHub to distribute skeleton code and collect submissions. Please refer to our Git Workflow guide for more details. Note that we will be using multiple tags for this assignment, for each deliverable part.

For students on ARM Mac computers (e.g. with M1 chip): if you want your submission to be built/tested for ARM, you must create and submit a file called .armpls in the toplevel directory of your repo; feel free to use the following one-liner:

cd “$(git rev-parse –show-toplevel)” && touch .armpls && git add .armpls &&

You should do this first so that this file is present in all parts.

There is a script in the skeleton code named run_checkpatch.sh . It is a wrapper over linux/scripts/checkpatch.pl , which is a Perl script that comes with the linux kernel that checks if your code conforms to the kernel coding style.

Execute run_checkpatch.sh to see if your code conforms to the kernel style – it’ll let you know what changes you should make. You must make these changes before pushing a tag. Passing run_checkpatch.sh with no warnings and no errors is required for this assignment.

A loop device is a pseudo-device that makes a file accessible as a block device. Files of this kind are often used for CD ISO images. Mounting a file containing a file system via such a loop mount makes the files within that file system accessible.

$ sudo su

# dd if=/dev/zero of=./ext2.img bs=1024 count=100

100+0 records in

100+0 records out

102400 bytes (102 kB, 100 KiB) copied, 0.000600037 s, 171 MB/s

# modprobe loop

# losetup –find –show ext2.img

/dev/loop0

# mkfs -t ext2 /dev/loop0

mke2fs 1.44.5 (15-Dec-2018)

Creating filesystem with 100 1k blocks and 16 inodes

Allocating group tables: done

Writing inode tables: done

Writing superblocks and filesystem accounting information: done

# mkdir mnt

# mount /dev/loop0 ./mnt

drwxr-xr-x 3 root root 1024 Apr 21 02:22 .

drwxr-xr-x 37 hans hans 4096 Apr 21 02:22 ..

drwx—— 2 root root 12288 Apr 21 02:22 lost+found

# mkdir sub2

drwxr-xr-x 4 root root 1024 Apr 21 02:23 .

drwxr-xr-x 37 hans hans 4096 Apr 21 02:22 ..4/29/22, 10:50 PM

Page 3 of 28

drwx—— 2 root root 12288 Apr 21 02:22 lost+found

drwxr-xr-x 2 root root 1024 Apr 21 02:23 sub2

# cd sub2

drwxr-xr-x 2 root root 1024 Apr 21 02:23 .

drwxr-xr-x 4 root root 1024 Apr 21 02:23 ..

# mkdir sub2.1

drwxr-xr-x 3 root root 1024 Apr 21 02:24 .

drwxr-xr-x 4 root root 1024 Apr 21 02:23 ..

drwxr-xr-x 2 root root 1024 Apr 21 02:24 sub2.1

# touch file2.1

drwxr-xr-x 3 root root 1024 Apr 21 02:24 .

drwxr-xr-x 4 root root 1024 Apr 21 02:23 ..

-rw-r–r– 1 root root 0 Apr 21 02:24 file2.1

drwxr-xr-x 2 root root 1024 Apr 21 02:24 sub2.1

# cd ../../

# umount mnt/

# losetup –find

/dev/loop1

# losetup –detach /dev/loop0

# losetup –find

/dev/loop0

# ls -al mnt/

drwxr-xr-x 2 root root 4096 Apr 21 02:22 .

drwxr-xr-x 37 hans hans 4096 Apr 21 02:22 ..

Also try creating some hard links and symlinks. Make sure you understand how they affect the link counts.

In this assignment, we provide a compiled reference implementation of PantryFS for you to test your implementation against.

We provide reference implementations ( ref/pantry-x86.ko and ref/pantryarm.ko ), compiled against the stock Debian 11 kernel ( 5.10.0-8-amd64 and 5.10.0-9-arm64 , respectively). You should boot into this kernel for the rest of this assignment.

If your kernel name is slightly differerent (e.g. 5.10.0-9-amd64 ), you may get a versioning error when you try to insert the reference implementation. In that case, you can try forcibly inserting the module with insmod -f .