The boot CPU inits in main.c:
- init buffer cache
- init virtual file system
- this inits all individual file systems, which in turn inits the inode table(s)
- init file table
- pick the
/device (ROOT_DEVICE_NUMBER) - to be mounted in part 2
The actual file system gets initialized from the first spawned process in forkret() (calling mount_root(ROOT_DEVICE_NUMBER, "vimixfs");). This is triggered via init_userspace and mounts the root file system.
While belonging to the first process (init), this still runs in S-mode.
The reason the init is placed here is that mounting the file system requires reads from disk (at least the file system super block to check some meta data). Reads will try to set the current processes sleeping until the data is ready. This would not work until a process is set up.
Lastly init will mount /dev and /sys as well as optionally additional file systems like /home.
Overview: kernel | file_system
File System: init_filesystem | vfs | vimixfs | devfs | sysfs | block_io | dentry_cache | inode | file | directory