[PATCH][FYI] special inode handling in 2.3.x

Alexander Viro (viro@math.psu.edu)
Mon, 14 Jun 1999 09:10:40 -0400 (EDT)


1. efs_read_inode() didn't convert the device number to kdev_t.
The patch below fixes it (init_special_inode() does the conversion).

2. Folks, in 2.3.x we have a better mechanism to initialize in-core
inodes of special files (everything but regular files, directories and
symlinks). Pseudo-manpage follows:

NAME
init_special_inode - initialize in-core inode of special file.

SYNOPSIS
#include <linux/fs.h>

void init_special_inode(struct inode *inode, umode_t mode, int dev);

DESCRIPTION
init_special_inode does all necessary initialization of in-core inode
of special file. It sets i_mode and i_op according to mode argument.
For devices it also converts device number (dev) to kdev_t and sets
i_rdev field. For FIFOs it supersedes init_fifo(). There are two
places where it is typically used - foofs_read_inode() and
foofs_mknod() (see examples in fs/ext2/inode.c and fs/ext2/namei.c).

HISTORY
Introduced in 2.3.1

Please, consider switching to that mechanism. It will save
everybody a lot of PITA if/when the changes in device/FIFO/socket handling
will happen. In the official tree almost everything is already there
(exceptions: efs, romfs, devpts and openpromfs)

diff -urN linux-2.3.6/fs/efs/inode.c linux-bird.misc/fs/efs/inode.c
--- linux-2.3.6/fs/efs/inode.c Fri May 14 23:54:40 1999
+++ linux-bird.misc/fs/efs/inode.c Mon Jun 14 01:17:35 1999
@@ -131,16 +131,10 @@
inode->i_op = &efs_symlink_inode_operations;
break;
case S_IFCHR:
- inode->i_rdev = device;
- inode->i_op = &chrdev_inode_operations;
- break;
case S_IFBLK:
- inode->i_rdev = device;
- inode->i_op = &blkdev_inode_operations;
- break;
case S_IFIFO:
- init_fifo(inode);
- break;
+ init_special_inode(inode, inode->i_mode, device);
+ break;
default:
printk(KERN_WARNING "EFS: unsupported inode mode %o\n", inode->i_mode);
goto read_inode_error;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/