28 #include <linux/module.h>
30 #include <linux/slab.h>
46 static int item_path_length(
struct config_item * item)
51 length +=
strlen(config_item_name(p)) + 1;
67 strncpy(buffer + length,config_item_name(p),cur);
68 *(buffer + --
length) =
'/';
72 static int create_link(
struct config_item *parent_item,
87 spin_lock(&configfs_dirent_lock);
89 spin_unlock(&configfs_dirent_lock);
95 spin_unlock(&configfs_dirent_lock);
99 spin_lock(&configfs_dirent_lock);
101 spin_unlock(&configfs_dirent_lock);
112 static int get_target(
const char *symname,
struct path *
path,
119 if (path->
dentry->d_sb == sb) {
120 *target = configfs_get_config_item(path->
dentry);
153 parent_item = configfs_get_config_item(dentry->
d_parent);
161 ret = get_target(symname, &path, &target_item, dentry->
d_sb);
165 ret = type->
ct_item_ops->allow_link(parent_item, target_item);
168 ret = create_link(parent_item, target_item, dentry);
199 parent_item = configfs_get_config_item(dentry->
d_parent);
241 depth = item_depth(item);
242 size = item_path_length(target) + depth * 3 - 1;
246 pr_debug(
"%s: depth = %d, size = %d\n", __func__, depth, size);
248 for (s = path; depth--; s += 3)
251 fill_item_path(target, path, size);
252 pr_debug(
"%s: path = '%s'\n", __func__, path);
257 static int configfs_getlink(
struct dentry *dentry,
char * path)
262 item = configfs_get_config_item(dentry->
d_parent);
266 target_item = configfs_get_config_item(dentry);
273 error = configfs_get_target_path(item, target_item, path);
282 static void *configfs_follow_link(
struct dentry *dentry,
struct nameidata *nd)
288 error = configfs_getlink(dentry, (
char *)page);
290 nd_set_link(nd, (
char *)page);
295 nd_set_link(nd, ERR_PTR(error));
299 static void configfs_put_link(
struct dentry *dentry,
struct nameidata *nd,
303 unsigned long page = (
unsigned long)cookie;
309 .follow_link = configfs_follow_link,
311 .put_link = configfs_put_link,