From b29a8f1587f6d520a3acdee646d8c2c2ea2632b7 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Wed, 8 Jan 2020 13:22:18 +0100 Subject: [PATCH 1/3] main: force a dir reload after a move if the directory was moved, invalidate its cache and force a reload. Closes: https://github.com/containers/fuse-overlayfs/issues/160 Signed-off-by: Giuseppe Scrivano --- main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.c b/main.c index fcf4698..c7f3d37 100644 --- a/main.c +++ b/main.c @@ -4176,6 +4176,8 @@ ovl_rename_direct (fuse_req_t req, fuse_ino_t parent, const char *name, if (update_paths (node) < 0) goto error; + node->loaded = 0; + ret = 0; goto cleanup; From efcfb045b41ee3ba9b80e6eb10d5846b3c771535 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Wed, 8 Jan 2020 13:23:14 +0100 Subject: [PATCH 2/3] main: skip whiteouts file when creating missing ones do not attempt to create a whiteout if the file itself is already a whiteout. Signed-off-by: Giuseppe Scrivano --- main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.c b/main.c index c7f3d37..6fafd73 100644 --- a/main.c +++ b/main.c @@ -2021,6 +2021,8 @@ create_missing_whiteouts (struct ovl_data *lo, struct ovl_node *node, const char continue; if (strcmp (dent->d_name, "..") == 0) continue; + if (has_prefix (dent->d_name, ".wh.")) + continue; node_set_name (&key, (char *) dent->d_name); From a9c49ec18dcf12fc3962606567aae4ab6b6076ac Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Wed, 8 Jan 2020 13:23:58 +0100 Subject: [PATCH 3/3] 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 --- main.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/main.c b/main.c index 6fafd73..4064fc2 100644 --- a/main.c +++ b/main.c @@ -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); if (ret < 0 && errno != ENOENT && errno != ENOTDIR) - { - it->ds->closedir (dp); - return NULL; - } + return NULL; if (ret == 0) break; @@ -1530,6 +1527,7 @@ load_dir (struct ovl_data *lo, struct ovl_node *n, struct ovl_layer *layer, char n->last_layer = it; stop_lookup = true; } + it->ds->closedir (dp); } 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) { cleanup_dir DIR *dp = NULL; - cleanup_close int cleanup_fd = -1; - cleanup_fd = l->ds->openat (l, from, O_DIRECTORY, 0755); - if (cleanup_fd < 0) + dp = l->ds->opendir (l, from); + if (dp == NULL) { - if (errno == ENOENT) - continue; if (errno == ENOTDIR) break; - + if (errno == ENOENT) + continue; return -1; } - - dp = fdopendir (cleanup_fd); - if (dp == NULL) - return -1; else { struct dirent *dent; - cleanup_fd = -1; /* Now owned by dp. */ - for (;;) { struct ovl_node key;