TWiki> CS385fall14 Web>Homeworks>Homework8 (revision 2)EditAttach

Device files and a virtual /proc file system

In most Linuxes, /dev/ holds a number of "device" files. These "files" are not backed by file storage. Instead, device numbers (shown with ls -l) describe what driver should handle read and write requests to this file.

Similarly, the /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. In contrast with /dev, the /proc files do not have device numbers, and even the /proc directory does not exist on disk. Instead, the contents of the directory is dynamically generated every time it is read.

In this homework, we experiment with device files, and introduce the /proc file system to xv6.

Random number device file

The system call mknod() creates a device file. However, no user space program exists to take advantage of it. Create a mknod executable, then use it to create a new device file called random with major=2, minor=1.

Modify xv6 so that when a process reads from random, an infinite series of random bytes is produced. Reading from this with cat won't work well since some numbers don't come out well as characters. To test, write a small program to read from random and print them out in decimal form.

Virtual directory listing

Create a directory /proc using 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 files called meminfo, fsinfo, cpuinfo, and core.

info and core files

Update xv6 so that meminfo, fsinfo and cpuinfo contain information about the corresponding parts of the machine.

process directories and files

For each running process, the corresponding directory (named by pid) should contain several files, including cwd, and other process-specific info.

manually mounting the proc filesystem (BONUS)

Add support for mounting the "proc" file system to any directory, even multiple different directories. To support this, modify the in-memory inode to include function pointers to key inode functions, such as dirlookup, ilock, iget, etc.

Add a system call mount(), and an executable mount that allows the user to access this functionality.

Edit | Attach | Print version | History: r6 | r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r2 - 2014-11-04 - 21:00:34 - Main.jakob
 
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
WISEST
Helping Women Faculty Advance
Funded by NSF