Presentation is loading. Please wait.

Presentation is loading. Please wait.

Linux Virtual Filesystem

Similar presentations


Presentation on theme: "Linux Virtual Filesystem"— Presentation transcript:

1 Linux Virtual Filesystem
Chris Gill and James Orr CSE 422S - Operating Systems Organization Washington University in St. Louis St. Louis, MO 63130

2 CSE 422S – Operating Systems Organization
Linux VFS Layer Kernel-wide filesystem view Superblock (struct super_block) describes a filesystem, provides operations the OS can use Each superblock has a list (in its s_list field) of superblocks for all available file systems It also keeps lists of index nodes, directory entries, files Process-specific filesystem view Process’ task_struct points to 3 filesystem structs Field fs points to a filesystem structure (struct fs_struct) Field files points to open files table (struct files_struct) Field nsproxy points to a wrapper for its namespace, etc. Each of these has further structure we will look at next CSE 422S – Operating Systems Organization

3 Linux Process’ Views of Filesystem
Fields in the process’ task_struct point to key filesystem structs The new nsproxy field points to a nsproxy struct that wraps a pointer to the filesystem’s namespace (mnt_namespace) The files field points to a table of process’ open files The fs field points to a filesystem structure that points to paths for the process’ root and current working directories current task_struct nsproxy fs files nsproxy files_struct mnt_namespace fs_struct root pwd CSE 422S – Operating Systems Organization

4 Paths and Directory Entries
Each path points to a VFS mount structure (vfs_mount) and a directory entry (dentry) structure (filesystem+directory) A VFS mount structure describes a specific filesystem instance (a “mount point”) A directory entry structure describes any element in the filesystem (directory or file, though in a path it’s a directory) current task_struct fs fs_struct root pwd path mnt dentry Vfs_mount dentry CSE 422S – Operating Systems Organization

5 Directory Entries and Index Nodes
Each directory entry points to an associated index node (inode) that contains metadata about the directory entry Last access time, permissions, etc. E.g., what you see with ls command Index nodes also implement operations the superblock uses Each directory entry also has a character array field (d_iname) that contains its name dentry ‘/’ \0 d_iname ... d_inode inode CSE 422S – Operating Systems Organization

6 Directory Entry Hierarchy
A directory’s dentry lists other directory entries that it contains Stored in its d_subdirs field List iteration requires special operations (see LKD Chapter 6) E.g., list_empty(), list_for_each(), list_for_each_entry(), etc. Can use those operations to traverse a path (or an entire filesystem) recursively via the directory entry hierarchy dentry d_iname ‘/’ \0 ... d_subdirs ... dentry d_iname ‘b’ ‘i’ ‘n’ \0 ... d_subdirs ... ... dentry d_iname ‘l’ ‘s’ \0 ... d_subdirs (empty) CSE 422S – Operating Systems Organization

7 Studio Exercises Today
Create a kernel module with a single thread Runs in kernel space, in process context Has access to filesystem, but details differ a bit from the view a user-space process has Kernel thread can get PID for a user-space process, get its task_struct and see its filesystem view Explore different file system data structures Working from process to filesystem structure to root and working directory paths, to dentrys, etc. Looking at directory entries specifically as you go CSE 422S – Operating Systems Organization


Download ppt "Linux Virtual Filesystem"

Similar presentations


Ads by Google