User login

Navigation

Virtual File System - Part 2

When a File System is mounted, the superblock is generated and the root inode for the file system is entered in the field 'i_mount' of the inode corresponding to the appropriate mount point.

The inodes are maintained in two structures in the memory:

* A doubly linked circular list starting with first_inode. This list also includes the free, unused inodes.

* An open hash table hash_table[ ], for faster access.

The inodes are managed using the functions:

* iget (to procure an inode)

* namei (to get an inode corresponding to the filename passed as parameter)

* iput (to release an inode after use)

Inode Operations

The inode structure contains a pointer to an inode_operations structure, which in turn contains pointers to functions needed for file management. These functions are usually called directly from appropriate system calls.

struct inode_operations

{

struct file_operations *default_file_ops;

int (*create) (struct inode *dir, const char *filename, int len,

int mode, struct inode **result_inode);

int (*lookup) (struct inode *dir, const char *filename, int len,

struct inode **result_inode);

int (*link) (struct inode *oldinode, struct inode *dir,

const char *filename, int len);

int (*unlink) (struct inode *dir, const char *filename, int len);

int (*symlink) (struct inode *dir, const char *filename, int len,

const char *destname);

int (*mkdir) (struct inode *dir, const char *filename, int len,

int mode);

int (*rmdir) (struct inode *dir, const char *filename, int len);

int (*mknod) (struct inode *dir, const char *filename, int len,

int mode, int rdev);

int (*rename) (struct inode *olddir, const char *oldname, int oldlen,

struct inode *newdir, const char *newname,

int newlen);

int (*readlink) (struct inode *inode1, char *buf, int size);

int (*follow_link) (struct inode *dir, struct inode *inode1,

int flag, int mode, struct inode **result_inode);

int (*bmap) (struct inode *inode1, int block);

void (*truncate) (struct inode *inode1);

int (*permission) (struct inode *inode1, int flag);

int (*smap) (struct inode *inode1, int sector);

};

NOTE: the parameters have been given names here in order to co-relate with them during the following discussion.

* default_file_ops

It points to a file operations structure, which is an interface for various operations on files, like open, read etc.