diff options
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/debugfs/inode.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index c69e00d69ff1..bc02e2096977 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c | |||
| @@ -70,23 +70,18 @@ static struct inode *debugfs_get_inode(struct super_block *sb, umode_t mode, dev | |||
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | /* SMP-safe */ | 72 | /* SMP-safe */ |
| 73 | static int debugfs_mknod(struct inode *dir, struct dentry *dentry, | 73 | static int debugfs_mknod(struct dentry *dentry, |
| 74 | umode_t mode, dev_t dev, void *data, | 74 | umode_t mode, void *data, |
| 75 | const struct file_operations *fops) | 75 | const struct file_operations *fops) |
| 76 | { | 76 | { |
| 77 | struct inode *inode; | 77 | struct inode *inode; |
| 78 | int error = -EPERM; | ||
| 79 | 78 | ||
| 80 | if (dentry->d_inode) | 79 | inode = debugfs_get_inode(dentry->d_sb, mode, 0, data, fops); |
| 81 | return -EEXIST; | 80 | if (unlikely(!inode)) |
| 82 | 81 | return -EPERM; | |
| 83 | inode = debugfs_get_inode(dir->i_sb, mode, dev, data, fops); | 82 | d_instantiate(dentry, inode); |
| 84 | if (inode) { | 83 | dget(dentry); |
| 85 | d_instantiate(dentry, inode); | 84 | return 0; |
| 86 | dget(dentry); | ||
| 87 | error = 0; | ||
| 88 | } | ||
| 89 | return error; | ||
| 90 | } | 85 | } |
| 91 | 86 | ||
| 92 | static int debugfs_mkdir(struct dentry *dentry, umode_t mode) | 87 | static int debugfs_mkdir(struct dentry *dentry, umode_t mode) |
| @@ -95,7 +90,7 @@ static int debugfs_mkdir(struct dentry *dentry, umode_t mode) | |||
| 95 | int res; | 90 | int res; |
| 96 | 91 | ||
| 97 | mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR; | 92 | mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR; |
| 98 | res = debugfs_mknod(dir, dentry, mode, 0, NULL, NULL); | 93 | res = debugfs_mknod(dentry, mode, NULL, NULL); |
| 99 | if (!res) { | 94 | if (!res) { |
| 100 | inc_nlink(dir); | 95 | inc_nlink(dir); |
| 101 | fsnotify_mkdir(dir, dentry); | 96 | fsnotify_mkdir(dir, dentry); |
| @@ -110,7 +105,7 @@ static int debugfs_create(struct dentry *dentry, umode_t mode, | |||
| 110 | int res; | 105 | int res; |
| 111 | 106 | ||
| 112 | mode = (mode & S_IALLUGO) | S_IFREG; | 107 | mode = (mode & S_IALLUGO) | S_IFREG; |
| 113 | res = debugfs_mknod(dir, dentry, mode, 0, data, fops); | 108 | res = debugfs_mknod(dentry, mode, data, fops); |
| 114 | if (!res) | 109 | if (!res) |
| 115 | fsnotify_create(dir, dentry); | 110 | fsnotify_create(dir, dentry); |
| 116 | return res; | 111 | return res; |
| @@ -458,8 +453,7 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, | |||
| 458 | return NULL; | 453 | return NULL; |
| 459 | } | 454 | } |
| 460 | 455 | ||
| 461 | error = debugfs_mknod(dentry->d_parent->d_inode, dentry, | 456 | error = debugfs_mknod(dentry, S_IFLNK | S_IRWXUGO, link, NULL); |
| 462 | S_IFLNK | S_IRWXUGO, 0, link, NULL); | ||
| 463 | if (error) | 457 | if (error) |
| 464 | kfree(link); | 458 | kfree(link); |
| 465 | 459 | ||
