Filesystem Type Registration
Often, the user configures Linux to recognize all the filesystems needed when compiling the kernel for her system. But the code for a filesystem actually may either be included in the kernel image or dynamically loaded as a module (see Appendix B). The VFS must keep track of all filesystem types whose code is currently included in the kernel. It does this by performing filesystem type registration.
Each registered filesystem is represented as a file_system_type object whose fields are illustrated in Table 12-9.
|
Type |
Field |
Description |
|
const char * |
name |
Filesystem name |
|
int |
fs flags |
Filesystem type flags |
|
struct super block *(*)( ) |
read super |
Method for reading superblock |
|
struct module * |
owner |
Pointer to the module implementing the filesystem (see Appendix B) |
|
struct file_system_type * |
next |
Pointer to the next list element |
All filesystem-type objects are inserted into a simply linked list. The file_systems variable points to the first item, while the next field of the structure points to the next item in the list. The file_systems_lock read/write spin lock protects the whole list against concurrent accesses.
The fs_supers field represents the head (first dummy element) of a list of superblock objects corresponding to mounted filesystems of the given type. The backward and forward links of a list element are stored in the s_instances field of the superblock object.
The read_super field points to the filesystem-type-dependant function that reads the superblock from the disk device and copies it into the corresponding superblock object.
The fs_flags field stores several flags, which are listed in Table 12-10.
|
Name |
Description |
|
FS REQUIRES DEV |
Any filesystem of this type must be located on a physical disk device. |
|
FS NO DCACHE |
No longer used. |
|
FS NO PRELIM |
No longer used. |
|
FS SINGLE |
There can be only one superblock object for this filesystem type. |
|
FS NOMOUNT |
Filesystem has no mount point (see Section 12.3.1). |
|
FS LITTER |
Purge dentry cache after unmounting (for special filesystems). |
|
FS ODD RENAME |
"Rename" operations are "move" operations (for network filesystems). |
During system initialization, the register_filesystem( ) function is invoked for every filesystem specified at compile time; the function inserts the corresponding file_system_type object into the filesystem-type list.
The register_filesystem( ) function is also invoked when a module implementing a filesystem is loaded. In this case, the filesystem may also be unregistered (by invoking the unregister_filesystem( ) function) when the module is unloaded.
The get_fs_type( ) function, which receives a filesystem name as its parameter, scans the list of registered filesystems looking at the name field of their descriptors, and returns a pointer to the corresponding file_system_type object, if it is present.
I [email protected] RuBoard
Continue reading here: Filesystem Mounting
Was this article helpful?