summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-10-24 11:49:11 -0400
committerPawel Osmialowski <p.osmialowsk@mcdsrvbld02.digital.local>2015-03-27 18:13:13 +0100
commit5f69472e331e4a02f1c7dc5a23070093ddb7d2d4 (patch)
treed78e19ff3e04d103de9ff7cd5f6d8910d61a9823
parente50db6ca1569ad9292167295d32fbd58334a5cf6 (diff)
downloadlinux-3.10-5f69472e331e4a02f1c7dc5a23070093ddb7d2d4.tar.gz
linux-3.10-5f69472e331e4a02f1c7dc5a23070093ddb7d2d4.tar.bz2
linux-3.10-5f69472e331e4a02f1c7dc5a23070093ddb7d2d4.zip
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>
-rw-r--r--fs/sysfs/dir.c30
-rw-r--r--fs/sysfs/sysfs.h1
2 files changed, 20 insertions, 11 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index bd33287a1d0..568e562fcf4 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -471,6 +471,23 @@ static char *sysfs_pathname(struct sysfs_dirent *sd, char *path)
return path;
}
+void sysfs_warn_dup(struct sysfs_dirent *parent, const char *name)
+{
+ char *path;
+
+ path = kzalloc(PATH_MAX, GFP_KERNEL);
+ if (path) {
+ sysfs_pathname(parent, path);
+ strlcat(path, "/", PATH_MAX);
+ strlcat(path, name, PATH_MAX);
+ }
+
+ WARN(1, KERN_WARNING "sysfs: cannot create duplicate filename '%s'\n",
+ path ? path : name);
+
+ kfree(path);
+}
+
/**
* sysfs_add_one - add sysfs_dirent to parent
* @acxt: addrm context to use
@@ -498,18 +515,9 @@ int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd,
int ret;
ret = __sysfs_add_one(acxt, sd, parent_sd);
- if (ret == -EEXIST) {
- char *path = kzalloc(PATH_MAX, GFP_KERNEL);
- WARN(1, KERN_WARNING
- "sysfs: cannot create duplicate filename '%s'\n",
- (path == NULL) ? sd->s_name
- : (sysfs_pathname(parent_sd, path),
- strlcat(path, "/", PATH_MAX),
- strlcat(path, sd->s_name, PATH_MAX),
- path));
- kfree(path);
- }
+ if (ret == -EEXIST)
+ sysfs_warn_dup(parent_sd, sd->s_name);
return ret;
}
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 4d131d0b6df..87e45224ef1 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -179,6 +179,7 @@ extern const struct inode_operations sysfs_dir_inode_operations;
struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd);
void sysfs_put_active(struct sysfs_dirent *sd);
void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt);
+void sysfs_warn_dup(struct sysfs_dirent *parent, const char *name);
int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd,
struct sysfs_dirent *parent_sd);
int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd,