diff options
Diffstat (limited to 'fs/sysfs/symlink.c')
| -rw-r--r-- | fs/sysfs/symlink.c | 38 | 
1 files changed, 38 insertions, 0 deletions
| diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c index c5eff49fa41b..1b9a3a1e8a17 100644 --- a/fs/sysfs/symlink.c +++ b/fs/sysfs/symlink.c | |||
| @@ -123,6 +123,44 @@ void sysfs_remove_link(struct kobject * kobj, const char * name) | |||
| 123 | sysfs_hash_and_remove(parent_sd, name); | 123 | sysfs_hash_and_remove(parent_sd, name); | 
| 124 | } | 124 | } | 
| 125 | 125 | ||
| 126 | /** | ||
| 127 | * sysfs_rename_link - rename symlink in object's directory. | ||
| 128 | * @kobj: object we're acting for. | ||
| 129 | * @targ: object we're pointing to. | ||
| 130 | * @old: previous name of the symlink. | ||
| 131 | * @new: new name of the symlink. | ||
| 132 | * | ||
| 133 | * A helper function for the common rename symlink idiom. | ||
| 134 | */ | ||
| 135 | int sysfs_rename_link(struct kobject *kobj, struct kobject *targ, | ||
| 136 | const char *old, const char *new) | ||
| 137 | { | ||
| 138 | struct sysfs_dirent *parent_sd, *sd = NULL; | ||
| 139 | int result; | ||
| 140 | |||
| 141 | if (!kobj) | ||
| 142 | parent_sd = &sysfs_root; | ||
| 143 | else | ||
| 144 | parent_sd = kobj->sd; | ||
| 145 | |||
| 146 | result = -ENOENT; | ||
| 147 | sd = sysfs_get_dirent(parent_sd, old); | ||
| 148 | if (!sd) | ||
| 149 | goto out; | ||
| 150 | |||
| 151 | result = -EINVAL; | ||
| 152 | if (sysfs_type(sd) != SYSFS_KOBJ_LINK) | ||
| 153 | goto out; | ||
| 154 | if (sd->s_symlink.target_sd->s_dir.kobj != targ) | ||
| 155 | goto out; | ||
| 156 | |||
| 157 | result = sysfs_rename(sd, parent_sd, new); | ||
| 158 | |||
| 159 | out: | ||
| 160 | sysfs_put(sd); | ||
| 161 | return result; | ||
| 162 | } | ||
| 163 | |||
| 126 | static int sysfs_get_target_path(struct sysfs_dirent *parent_sd, | 164 | static int sysfs_get_target_path(struct sysfs_dirent *parent_sd, | 
| 127 | struct sysfs_dirent *target_sd, char *path) | 165 | struct sysfs_dirent *target_sd, char *path) | 
| 128 | { | 166 | { | 
