Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 8: The Virtual Filesystem


#define f_vfsmnt f_path.mnt
const struct file_operations *f_op;
atomic_t f_count;
unsigned int f_flags;
mode_t f_mode;
loff_t f_pos;
struct fown_struct f_owner;
unsigned int f_uid, f_gid;
struct file_ra_state f_ra;

unsigned long f_version;
...
struct address_space *f_mapping;
...
};

The elements have the following meanings:


❑ f_uidandf_gidspecify the UID and the GID of the user.
❑ f_ownercontains information on the process working with the file (and therefore determines the
PID to whichSIGIOsignals are sent to implement asynchronous input and output).
❑ The readahead characteristics are held inf_ra. These values specify if and how file data are to
be read in anticipation before they are actually requested (readahead improves system perfor-
mance).
❑ Themodepassedwhenafileisopened (generally read, write, or readandwrite access) is held in
thef_modefield.
❑ f_flagsspecifies additional flags that can be passed on theopensystem call.
❑ The current position of the file pointer (which is important for sequential read operations or
when reading a specific file section) is held in thef_posvariable as a byte offset from the begin-
ning of the file.
❑ f_pathencapsulates two pieces of information:

❑ An association between filename and inode
❑ Information about the mounted filesystem in which the file resides

The path data structure is defined as follows:
<namei.h>
struct path {
struct vfsmount *mnt;
struct dentry *dentry;
};
struct dentryprovides a connection between filename and inode. I discuss it in Section 8.3.5.
Information about the mounted filesystem is contained instruct vfs_mount, discussed in
Section 8.4.1.
Since former kernel versions did not usestruct pathbut had explicitdentryandvfsmount
members instruct file, corresponding helper macros are required ensuring that code that is
not yet updated continues to work.
Free download pdf