fuse-overlayfs: fix order of lower layers

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2018-07-18 15:35:56 +02:00
parent 5b29022bd3
commit 24dd39ee72
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED

21
main.c
View File

@ -946,6 +946,7 @@ static struct ovl_layer *
read_dirs (char *path, bool low, struct ovl_layer *layers)
{
char *buf = NULL, *saveptr = NULL, *it;
struct ovl_layer *last;
if (path == NULL)
return NULL;
@ -954,6 +955,10 @@ read_dirs (char *path, bool low, struct ovl_layer *layers)
if (buf == NULL)
return NULL;
last = layers;
while (last && last->next)
last = last->next;
for (it = strtok_r (path, ":", &saveptr); it; it = strtok_r (NULL, ":", &saveptr))
{
char full_path[PATH_MAX + 1];
@ -987,9 +992,25 @@ read_dirs (char *path, bool low, struct ovl_layer *layers)
}
l->low = low;
if (low)
{
if (last == NULL)
{
last = layers = l;
l->next = NULL;
}
else
{
last->next = l;
last = l;
}
}
else
{
l->next = layers;
layers = l;
}
}
free (buf);
return layers;
}