diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-01-25 15:10:32 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-01-25 16:52:53 -0500 |
commit | 77b3da6e3232d3b4d4b8addb4b05799fe98f3bf8 (patch) | |
tree | 849f5a1670e36b6b0a4365edc3f7779aa8261db2 /fs/debugfs | |
parent | 5233e31191af661389a4f5b060873bfcb155c828 (diff) |
new primitive: debugfs_create_automount()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/debugfs')
-rw-r--r-- | fs/debugfs/inode.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 1219dff8e18f..957c40ce09f6 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c | |||
@@ -175,6 +175,18 @@ static const struct super_operations debugfs_super_operations = { | |||
175 | .show_options = debugfs_show_options, | 175 | .show_options = debugfs_show_options, |
176 | }; | 176 | }; |
177 | 177 | ||
178 | static struct vfsmount *debugfs_automount(struct path *path) | ||
179 | { | ||
180 | struct vfsmount *(*f)(void *); | ||
181 | f = (struct vfsmount *(*)(void *))path->dentry->d_fsdata; | ||
182 | return f(path->dentry->d_inode->i_private); | ||
183 | } | ||
184 | |||
185 | static const struct dentry_operations debugfs_dops = { | ||
186 | .d_delete = always_delete_dentry, | ||
187 | .d_automount = debugfs_automount, | ||
188 | }; | ||
189 | |||
178 | static int debug_fill_super(struct super_block *sb, void *data, int silent) | 190 | static int debug_fill_super(struct super_block *sb, void *data, int silent) |
179 | { | 191 | { |
180 | static struct tree_descr debug_files[] = {{""}}; | 192 | static struct tree_descr debug_files[] = {{""}}; |
@@ -199,6 +211,7 @@ static int debug_fill_super(struct super_block *sb, void *data, int silent) | |||
199 | goto fail; | 211 | goto fail; |
200 | 212 | ||
201 | sb->s_op = &debugfs_super_operations; | 213 | sb->s_op = &debugfs_super_operations; |
214 | sb->s_d_op = &debugfs_dops; | ||
202 | 215 | ||
203 | debugfs_apply_options(sb); | 216 | debugfs_apply_options(sb); |
204 | 217 | ||
@@ -368,6 +381,41 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) | |||
368 | EXPORT_SYMBOL_GPL(debugfs_create_dir); | 381 | EXPORT_SYMBOL_GPL(debugfs_create_dir); |
369 | 382 | ||
370 | /** | 383 | /** |
384 | * debugfs_create_automount - create automount point in the debugfs filesystem | ||
385 | * @name: a pointer to a string containing the name of the file to create. | ||
386 | * @parent: a pointer to the parent dentry for this file. This should be a | ||
387 | * directory dentry if set. If this parameter is NULL, then the | ||
388 | * file will be created in the root of the debugfs filesystem. | ||
389 | * @f: function to be called when pathname resolution steps on that one. | ||
390 | * @data: opaque argument to pass to f(). | ||
391 | * | ||
392 | * @f should return what ->d_automount() would. | ||
393 | */ | ||
394 | struct dentry *debugfs_create_automount(const char *name, | ||
395 | struct dentry *parent, | ||
396 | struct vfsmount *(*f)(void *), | ||
397 | void *data) | ||
398 | { | ||
399 | struct dentry *dentry = start_creating(name, parent); | ||
400 | struct inode *inode; | ||
401 | |||
402 | if (IS_ERR(dentry)) | ||
403 | return NULL; | ||
404 | |||
405 | inode = debugfs_get_inode(dentry->d_sb); | ||
406 | if (unlikely(!inode)) | ||
407 | return failed_creating(dentry); | ||
408 | |||
409 | inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO; | ||
410 | inode->i_flags |= S_AUTOMOUNT; | ||
411 | inode->i_private = data; | ||
412 | dentry->d_fsdata = (void *)f; | ||
413 | d_instantiate(dentry, inode); | ||
414 | return end_creating(dentry); | ||
415 | } | ||
416 | EXPORT_SYMBOL(debugfs_create_automount); | ||
417 | |||
418 | /** | ||
371 | * debugfs_create_symlink- create a symbolic link in the debugfs filesystem | 419 | * debugfs_create_symlink- create a symbolic link in the debugfs filesystem |
372 | * @name: a pointer to a string containing the name of the symbolic link to | 420 | * @name: a pointer to a string containing the name of the symbolic link to |
373 | * create. | 421 | * create. |