Figure 103 Code flow diagram for procrootlookup

The kernel uses this routine simply to distinguish between two different types of proc entries before delegating the real work to specialized routines. Entries may be files in a process-specific directory, as with /proc/1/maps. Alternatively, entries may be files registered dynamically by a driver or subsystem (e.g., /proc/cpuinfo or /proc/net/dev). It is up to the kernel to distinguish between the two.

The kernel first invokes proc_lookup to find regular entries. If the function finds the file it is looking for (by sequentially scanning the components of the specified path), everything is OK, and the lookup operation is terminated.

If proc_lookup fails to find an entry, the kernel invokes proc_pid_lookup to look in the list of process-specific entries.

These functions are not examined in detail here. All we need to know is that an appropriate inode type is returned (proc_pid_lookup is discussed again in Section 10.1.7, where the creation and structure of process-specific inodes are discussed).

Continue reading here: Reading and Writing Information

Was this article helpful?

0 0