/** * Returns the absolute path combining parent and name, assuming that root is at * the configfs scheduler subsystem entry. * * @param parent base config_item * @param name component to catenate to parent's path * * @return pointer to a newly allocated string containing the * absolute path. The path must be freed with put_path. */ static char *get_full_path(struct config_item *parent, const char *name) { size_t parent_len = item_path_length(parent); size_t full_len = parent_len - 1; char *path; if (name) full_len += 1 + strlen(name); path = kmalloc(full_len + 1, GFP_KERNEL); if (!path) return NULL; fill_item_path(parent, path, parent_len); if (name) { path[parent_len - 1] = '/'; strcpy(path + parent_len, name); } else path[parent_len - 1] = '\0'; return path; }
static int configfs_get_target_path(struct config_item * item, struct config_item * target, char *path) { char * s; int depth, size; depth = item_depth(item); size = item_path_length(target) + depth * 3 - 1; if (size > PATH_MAX) return -ENAMETOOLONG; pr_debug("%s: depth = %d, size = %d\n", __func__, depth, size); for (s = path; depth--; s += 3) strcpy(s,"../"); fill_item_path(target, path, size); pr_debug("%s: path = '%s'\n", __func__, path); return 0; }