summaryrefslogtreecommitdiff
path: root/fs/debugfs/inode.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-01-25 14:31:32 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2015-01-25 16:52:52 -0500
commit680b302409cdc87c2000a31f2ceb2951bd642260 (patch)
tree10ba80adfd51d79dcc978d9d6071501970d6beb1 /fs/debugfs/inode.c
parent3473cde5655cf4501cadb8ed11ab8aad1484b377 (diff)
downloadlwn-680b302409cdc87c2000a31f2ceb2951bd642260.tar.gz
lwn-680b302409cdc87c2000a31f2ceb2951bd642260.zip
fold debugfs_mknod() into callers
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/debugfs/inode.c')
-rw-r--r--fs/debugfs/inode.c68
1 files changed, 31 insertions, 37 deletions
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 778c0e32eb51..b765c04eba20 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -69,21 +69,6 @@ static struct inode *debugfs_get_inode(struct super_block *sb, umode_t mode, dev
return inode;
}
-/* SMP-safe */
-static int debugfs_mknod(struct dentry *dentry,
- umode_t mode, void *data,
- const struct file_operations *fops)
-{
- struct inode *inode;
-
- inode = debugfs_get_inode(dentry->d_sb, mode, 0, data, fops);
- if (unlikely(!inode))
- return -EPERM;
- d_instantiate(dentry, inode);
- dget(dentry);
- return 0;
-}
-
static inline int debugfs_positive(struct dentry *dentry)
{
return dentry->d_inode && !d_unhashed(dentry);
@@ -339,7 +324,7 @@ struct dentry *debugfs_create_file(const char *name, umode_t mode,
const struct file_operations *fops)
{
struct dentry *dentry;
- int error;
+ struct inode *inode;
if (!(mode & S_IFMT))
mode |= S_IFREG;
@@ -349,10 +334,14 @@ struct dentry *debugfs_create_file(const char *name, umode_t mode,
if (IS_ERR(dentry))
return NULL;
- error = debugfs_mknod(dentry, mode, data, fops);
- if (!error)
- fsnotify_create(dentry->d_parent->d_inode, dentry);
- return end_creating(dentry, error);
+ inode = debugfs_get_inode(dentry->d_sb, mode, 0, data, fops);
+ if (unlikely(!inode))
+ return end_creating(dentry, -ENOMEM);
+
+ d_instantiate(dentry, inode);
+ dget(dentry);
+ fsnotify_create(dentry->d_parent->d_inode, dentry);
+ return end_creating(dentry, 0);
}
EXPORT_SYMBOL_GPL(debugfs_create_file);
@@ -377,18 +366,22 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
{
struct dentry *dentry = start_creating(name, parent);
- int error;
+ struct inode *inode;
if (IS_ERR(dentry))
return NULL;
- error = debugfs_mknod(dentry, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
- NULL, NULL);
- if (!error) {
- inc_nlink(dentry->d_parent->d_inode);
- fsnotify_mkdir(dentry->d_parent->d_inode, dentry);
- }
- return end_creating(dentry, error);
+ inode = debugfs_get_inode(dentry->d_sb,
+ S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
+ 0, NULL, NULL);
+ if (unlikely(!inode))
+ return end_creating(dentry, -ENOMEM);
+
+ d_instantiate(dentry, inode);
+ dget(dentry);
+ inc_nlink(dentry->d_parent->d_inode);
+ fsnotify_mkdir(dentry->d_parent->d_inode, dentry);
+ return end_creating(dentry, 0);
}
EXPORT_SYMBOL_GPL(debugfs_create_dir);
@@ -419,25 +412,26 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
const char *target)
{
struct dentry *dentry;
- char *link;
- int error;
-
- link = kstrdup(target, GFP_KERNEL);
+ struct inode *inode;
+ char *link = kstrdup(target, GFP_KERNEL);
if (!link)
return NULL;
dentry = start_creating(name, parent);
-
if (IS_ERR(dentry)) {
kfree(link);
return NULL;
}
- error = debugfs_mknod(dentry, S_IFLNK | S_IRWXUGO, link, NULL);
- if (error)
+ inode = debugfs_get_inode(dentry->d_sb, S_IFLNK | S_IRWXUGO, 0,
+ link, NULL);
+ if (unlikely(!inode)) {
kfree(link);
-
- return end_creating(dentry, error);
+ return end_creating(dentry, -ENOMEM);
+ }
+ d_instantiate(dentry, inode);
+ dget(dentry);
+ return end_creating(dentry, 0);
}
EXPORT_SYMBOL_GPL(debugfs_create_symlink);