and some files are dynamically created as the filesystem is read. All
the process directories (those with numerical names and <#1664#> self<#1664#>)
essentially have inode numbers that are the pid
shifted left 16 bits, but the
files within those directories reuse low (1--10 or so) inode numbers,
which are added at runtime to the pid of the process.
This is done in inode.c by careful re-assignment of <#1665#> inode_operation<#1665#>
structures.
Most of the short read-only files in the root directory and in each
process subdirectory one use a simplified interface provided by the
<#1666#> array_inode_operations<#1666#> structure, within array.c.
Other directories, such as /proc/net/, have their own inode numbers.
For instance, the net directory itself has inode number 8. The files
within that directory use inode numbers from the range 128--160, and
those are uniquely identified in inode.c and the files given the
proper permissions when looked up and read.
Adding a file is relatively simple, and is left as an exercise for
the reader. Adding a new directory is a little bit harder. Assuming
that it is not a dynamically allocated directory like the process
directories, here are the steps:
add a section that looks like this:
but modify it to to do what you want. For instance, perhaps you have
a range of 200--256, and some files, inodes 200, 201, and 202,
and some directories, which are inodes 204 and 205. You also have a
file that is readable only by root, inode 206.
Your example might look like this:
You will then add a new file to this structure, like this, using the
next available inode number:
You will then have to provide for this new directory in inode.c, so:
becomes
<#1702#> [Please note: I have made changes similar to these (I wrote the
/proc/net/ support). However, this has been written from memory, and
may be unintentionally incomplete. If you notice any inadequacies,
please explain them to me in as complete detail as possible. My email
address is <#1690#> johnsonm@sunsite.unc.edu<#1690#>]<#1702#>
%