diff --git a/writeup/2.md b/writeup/2.md index 71ea7f1..524d612 100644 --- a/writeup/2.md +++ b/writeup/2.md @@ -58,4 +58,15 @@ int ext2fs_sysctl(int *, u_int, void *, size_t *, void *, size_t, Here we have some information regarding mounts. Obviously, this is the first thing we need to implement. We can try to mount a 64-bit filesystem successfully and having errors on every read first, and then slowly break our way out of that. +```c +/* ext2fs_readwrite.c */ +int ext2fs_read(void *); +int ext2fs_write(void *); +``` + +Just check for r/w, looks useful but we won't be using it until 64-bit is properly implemented. Judging by my guesses, if we implement mount correctly, reading and writing should not change for read only mode. + +For the rest of the file, we don't have any other useful declarations; just `touch`, `ls`, `ln`, `rm`, etc implementations. We won't need to modify these too much yet, so let's move on. + +I guess then, our second dive starts in `ext2fs_vfsops.c`. It's around 1142 lines, so let's read it in the next chapter. diff --git a/writeup/3.md b/writeup/3.md new file mode 100644 index 0000000..7d2d9db --- /dev/null +++ b/writeup/3.md @@ -0,0 +1,16 @@ +# Mount source code +Let's look at OpenBSD's mounting, as present in `ext2fs_vfsops.c`. + +The first two function declarations prove quite useful: + +```c +int ext2fs_sbupdate(struct ufsmount *, int); +static int e2fs_sbcheck(struct ext2fs *, int); +``` + +The first thing we are concerned with, of course, is the super block. With that being said, let's keep reading. + +Below that, we have a struct called `ext2fs_vfsops` which just contains values that are defined as certain constants (e.g. `.vfs_mount = ext2fs_mount`), but we don't care about that. Then we have the inode pool, the `ext2gennumber`, and below that, we have the initializer of the inode pool, which probably needs to be tweaked for 64-bit as well. No wonder nobody has done it 😅 + +At this point, we should see where in the mounting process ext4 fails. Create an ext4 filesystem using qemu and mount it; make sure that the virtual machine manager marks it as a readonly filesystem before mounting it to ensure that it doesn't get corrupted (at least, not yet). +