Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 312930
b: refs/heads/master
c: cfa57c1
h: refs/heads/master
v: v3
  • Loading branch information
Al Viro committed Jul 14, 2012
1 parent 1b798f5 commit a5b2acb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 34 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c3b1a350846a11dd1054cb7832e098aa37025deb
refs/heads/master: cfa57c11b0d5a80f7bffa1ab35bc46892127817f
53 changes: 20 additions & 33 deletions trunk/fs/debugfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,19 @@ static struct file_system_type debug_fs_type = {
.kill_sb = kill_litter_super,
};

static int debugfs_create_by_name(const char *name, umode_t mode,
struct dentry *parent,
struct dentry **dentry,
void *data,
const struct file_operations *fops)
struct dentry *__create_file(const char *name, umode_t mode,
struct dentry *parent, void *data,
const struct file_operations *fops)
{
int error = 0;
struct dentry *dentry = NULL;
int error;

pr_debug("debugfs: creating file '%s'\n",name);

error = simple_pin_fs(&debug_fs_type, &debugfs_mount,
&debugfs_mount_count);
if (error)
goto exit;

/* If the parent is not specified, we create it in the root.
* We need the root dentry to do this, which is in the super
Expand All @@ -309,48 +315,29 @@ static int debugfs_create_by_name(const char *name, umode_t mode,
if (!parent)
parent = debugfs_mount->mnt_root;

*dentry = NULL;
dentry = NULL;
mutex_lock(&parent->d_inode->i_mutex);
*dentry = lookup_one_len(name, parent, strlen(name));
if (!IS_ERR(*dentry)) {
dentry = lookup_one_len(name, parent, strlen(name));
if (!IS_ERR(dentry)) {
switch (mode & S_IFMT) {
case S_IFDIR:
error = debugfs_mkdir(parent->d_inode, *dentry, mode,
error = debugfs_mkdir(parent->d_inode, dentry, mode,
data, fops);
break;
case S_IFLNK:
error = debugfs_link(parent->d_inode, *dentry, mode,
error = debugfs_link(parent->d_inode, dentry, mode,
data, fops);
break;
default:
error = debugfs_create(parent->d_inode, *dentry, mode,
error = debugfs_create(parent->d_inode, dentry, mode,
data, fops);
break;
}
dput(*dentry);
dput(dentry);
} else
error = PTR_ERR(*dentry);
error = PTR_ERR(dentry);
mutex_unlock(&parent->d_inode->i_mutex);

return error;
}

struct dentry *__create_file(const char *name, umode_t mode,
struct dentry *parent, void *data,
const struct file_operations *fops)
{
struct dentry *dentry = NULL;
int error;

pr_debug("debugfs: creating file '%s'\n",name);

error = simple_pin_fs(&debug_fs_type, &debugfs_mount,
&debugfs_mount_count);
if (error)
goto exit;

error = debugfs_create_by_name(name, mode, parent, &dentry,
data, fops);
if (error) {
dentry = NULL;
simple_release_fs(&debugfs_mount, &debugfs_mount_count);
Expand Down

0 comments on commit a5b2acb

Please sign in to comment.