diff options
author | David Woodhouse <dwmw2@infradead.org> | 2007-01-17 18:34:51 -0500 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2007-01-17 18:34:51 -0500 |
commit | 9cdf083f981b8d37b3212400a359368661385099 (patch) | |
tree | aa15a6a08ad87e650dea40fb59b3180bef0d345b /fs/debugfs | |
parent | e499e01d234a31d59679b7b1e1cf628d917ba49a (diff) | |
parent | a8b3485287731978899ced11f24628c927890e78 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'fs/debugfs')
-rw-r--r-- | fs/debugfs/inode.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 137d76c3f90a..c692487346ea 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/kobject.h> | 24 | #include <linux/kobject.h> |
25 | #include <linux/namei.h> | 25 | #include <linux/namei.h> |
26 | #include <linux/debugfs.h> | 26 | #include <linux/debugfs.h> |
27 | #include <linux/fsnotify.h> | ||
27 | 28 | ||
28 | #define DEBUGFS_MAGIC 0x64626720 | 29 | #define DEBUGFS_MAGIC 0x64626720 |
29 | 30 | ||
@@ -54,7 +55,8 @@ static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t d | |||
54 | inode->i_op = &simple_dir_inode_operations; | 55 | inode->i_op = &simple_dir_inode_operations; |
55 | inode->i_fop = &simple_dir_operations; | 56 | inode->i_fop = &simple_dir_operations; |
56 | 57 | ||
57 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ | 58 | /* directory inodes start off with i_nlink == 2 |
59 | * (for "." entry) */ | ||
58 | inc_nlink(inode); | 60 | inc_nlink(inode); |
59 | break; | 61 | break; |
60 | } | 62 | } |
@@ -87,15 +89,22 @@ static int debugfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
87 | 89 | ||
88 | mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR; | 90 | mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR; |
89 | res = debugfs_mknod(dir, dentry, mode, 0); | 91 | res = debugfs_mknod(dir, dentry, mode, 0); |
90 | if (!res) | 92 | if (!res) { |
91 | inc_nlink(dir); | 93 | inc_nlink(dir); |
94 | fsnotify_mkdir(dir, dentry); | ||
95 | } | ||
92 | return res; | 96 | return res; |
93 | } | 97 | } |
94 | 98 | ||
95 | static int debugfs_create(struct inode *dir, struct dentry *dentry, int mode) | 99 | static int debugfs_create(struct inode *dir, struct dentry *dentry, int mode) |
96 | { | 100 | { |
101 | int res; | ||
102 | |||
97 | mode = (mode & S_IALLUGO) | S_IFREG; | 103 | mode = (mode & S_IALLUGO) | S_IFREG; |
98 | return debugfs_mknod(dir, dentry, mode, 0); | 104 | res = debugfs_mknod(dir, dentry, mode, 0); |
105 | if (!res) | ||
106 | fsnotify_create(dir, dentry); | ||
107 | return res; | ||
99 | } | 108 | } |
100 | 109 | ||
101 | static inline int debugfs_positive(struct dentry *dentry) | 110 | static inline int debugfs_positive(struct dentry *dentry) |
@@ -135,7 +144,7 @@ static int debugfs_create_by_name(const char *name, mode_t mode, | |||
135 | * block. A pointer to that is in the struct vfsmount that we | 144 | * block. A pointer to that is in the struct vfsmount that we |
136 | * have around. | 145 | * have around. |
137 | */ | 146 | */ |
138 | if (!parent ) { | 147 | if (!parent) { |
139 | if (debugfs_mount && debugfs_mount->mnt_sb) { | 148 | if (debugfs_mount && debugfs_mount->mnt_sb) { |
140 | parent = debugfs_mount->mnt_sb->s_root; | 149 | parent = debugfs_mount->mnt_sb->s_root; |
141 | } | 150 | } |
@@ -153,6 +162,7 @@ static int debugfs_create_by_name(const char *name, mode_t mode, | |||
153 | error = debugfs_mkdir(parent->d_inode, *dentry, mode); | 162 | error = debugfs_mkdir(parent->d_inode, *dentry, mode); |
154 | else | 163 | else |
155 | error = debugfs_create(parent->d_inode, *dentry, mode); | 164 | error = debugfs_create(parent->d_inode, *dentry, mode); |
165 | dput(*dentry); | ||
156 | } else | 166 | } else |
157 | error = PTR_ERR(*dentry); | 167 | error = PTR_ERR(*dentry); |
158 | mutex_unlock(&parent->d_inode->i_mutex); | 168 | mutex_unlock(&parent->d_inode->i_mutex); |
@@ -197,13 +207,15 @@ struct dentry *debugfs_create_file(const char *name, mode_t mode, | |||
197 | 207 | ||
198 | pr_debug("debugfs: creating file '%s'\n",name); | 208 | pr_debug("debugfs: creating file '%s'\n",name); |
199 | 209 | ||
200 | error = simple_pin_fs(&debug_fs_type, &debugfs_mount, &debugfs_mount_count); | 210 | error = simple_pin_fs(&debug_fs_type, &debugfs_mount, |
211 | &debugfs_mount_count); | ||
201 | if (error) | 212 | if (error) |
202 | goto exit; | 213 | goto exit; |
203 | 214 | ||
204 | error = debugfs_create_by_name(name, mode, parent, &dentry); | 215 | error = debugfs_create_by_name(name, mode, parent, &dentry); |
205 | if (error) { | 216 | if (error) { |
206 | dentry = NULL; | 217 | dentry = NULL; |
218 | simple_release_fs(&debugfs_mount, &debugfs_mount_count); | ||
207 | goto exit; | 219 | goto exit; |
208 | } | 220 | } |
209 | 221 | ||
@@ -262,6 +274,7 @@ EXPORT_SYMBOL_GPL(debugfs_create_dir); | |||
262 | void debugfs_remove(struct dentry *dentry) | 274 | void debugfs_remove(struct dentry *dentry) |
263 | { | 275 | { |
264 | struct dentry *parent; | 276 | struct dentry *parent; |
277 | int ret = 0; | ||
265 | 278 | ||
266 | if (!dentry) | 279 | if (!dentry) |
267 | return; | 280 | return; |
@@ -273,11 +286,19 @@ void debugfs_remove(struct dentry *dentry) | |||
273 | mutex_lock(&parent->d_inode->i_mutex); | 286 | mutex_lock(&parent->d_inode->i_mutex); |
274 | if (debugfs_positive(dentry)) { | 287 | if (debugfs_positive(dentry)) { |
275 | if (dentry->d_inode) { | 288 | if (dentry->d_inode) { |
276 | if (S_ISDIR(dentry->d_inode->i_mode)) | 289 | dget(dentry); |
277 | simple_rmdir(parent->d_inode, dentry); | 290 | if (S_ISDIR(dentry->d_inode->i_mode)) { |
278 | else | 291 | ret = simple_rmdir(parent->d_inode, dentry); |
292 | if (ret) | ||
293 | printk(KERN_ERR | ||
294 | "DebugFS rmdir on %s failed : " | ||
295 | "directory not empty.\n", | ||
296 | dentry->d_name.name); | ||
297 | } else | ||
279 | simple_unlink(parent->d_inode, dentry); | 298 | simple_unlink(parent->d_inode, dentry); |
280 | dput(dentry); | 299 | if (!ret) |
300 | d_delete(dentry); | ||
301 | dput(dentry); | ||
281 | } | 302 | } |
282 | } | 303 | } |
283 | mutex_unlock(&parent->d_inode->i_mutex); | 304 | mutex_unlock(&parent->d_inode->i_mutex); |