Skip to content

Commit

Permalink
debugfs: take mode-dependent parts of debugfs_get_inode() into callers
Browse files Browse the repository at this point in the history
... and trim the arguments list

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Jan 25, 2015
1 parent 680b302 commit edac65e
Showing 1 changed file with 16 additions and 32 deletions.
48 changes: 16 additions & 32 deletions fs/debugfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,12 @@ static struct vfsmount *debugfs_mount;
static int debugfs_mount_count;
static bool debugfs_registered;

static struct inode *debugfs_get_inode(struct super_block *sb, umode_t mode, dev_t dev,
void *data, const struct file_operations *fops)

static struct inode *debugfs_get_inode(struct super_block *sb)
{
struct inode *inode = new_inode(sb);

if (inode) {
inode->i_ino = get_next_ino();
inode->i_mode = mode;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
switch (mode & S_IFMT) {
default:
init_special_inode(inode, mode, dev);
break;
case S_IFREG:
inode->i_fop = fops ? fops : &debugfs_file_operations;
inode->i_private = data;
break;
case S_IFLNK:
inode->i_op = &debugfs_link_operations;
inode->i_private = data;
break;
case S_IFDIR:
inode->i_op = &simple_dir_inode_operations;
inode->i_fop = &simple_dir_operations;

/* directory inodes start off with i_nlink == 2
* (for "." entry) */
inc_nlink(inode);
break;
}
}
return inode;
}
Expand Down Expand Up @@ -334,10 +309,13 @@ struct dentry *debugfs_create_file(const char *name, umode_t mode,
if (IS_ERR(dentry))
return NULL;

inode = debugfs_get_inode(dentry->d_sb, mode, 0, data, fops);
inode = debugfs_get_inode(dentry->d_sb);
if (unlikely(!inode))
return end_creating(dentry, -ENOMEM);

inode->i_mode = mode;
inode->i_fop = fops ? fops : &debugfs_file_operations;
inode->i_private = data;
d_instantiate(dentry, inode);
dget(dentry);
fsnotify_create(dentry->d_parent->d_inode, dentry);
Expand Down Expand Up @@ -371,12 +349,16 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
if (IS_ERR(dentry))
return NULL;

inode = debugfs_get_inode(dentry->d_sb,
S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
0, NULL, NULL);
inode = debugfs_get_inode(dentry->d_sb);
if (unlikely(!inode))
return end_creating(dentry, -ENOMEM);

inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
inode->i_op = &simple_dir_inode_operations;
inode->i_fop = &simple_dir_operations;

/* directory inodes start off with i_nlink == 2 (for "." entry) */
inc_nlink(inode);
d_instantiate(dentry, inode);
dget(dentry);
inc_nlink(dentry->d_parent->d_inode);
Expand Down Expand Up @@ -423,12 +405,14 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
return NULL;
}

inode = debugfs_get_inode(dentry->d_sb, S_IFLNK | S_IRWXUGO, 0,
link, NULL);
inode = debugfs_get_inode(dentry->d_sb);
if (unlikely(!inode)) {
kfree(link);
return end_creating(dentry, -ENOMEM);
}
inode->i_mode = S_IFLNK | S_IRWXUGO;
inode->i_op = &debugfs_link_operations;
inode->i_private = link;
d_instantiate(dentry, inode);
dget(dentry);
return end_creating(dentry, 0);
Expand Down

0 comments on commit edac65e

Please sign in to comment.