Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs: use the switch statement in init_special_inode()

Similar to may_open().

No functional changes.

Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Mateusz Guzik and committed by
Christian Brauner
af67f4c1 796667c9

+13 -6
+13 -6
fs/inode.c
··· 2518 2518 void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev) 2519 2519 { 2520 2520 inode->i_mode = mode; 2521 - if (S_ISCHR(mode)) { 2521 + switch (inode->i_mode & S_IFMT) { 2522 + case S_IFCHR: 2522 2523 inode->i_fop = &def_chr_fops; 2523 2524 inode->i_rdev = rdev; 2524 - } else if (S_ISBLK(mode)) { 2525 + break; 2526 + case S_IFBLK: 2525 2527 if (IS_ENABLED(CONFIG_BLOCK)) 2526 2528 inode->i_fop = &def_blk_fops; 2527 2529 inode->i_rdev = rdev; 2528 - } else if (S_ISFIFO(mode)) 2530 + break; 2531 + case S_IFIFO: 2529 2532 inode->i_fop = &pipefifo_fops; 2530 - else if (S_ISSOCK(mode)) 2531 - ; /* leave it no_open_fops */ 2532 - else 2533 + break; 2534 + case S_IFSOCK: 2535 + /* leave it no_open_fops */ 2536 + break; 2537 + default: 2533 2538 printk(KERN_DEBUG "init_special_inode: bogus i_mode (%o) for" 2534 2539 " inode %s:%lu\n", mode, inode->i_sb->s_id, 2535 2540 inode->i_ino); 2541 + break; 2542 + } 2536 2543 } 2537 2544 EXPORT_SYMBOL(init_special_inode); 2538 2545