Proc/Dev File Systems
Abstract
The goal of this project is to add /dev and /proc file systems to MINIX3.
The purpose of the /dev file system is to provide a dynamically populated /dev directory. The high-level goal of this part of the project is to let device drivers dynamically register device nodes based on the hardware available in the system.
The purpose of the /proc file system is to provide a /proc directory that offers information about the system and processes running on it. The high-level goal of this part of the project is to provide an interface cleaner than getsysinfo(2)
for retrieval of system information by userland utilities like ps(1)
and top(1)
, and to provide a more consistent and extensible way of exposing system information in general.
Design
Test Plan and Evaluation
Schedule and Deliverables
Weekly Status
Week #1 [23.05.2009 - 29.05.2009] Getting Started
Familiarizing with the anticipated project work. Analysis and discussion with the mentor on the project design. Setting up the programming environment and the MINIX3 virtual box. Used programming enivronment – Eclipse with Remote System Explorer plug-in. The plug-in provides remote access to the MINIX3 file system, as well as remote compiling.
Week #2 [30.05.2009 - 06.06.2009]
Graduation 2009 at Jacobs University. No implementation provided, The time spent during this week will be compensated with work during the weekends.
VTreeFS
Accomplished
Implemented the initial skeleton of software design.
Full implementation of the VTreeFS tree structure (as specified in the design document). The implemented functions include (without specifying the function arguments):
add_inode ()
delete_inode ()
get_inode_by_name ()
get_inode_by_index ()
get_inode_name ()
get_inode_index ()
get_inode_cbdata ();
get_root_inode ()
get_parent_inode ()
get_first_inode ()
get_next_inode ()
get_inode_stat ()
set_inode_stat ()
start_vtreefs ()
Provided tests files for the initial tree structure.
Highlights
Use of the SMDB algorithm for creating the hash tables for (parent,name)→inode lookup. The method provides excellent distribution of the inodes in the hash-table.
ToDo
VTreeFS
Accomplished
VTreeFS
Accomplished
Week #6 [29.06.2009 - 05.07.2009] Initial /proc file system
Accomplished
Design of the procfs server. Implementation of the hooks defined in the VTreeFS library:
read_hook
lookup_hook
getdents_hook
rdlink_hook
Added init_hook in the VTreeFS library used for initalization of the Virtual Tree server, right after REQ_READSUPER_S request has been issued
Implementation of the system calls getuname(), getloadavg(), getuptime() and sys_hz(). The following files are provided in the procfs:
/proc/hz
/proc/version
/proc/uptime
/proc/loadavg
Design of an optimal structure able to represent all the available pids (still in the initial version): /proc/[pid#]/
Week #7 [06.07.2009 - 12.07.2009] Complete /proc/[pid] structure
Accomplished
Complete implementation of an optimal structure to represent all the available processes.
Small changes to the delete_inode and put_inode functions in the VTreeFS library. The delete_inode function uses INODE_DELETED flag to delete an inode which is being used by the VTreeFS server at the same moment. put_inode deletes the inode, after fs_putnode is being executed.
Design of the /proc/[pid]/status and /proc/[pid]/psinfo.
Full analysis of top.c and ps.c commands and implemented the necessary informations in /proc/[pid]/psinfo
Week #8 [13.07.2009 - 19.07.2009] Partial top and ps implementation
The most important part of the procfs is the /proc/[pid]/psinfo entry. All the informations concerning one process are presented in this file, and the data is very easy to be parsed. The current format of the psinfo has the following form (C programming language):
If the process is a kernel task:
"%d %d %d %s %d %c %d %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld"
Otherwise (a normal process):
"%d %d %d %s %d %c %d %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %d %d %d %d %d %d %d %d"
.
There is no difference between the two entries, except that a normal process has an extra data of 8 entries. The data represented by those entries is the following (given by the same order as in the control string):
%d (p_pid) - pid number
%d (p_nr) - kernel slot number
%d (p_endpoint) - kernel endpoint number
%s (p_name) - process name
%d (p_rts_flags) - process flags set by kernel
%c (state) - state of the process
%d (p_priority) - process priority
%ld (p_user_time) - process user time
%ld (p_sys_time) - process system time
%d (p_getfrom_e) - the endpoint of the p_getfrom_e - "recv" field
%ld (t_mem_len) - length of T process segment
%ld (d_mem_len) - length of D process segment
%ld (s_mem_len) - length of S process segment
%ld (t_mem_vir) - virtual address of segment T
%ld (d_mem_vir) - virtual address of segment D
%ld (s_mem_vir) - virtual address of segment S
%ld (t_mem_phys) - physical address of segment T
%ld (d_mem_phys) - physical address of segment D
%ld (s_mem_phys) - physical address of segment S
%d (mp_nice) - the process nice value
%d (mp_flags) - process PM flags
%d (mp_ppid) - PPID (parent PID)
%d (mp_procgrp) - PID of the process group
%d (mp_realuid) - REALUID
%d (mp_effuid) - EFFUID
%d (fp_tty) - the process tty
%d (fp_task) - print which task is proc suspended on
Having the entries above, partial implementation of top and ps is provided. Missing implementation of the methods to show the process arguments.
Week #9 [20.07.2009 - 26.07.2009] Complete ps and top implementation
I had some difficulties understanding the process frame of the individual processes. After couple of days of code analysis, I manged to get back on track.
Accomplished
Week #10 [27.07.2009 - 02.08.2009] Testing /proc, top and ps
Accomplished
Completed the full structure of the /proc file system
Performed tests of the whole /proc tree, as well as top and ps and corrected some minor errors
Starting with the implementation of the DevFS
Week #11 [03.08.2009 - 09.08.2009] Reading week
Reading week. The design document of David C. van Moolenbroek required knowledge of the other OS modules, including the RS and DS. No implementation provided this week.
Week #12 [10.08.2009 - 16.08.2009] Complete /proc/[pid] structure
Accomplished
Added RS_REG_NODE to <minix/com.h> to support node registration in the RS
Implemented rs_register_node in lib/syslib/rs.c
Implemented the RS_REG_NODE request in the RS - do_register_node
service.c was modfied such that the drivers are started with extra parameters: -devtype and -devnr. The parameter -dev was exclded.
/etc/rc and /etc/usr/rc are changed to comply with the new “service” implementation
Inital implementation of the DevFS.
DevFS
I lost couple of days of coding, since I was moving to Swtizerland.
Accomplished
vtreefs.h was changed such that an extra hook was added - vfs_req_hook. This hook was necessary for mknod implementation of the DevFS. If the hook is defined as NULL, it won't be used by the VTreeFS.
DevFS was completed
Changing drivers. So far the following drivers are changed:
Final evaluation submitted