diff options
Diffstat (limited to 'fs/debugfs/inode.c')
-rw-r--r-- | fs/debugfs/inode.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 1e444fe1f778..042b688ed124 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c | |||
@@ -2,13 +2,16 @@ | |||
2 | /* | 2 | /* |
3 | * inode.c - part of debugfs, a tiny little debug file system | 3 | * inode.c - part of debugfs, a tiny little debug file system |
4 | * | 4 | * |
5 | * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com> | 5 | * Copyright (C) 2004,2019 Greg Kroah-Hartman <greg@kroah.com> |
6 | * Copyright (C) 2004 IBM Inc. | 6 | * Copyright (C) 2004 IBM Inc. |
7 | * Copyright (C) 2019 Linux Foundation <gregkh@linuxfoundation.org> | ||
7 | * | 8 | * |
8 | * debugfs is for people to use instead of /proc or /sys. | 9 | * debugfs is for people to use instead of /proc or /sys. |
9 | * See ./Documentation/core-api/kernel-api.rst for more details. | 10 | * See ./Documentation/core-api/kernel-api.rst for more details. |
10 | */ | 11 | */ |
11 | 12 | ||
13 | #define pr_fmt(fmt) "debugfs: " fmt | ||
14 | |||
12 | #include <linux/module.h> | 15 | #include <linux/module.h> |
13 | #include <linux/fs.h> | 16 | #include <linux/fs.h> |
14 | #include <linux/mount.h> | 17 | #include <linux/mount.h> |
@@ -285,15 +288,17 @@ static struct dentry *start_creating(const char *name, struct dentry *parent) | |||
285 | struct dentry *dentry; | 288 | struct dentry *dentry; |
286 | int error; | 289 | int error; |
287 | 290 | ||
288 | pr_debug("debugfs: creating file '%s'\n",name); | 291 | pr_debug("creating file '%s'\n", name); |
289 | 292 | ||
290 | if (IS_ERR(parent)) | 293 | if (IS_ERR(parent)) |
291 | return parent; | 294 | return parent; |
292 | 295 | ||
293 | error = simple_pin_fs(&debug_fs_type, &debugfs_mount, | 296 | error = simple_pin_fs(&debug_fs_type, &debugfs_mount, |
294 | &debugfs_mount_count); | 297 | &debugfs_mount_count); |
295 | if (error) | 298 | if (error) { |
299 | pr_err("Unable to pin filesystem for file '%s'\n", name); | ||
296 | return ERR_PTR(error); | 300 | return ERR_PTR(error); |
301 | } | ||
297 | 302 | ||
298 | /* If the parent is not specified, we create it in the root. | 303 | /* If the parent is not specified, we create it in the root. |
299 | * We need the root dentry to do this, which is in the super | 304 | * We need the root dentry to do this, which is in the super |
@@ -306,6 +311,12 @@ static struct dentry *start_creating(const char *name, struct dentry *parent) | |||
306 | inode_lock(d_inode(parent)); | 311 | inode_lock(d_inode(parent)); |
307 | dentry = lookup_one_len(name, parent, strlen(name)); | 312 | dentry = lookup_one_len(name, parent, strlen(name)); |
308 | if (!IS_ERR(dentry) && d_really_is_positive(dentry)) { | 313 | if (!IS_ERR(dentry) && d_really_is_positive(dentry)) { |
314 | if (d_is_dir(dentry)) | ||
315 | pr_err("Directory '%s' with parent '%s' already present!\n", | ||
316 | name, parent->d_name.name); | ||
317 | else | ||
318 | pr_err("File '%s' in directory '%s' already present!\n", | ||
319 | name, parent->d_name.name); | ||
309 | dput(dentry); | 320 | dput(dentry); |
310 | dentry = ERR_PTR(-EEXIST); | 321 | dentry = ERR_PTR(-EEXIST); |
311 | } | 322 | } |
@@ -349,8 +360,11 @@ static struct dentry *__debugfs_create_file(const char *name, umode_t mode, | |||
349 | return dentry; | 360 | return dentry; |
350 | 361 | ||
351 | inode = debugfs_get_inode(dentry->d_sb); | 362 | inode = debugfs_get_inode(dentry->d_sb); |
352 | if (unlikely(!inode)) | 363 | if (unlikely(!inode)) { |
364 | pr_err("out of free dentries, can not create file '%s'\n", | ||
365 | name); | ||
353 | return failed_creating(dentry); | 366 | return failed_creating(dentry); |
367 | } | ||
354 | 368 | ||
355 | inode->i_mode = mode; | 369 | inode->i_mode = mode; |
356 | inode->i_private = data; | 370 | inode->i_private = data; |
@@ -511,8 +525,11 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) | |||
511 | return dentry; | 525 | return dentry; |
512 | 526 | ||
513 | inode = debugfs_get_inode(dentry->d_sb); | 527 | inode = debugfs_get_inode(dentry->d_sb); |
514 | if (unlikely(!inode)) | 528 | if (unlikely(!inode)) { |
529 | pr_err("out of free dentries, can not create directory '%s'\n", | ||
530 | name); | ||
515 | return failed_creating(dentry); | 531 | return failed_creating(dentry); |
532 | } | ||
516 | 533 | ||
517 | inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO; | 534 | inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO; |
518 | inode->i_op = &simple_dir_inode_operations; | 535 | inode->i_op = &simple_dir_inode_operations; |
@@ -550,8 +567,11 @@ struct dentry *debugfs_create_automount(const char *name, | |||
550 | return dentry; | 567 | return dentry; |
551 | 568 | ||
552 | inode = debugfs_get_inode(dentry->d_sb); | 569 | inode = debugfs_get_inode(dentry->d_sb); |
553 | if (unlikely(!inode)) | 570 | if (unlikely(!inode)) { |
571 | pr_err("out of free dentries, can not create automount '%s'\n", | ||
572 | name); | ||
554 | return failed_creating(dentry); | 573 | return failed_creating(dentry); |
574 | } | ||
555 | 575 | ||
556 | make_empty_dir_inode(inode); | 576 | make_empty_dir_inode(inode); |
557 | inode->i_flags |= S_AUTOMOUNT; | 577 | inode->i_flags |= S_AUTOMOUNT; |
@@ -606,6 +626,8 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, | |||
606 | 626 | ||
607 | inode = debugfs_get_inode(dentry->d_sb); | 627 | inode = debugfs_get_inode(dentry->d_sb); |
608 | if (unlikely(!inode)) { | 628 | if (unlikely(!inode)) { |
629 | pr_err("out of free dentries, can not create symlink '%s'\n", | ||
630 | name); | ||
609 | kfree(link); | 631 | kfree(link); |
610 | return failed_creating(dentry); | 632 | return failed_creating(dentry); |
611 | } | 633 | } |