Skip to Content
Understanding the Linux Kernel, Second Edition
book

Understanding the Linux Kernel, Second Edition

by Daniel P. Bovet, Marco Cesati
December 2002
Intermediate to advanced
784 pages
27h 7m
English
O'Reilly Media, Inc.
Content preview from Understanding the Linux Kernel, Second Edition

Pathname Lookup

In this section, we illustrate how the VFS derives an inode from the corresponding file pathname. When a process must identify a file, it passes its file pathname to some VFS system call, such as open( ), mkdir( ), rename( ), or stat( ).

The standard procedure for performing this task consists of analyzing the pathname and breaking it into a sequence of filenames. All filenames except the last must identify directories.

If the first character of the pathname is / , the pathname is absolute, and the search starts from the directory identified by current->fs->root (the process root directory). Otherwise, the pathname is relative and the search starts from the directory identified by current->fs->pwd (the process-current directory).

Having in hand the inode of the initial directory, the code examines the entry matching the first name to derive the corresponding inode. Then the directory file that has that inode is read from disk and the entry matching the second name is examined to derive the corresponding inode. This procedure is repeated for each name included in the path.

The dentry cache considerably speeds up the procedure, since it keeps the most recently used dentry objects in memory. As we saw before, each such object associates a filename in a specific directory to its corresponding inode. In many cases, therefore, the analysis of the pathname can avoid reading the intermediate directories from the disk.

However, things are not as simple as they look, since ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Understanding the Linux Kernel, 3rd Edition

Understanding the Linux Kernel, 3rd Edition

Daniel P. Bovet, Marco Cesati
Understanding the Linux Kernel

Understanding the Linux Kernel

Daniel P. Bovet, Marco Cesati
Linux Kernel Programming

Linux Kernel Programming

Kaiwan N. Billimoria

Publisher Resources

ISBN: 0596002130Catalog PageErrata