           < < <  PROCFS  > > >



*** Contents

o /proc/mtab support for displaying raw information about mounted filsystems

o 32-bit PIDs support and vwp subdirectory in proc filesystem

o viper scheme COPYPID support for clone (kernel threads)

o A little bit cleaned /proc filesystem

o The same sources run both as standalone module and in kernel



*** Note for procfs compiled in kernel

1. apply patches to the kernel at the directory above linux.
Patches can be found here in ./linux/ directory.
# patch -p0 < .../proc/linux/vwprocfs-1.1-1.1.61.diff

2. build the kernel

If you had created kernel module before building the kernel, 
the *.o files are not appropriate for kernel. Remove them with

# cd linux/fs/proc 
# make -f Module.make clean

before bulding the kernel. Do not forget to do it, building
kernel will exit with error.



*** Note for procfs mounted from standalone module

1. apply patches to the kernel
# patch -p0 < vwprocfs-1.1-1.1.61.diff

1a. rebuild the kernel

1b. if you have upgraded kernel version, but have old vwprocfs
    module compiled, you need to recompile the module. Remove stale
    version number with
# cd linux/fs/proc
# rm release.c       <--- this file carries old version number
                          new one will be created by Module.make

2. build the module. If necessary, create .depend file:
# cd linux/fs/proc
# make -f Module.make dep

remove previos *.o if it's from kernel:
# make -f Module.make clean

make the module
# make -f Module.make

3. have module utility installed (recommended new one from 
sunsite.unc.edu:/pub/Linux/kernel/modules.tar.gz)
# insmod procfs.o

4. you can check wether procfs made it into the kernel
# lsmod
Module:        #pages:  Used by:
procfs             4

5. mount alternative procfs to existing mount point /mnt. (Always have 2
identical /mnt /mnt otherwise you can't unmount this) 
# mount -t procfs /mnt /mnt

6. Play with it
# cd /mnt

7. Before removing, sessions must leave /mnt 
# cd /

8. unmount it
umount /mnt

9. remove it from kernel
rmmod procfs



*** New features explained

o Additional flag COPYPID for clone syscall makes it produce 32-bit
  PIDs.

o 32-bit PID support is done by using task[] pool index to code
  the process identity. The directory /proc/PID/vwp/* contains
  symlinks to otherwise invisible processes created by clone 
  syscall with COPYPID. Method: every PID (visible or not) contains
  an invisible inode with symlink to PID itself. Then in PID/vwp
  we put hardlinks to this symlink.

o Raw mount information is derived from list of superblocks.
  Entries are: 
  0. number of the entry 0, 1, 2...
  1. major/minor number of mounted device
  2. covered inode number of the device on which it mounted
  3. major/minor number of the device on which it mounted
  4. mounted inode (replaces covered inode)
  5. ascii filesystem type
  6. HEX flags
 
In reality, it looks like
$ mount
/dev/hdb6 on / type ext2 (defaults)
/dev/hdb7 on /vol/usr type ext2 (defaults)
/dev/hdb5 on /vol/usr1 type ext2 (defaults)
/dev/hda1 on /hd/a1 type msdos (defaults)
/dev/hdb1 on /hd/b1 type msdos (defaults)
/proc on /proc type proc (defaults)
03:03:12 emard:/tmp/proc
$ cat /proc/mtab
0: 3/70          2 3/70          2 ext2 0
1: 3/71         45 3/70          2 ext2 0
2: 3/69       4368 3/70          2 ext2 0
3: 3/1        7923 3/70          1 msdos 0
4: 3/65       7924 3/70          1 msdos 0
5: 0/1         155 3/70          1 proc 0
03:03:18 emard:/tmp/proc
$ cd mtab
01:08:02 emard:/proc/mtab
$ ls -al
total 0
dr-xr-xr-x   2 root     root            0 Nov  6 01:07 ./
dr-xr-xr-x   7 root     root            0 Nov  6 01:05 ../
lr-xr-xr-x   1 root     root           64 Nov  6 01:08 0 -> [0346]:2
lr-xr-xr-x   1 root     root           64 Nov  6 01:08 1 -> [0347]:2
lr-xr-xr-x   1 root     root           64 Nov  6 01:08 2 -> [0345]:2
lr-xr-xr-x   1 root     root           64 Nov  6 01:08 3 -> [0301]:1
lr-xr-xr-x   1 root     root           64 Nov  6 01:08 4 -> [0341]:1
lr-xr-xr-x   1 root     root           64 Nov  6 01:08 5 -> [0001]:1
01:08:05 emard:/proc/mtab
$ 

These are symlinks to mountpoints. you can do umount /proc/mtab/4
To unmount 4th point - please note /etc/mtab will get out of sync! 

/proc/mtab will still say truth about what is mounted and what isn't.

Original mount-point path can be obtained in C by entering the
/proc/mtab/n/ directory and taking pathname string with getcwd();

Please note that /proc/mtab has dual character - it behaves both as
file and as a directory.


*** Bugs

/proc/mtab report file can be up to 4KB (1 page) long.


*** Author
--                                               ____  _  _   _   ___ ___
<davor@emard.pub.hr>, <davj@ds5000.irb.hr>       \   \| \/ | / \ | _ |   \
---- Davor Jadrijevic --- PGP capable ----------- >   |    |/ _ \|   |    >
                                                 /___/|_\/_|_/ \_|_|\|___/