main: create_missing_whiteouts uses datastore

refactor create_missing_whiteouts to use the datastore API so it works
correctly with plugins.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2020-01-08 13:23:58 +01:00
parent efcfb045b4
commit a9c49ec18d
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED

20
main.c
View File

@ -1387,10 +1387,7 @@ load_dir (struct ovl_data *lo, struct ovl_node *n, struct ovl_layer *layer, char
ret = it->ds->file_exists (it, parent_whiteout_path); ret = it->ds->file_exists (it, parent_whiteout_path);
if (ret < 0 && errno != ENOENT && errno != ENOTDIR) if (ret < 0 && errno != ENOENT && errno != ENOTDIR)
{
it->ds->closedir (dp);
return NULL; return NULL;
}
if (ret == 0) if (ret == 0)
break; break;
@ -1530,6 +1527,7 @@ load_dir (struct ovl_data *lo, struct ovl_node *n, struct ovl_layer *layer, char
n->last_layer = it; n->last_layer = it;
stop_lookup = true; stop_lookup = true;
} }
it->ds->closedir (dp);
} }
if (get_timeout (lo) > 0) if (get_timeout (lo) > 0)
@ -1980,28 +1978,20 @@ create_missing_whiteouts (struct ovl_data *lo, struct ovl_node *node, const char
for (l = get_lower_layers (lo); l; l = l->next) for (l = get_lower_layers (lo); l; l = l->next)
{ {
cleanup_dir DIR *dp = NULL; cleanup_dir DIR *dp = NULL;
cleanup_close int cleanup_fd = -1;
cleanup_fd = l->ds->openat (l, from, O_DIRECTORY, 0755); dp = l->ds->opendir (l, from);
if (cleanup_fd < 0) if (dp == NULL)
{ {
if (errno == ENOENT)
continue;
if (errno == ENOTDIR) if (errno == ENOTDIR)
break; break;
if (errno == ENOENT)
continue;
return -1; return -1;
} }
dp = fdopendir (cleanup_fd);
if (dp == NULL)
return -1;
else else
{ {
struct dirent *dent; struct dirent *dent;
cleanup_fd = -1; /* Now owned by dp. */
for (;;) for (;;)
{ {
struct ovl_node key; struct ovl_node key;