diff options
Diffstat (limited to 'fs/sysfs/dir.c')
| -rw-r--r-- | fs/sysfs/dir.c | 44 |
1 files changed, 13 insertions, 31 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index ee0d761c3179..0b45ff42f374 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c | |||
| @@ -19,39 +19,18 @@ | |||
| 19 | 19 | ||
| 20 | DEFINE_SPINLOCK(sysfs_symlink_target_lock); | 20 | DEFINE_SPINLOCK(sysfs_symlink_target_lock); |
| 21 | 21 | ||
| 22 | /** | ||
| 23 | * sysfs_pathname - return full path to sysfs dirent | ||
| 24 | * @kn: kernfs_node whose path we want | ||
| 25 | * @path: caller allocated buffer of size PATH_MAX | ||
| 26 | * | ||
| 27 | * Gives the name "/" to the sysfs_root entry; any path returned | ||
| 28 | * is relative to wherever sysfs is mounted. | ||
| 29 | */ | ||
| 30 | static char *sysfs_pathname(struct kernfs_node *kn, char *path) | ||
| 31 | { | ||
| 32 | if (kn->parent) { | ||
| 33 | sysfs_pathname(kn->parent, path); | ||
| 34 | strlcat(path, "/", PATH_MAX); | ||
| 35 | } | ||
| 36 | strlcat(path, kn->name, PATH_MAX); | ||
| 37 | return path; | ||
| 38 | } | ||
| 39 | |||
| 40 | void sysfs_warn_dup(struct kernfs_node *parent, const char *name) | 22 | void sysfs_warn_dup(struct kernfs_node *parent, const char *name) |
| 41 | { | 23 | { |
| 42 | char *path; | 24 | char *buf, *path = NULL; |
| 43 | 25 | ||
| 44 | path = kzalloc(PATH_MAX, GFP_KERNEL); | 26 | buf = kzalloc(PATH_MAX, GFP_KERNEL); |
| 45 | if (path) { | 27 | if (buf) |
| 46 | sysfs_pathname(parent, path); | 28 | path = kernfs_path(parent, buf, PATH_MAX); |
| 47 | strlcat(path, "/", PATH_MAX); | ||
| 48 | strlcat(path, name, PATH_MAX); | ||
| 49 | } | ||
| 50 | 29 | ||
| 51 | WARN(1, KERN_WARNING "sysfs: cannot create duplicate filename '%s'\n", | 30 | WARN(1, KERN_WARNING "sysfs: cannot create duplicate filename '%s/%s'\n", |
| 52 | path ? path : name); | 31 | path, name); |
| 53 | 32 | ||
| 54 | kfree(path); | 33 | kfree(buf); |
| 55 | } | 34 | } |
| 56 | 35 | ||
| 57 | /** | 36 | /** |
| @@ -122,9 +101,13 @@ void sysfs_remove_dir(struct kobject *kobj) | |||
| 122 | int sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name, | 101 | int sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name, |
| 123 | const void *new_ns) | 102 | const void *new_ns) |
| 124 | { | 103 | { |
| 125 | struct kernfs_node *parent = kobj->sd->parent; | 104 | struct kernfs_node *parent; |
| 105 | int ret; | ||
| 126 | 106 | ||
| 127 | return kernfs_rename_ns(kobj->sd, parent, new_name, new_ns); | 107 | parent = kernfs_get_parent(kobj->sd); |
| 108 | ret = kernfs_rename_ns(kobj->sd, parent, new_name, new_ns); | ||
| 109 | kernfs_put(parent); | ||
| 110 | return ret; | ||
| 128 | } | 111 | } |
| 129 | 112 | ||
| 130 | int sysfs_move_dir_ns(struct kobject *kobj, struct kobject *new_parent_kobj, | 113 | int sysfs_move_dir_ns(struct kobject *kobj, struct kobject *new_parent_kobj, |
| @@ -133,7 +116,6 @@ int sysfs_move_dir_ns(struct kobject *kobj, struct kobject *new_parent_kobj, | |||
| 133 | struct kernfs_node *kn = kobj->sd; | 116 | struct kernfs_node *kn = kobj->sd; |
| 134 | struct kernfs_node *new_parent; | 117 | struct kernfs_node *new_parent; |
| 135 | 118 | ||
| 136 | BUG_ON(!kn->parent); | ||
| 137 | new_parent = new_parent_kobj && new_parent_kobj->sd ? | 119 | new_parent = new_parent_kobj && new_parent_kobj->sd ? |
| 138 | new_parent_kobj->sd : sysfs_root_kn; | 120 | new_parent_kobj->sd : sysfs_root_kn; |
| 139 | 121 | ||
