diff options
author | Tejun Heo <tj@kernel.org> | 2013-10-24 11:49:11 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-10-29 18:12:07 -0400 |
commit | d1c1459e45944e336a968acce1e459c9effcde47 (patch) | |
tree | 0378046afd671158c2fde7184ee9f851944c395c /fs/sysfs | |
parent | 7eed6ecb0785681892ab1fe47188fc981241cfd0 (diff) |
sysfs: separate out dup filename warning into a separate function
Separate out sysfs_warn_dup() out of sysfs_add_one(). This will help
separating out the core sysfs functionalities into kernfs so that it
can be used by non-sysfs users too.
This doesn't make any functional changes.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/sysfs')
-rw-r--r-- | fs/sysfs/dir.c | 30 | ||||
-rw-r--r-- | fs/sysfs/sysfs.h | 1 |
2 files changed, 20 insertions, 11 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 486238d06021..de47ed32d5c7 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c | |||
@@ -470,6 +470,23 @@ static char *sysfs_pathname(struct sysfs_dirent *sd, char *path) | |||
470 | return path; | 470 | return path; |
471 | } | 471 | } |
472 | 472 | ||
473 | void sysfs_warn_dup(struct sysfs_dirent *parent, const char *name) | ||
474 | { | ||
475 | char *path; | ||
476 | |||
477 | path = kzalloc(PATH_MAX, GFP_KERNEL); | ||
478 | if (path) { | ||
479 | sysfs_pathname(parent, path); | ||
480 | strlcat(path, "/", PATH_MAX); | ||
481 | strlcat(path, name, PATH_MAX); | ||
482 | } | ||
483 | |||
484 | WARN(1, KERN_WARNING "sysfs: cannot create duplicate filename '%s'\n", | ||
485 | path ? path : name); | ||
486 | |||
487 | kfree(path); | ||
488 | } | ||
489 | |||
473 | /** | 490 | /** |
474 | * sysfs_add_one - add sysfs_dirent to parent | 491 | * sysfs_add_one - add sysfs_dirent to parent |
475 | * @acxt: addrm context to use | 492 | * @acxt: addrm context to use |
@@ -497,18 +514,9 @@ int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd, | |||
497 | int ret; | 514 | int ret; |
498 | 515 | ||
499 | ret = __sysfs_add_one(acxt, sd, parent_sd); | 516 | ret = __sysfs_add_one(acxt, sd, parent_sd); |
500 | if (ret == -EEXIST) { | ||
501 | char *path = kzalloc(PATH_MAX, GFP_KERNEL); | ||
502 | WARN(1, KERN_WARNING | ||
503 | "sysfs: cannot create duplicate filename '%s'\n", | ||
504 | (path == NULL) ? sd->s_name | ||
505 | : (sysfs_pathname(parent_sd, path), | ||
506 | strlcat(path, "/", PATH_MAX), | ||
507 | strlcat(path, sd->s_name, PATH_MAX), | ||
508 | path)); | ||
509 | kfree(path); | ||
510 | } | ||
511 | 517 | ||
518 | if (ret == -EEXIST) | ||
519 | sysfs_warn_dup(parent_sd, sd->s_name); | ||
512 | return ret; | 520 | return ret; |
513 | } | 521 | } |
514 | 522 | ||
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h index 8d3dc1ddb546..05d063fe69c7 100644 --- a/fs/sysfs/sysfs.h +++ b/fs/sysfs/sysfs.h | |||
@@ -168,6 +168,7 @@ extern const struct inode_operations sysfs_dir_inode_operations; | |||
168 | struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd); | 168 | struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd); |
169 | void sysfs_put_active(struct sysfs_dirent *sd); | 169 | void sysfs_put_active(struct sysfs_dirent *sd); |
170 | void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt); | 170 | void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt); |
171 | void sysfs_warn_dup(struct sysfs_dirent *parent, const char *name); | ||
171 | int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd, | 172 | int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd, |
172 | struct sysfs_dirent *parent_sd); | 173 | struct sysfs_dirent *parent_sd); |
173 | int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd, | 174 | int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd, |