It's the only place where it is still used.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
return result;
}
-char **lxc_normalize_path(const char *path)
-{
- char **components;
- size_t components_len = 0;
- size_t pos = 0;
-
- components = lxc_string_split(path, '/');
- if (!components)
- return NULL;
-
- /* resolve '.' and '..' */
- for (pos = 0; pos < components_len;) {
- if (strequal(components[pos], ".") ||
- (strequal(components[pos], "..") && pos == 0)) {
- /* eat this element */
- free(components[pos]);
- memmove(&components[pos], &components[pos + 1],
- sizeof(char *) * (components_len - pos));
- components_len--;
- } else if (strequal(components[pos], "..")) {
- /* eat this and the previous element */
- free(components[pos - 1]);
- free(components[pos]);
- memmove(&components[pos - 1], &components[pos + 1],
- sizeof(char *) * (components_len - pos));
- components_len -= 2;
- pos--;
- } else {
- pos++;
- }
- }
-
- return components;
-}
-
/* taken from systemd */
char *path_simplify(const char *path)
{
const char *haystack);
__hidden extern bool lxc_string_in_array(const char *needle, const char **haystack);
__hidden extern char *lxc_string_join(const char *sep, const char **parts, bool use_as_prefix);
-/*
- * Normalize and split path: Leading and trailing / are removed, multiple
- * / are compactified, .. and . are resolved (.. on the top level is considered
- * identical to .).
- * Examples:
- * / -> { NULL }
- * foo/../bar -> { bar, NULL }
- * ../../ -> { NULL }
- * ./bar/baz/.. -> { bar, NULL }
- * foo//bar -> { foo, bar, NULL }
- */
-__hidden extern char **lxc_normalize_path(const char *path);
-/* remove multiple slashes from the path, e.g. ///foo//bar -> /foo/bar */
-__hidden extern char *lxc_deslashify(const char *path);
__hidden extern char *lxc_append_paths(const char *first, const char *second);
/*
return 0;
}
+static char **lxc_normalize_path(const char *path)
+{
+ char **components;
+ size_t components_len = 0;
+ size_t pos = 0;
+
+ components = lxc_string_split(path, '/');
+ if (!components)
+ return NULL;
+
+ /* resolve '.' and '..' */
+ for (pos = 0; pos < components_len;) {
+ if (strequal(components[pos], ".") ||
+ (strequal(components[pos], "..") && pos == 0)) {
+ /* eat this element */
+ free(components[pos]);
+ memmove(&components[pos], &components[pos + 1],
+ sizeof(char *) * (components_len - pos));
+ components_len--;
+ } else if (strequal(components[pos], "..")) {
+ /* eat this and the previous element */
+ free(components[pos - 1]);
+ free(components[pos]);
+ memmove(&components[pos - 1], &components[pos + 1],
+ sizeof(char *) * (components_len - pos));
+ components_len -= 2;
+ pos--;
+ } else {
+ pos++;
+ }
+ }
+
+ return components;
+}
+
static char *construct_path(char *path, bool as_prefix)
{
char **components = NULL;