/proc
directory holds a number of files that don't have a representation on disk. These "virtual" files describe the state and configuration of the system, its processes, and more. Indeed, even the /proc directory contents don't exist on disk. Instead, the contents of the directory is dynamically generated every time it is read.
In this homework, we introduce the /proc file system to xv6.
mkdir
. Modify xv6 so that when ls /proc
is executed, it shows a list of "virtual" files - files that don't actually exist on disk. There should be one directory per running process, and a file called meminfo
.
To help you with this part, the hw8
template in the git repository includes some changes to the file system code. Specifically, struct inode
now contains a pointer to a struct inode_functions
, which in turn holds functions for reading and writing file contents, and for populating inode data.
To get started, change the i_func pointer of the inode for "/proc", so that when we try to read "/proc", your functions are called. To provide a directory listing, see how "ls.c" reads it, and write a procfs_readi
function to match. The function namei()
returns a struct inode* given a path. To populate the struct (read in inode contents from disk), use ilock()
.
Make sure "ls /proc" displays the appropriate names listed above, and sensible types and sizes. For this, you'll need to implement procfs_ipopulate
. Watch out for iget() here: use a different device number for "proc" files to avoid reusing the wrong inode.
cpuinfo
shows how many cores are available.
pid
) should contain several files, including name
, and parent
.
main()
do the mounting. However, during grading, the /proc
folder won't exist, and you'll lose points if your program doesn't work right on the first run.
So, have init.c create the /proc
folder using mkdir()
. But on the first run, you still don't have a /proc
when main()
runs. So, for full points, create a sys_mount()
system call, and call that from init.c. Of course, once you have that, it's a hop, skip and a jump to the bonus points below:
mount()
, and an executable mount
that allows the user to mount any named file system (proc being the only one supported at the moment), on any directory.
FYI, we'll be testing this on a folder name other than /proc
. Copyright 2016 The Board of Trustees of the University of Illinois.webmaster@cs.uic.edu |
WISEST Helping Women Faculty Advance Funded by NSF | ![]() | ![]() |