Standard File Operations

When a device file is opened, the various filesystem implementations invoke the init_special_inode function to create the inode for a block or character device file.6

fs/inode.c void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev) {

inode->i_fop = &def_chr_fops; inode->i_rdev = rdev; } else if (S_ISBLK(mode)) {

inode->i_fop = &def_blk_fops; inode->i_rdev = rdev;

else printk(KERN_DEBUG "init_special_inode: bogus i_mode (%o)\n", mode);

The underlying filesystem must return the major and minor numbers of a device in addition to the device type (block or character) passed in mode. The inode is supplied with different file operations depending on device type.

Continue reading here: Standard Operations for Character Devices

Was this article helpful?

0 0