Representation of File System in the Kernel

Representation of data on a floppy and hard disk may consistently differ, but representing them in the kernel is almost same.

VFS mounts the file system through the function

  • register_filesystem(struct file_system_type *fs),
  • Example

register_filesystem(&ext2_fs_type);

Mounting

  • Before a file can be accessed, the file system containing the file should be mounted.
  • Done by the call using mount or function mount_root()
  • Every mounted file system is represented by a super_block structure.
  • The function read_super()of the VFS is used to initialize the superblock
    • Managing the file system
    • Will issue some flags during the mounting like

MS_RDONLY //File system is read only

MS_REMOUNT //flags have been changed

 

Superblock Operations

Super block provides functions needed to access the file system and its processing. Some of the operation includes

read_inode();// must execute and Responsible for filling the submitted inode structure

write_inode(); //must execute and Used to store information about the inode structure

put_inode();// optional and Release all the blocks occupied by the inodes and release other resources

delete_inode(); //optional and Delete the inode and no longer be referenced to the filesystem

 

Inode Operation

  • Inode is useful for file management
  • Each inode contains a unique number which addressable to a file
  • Inode operations

create();//fills the mode attributes of the inode dentry

lookup();

link(); //used to create a hard link

unlink(); //deletes the file indicated by dentry.

mkdir();

rmdir();//deletes the subdirectory entry

rename(); moves a file or changes its name

permission();// checking for access rights

File and its Operation

File structure is helpful is providing

Access rights like reading and writing

Current position

Access flags and number of accesses

File Operations

read(); //read the data and put in the user address space

write();//copy data from user address space to the file

mmap(); // the file is mapped to user address space

open(); //create a file structure

flush(file); //called when the file is closed

lock(); // lock is called if file locks are set

Comments

Popular Posts