nbd-proxy: clear errors from checking hook presence
We don't want to report an error if a hook is inacessable (and is the
last hook we check), so clear rc in these conditions.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
diff --git a/nbd-proxy.c b/nbd-proxy.c
index 6ecc120..84702b4 100644
--- a/nbd-proxy.c
+++ b/nbd-proxy.c
@@ -410,8 +410,8 @@
static int run_state_hooks(struct ctx *ctx, const char *action)
{
struct dirent *dirent;
- int rc;
DIR *dir;
+ int rc;
dir = opendir(state_hook_path);
if (!dir)
@@ -427,8 +427,10 @@
continue;
rc = fstatat(dirfd(dir), dirent->d_name, &statbuf, 0);
- if (rc)
+ if (rc) {
+ rc = 0;
continue;
+ }
if (!(S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode)))
continue;
@@ -437,8 +439,10 @@
continue;
rc = join_paths(state_hook_path, dirent->d_name, full_path);
- if (rc)
+ if (rc) {
+ rc = 0;
continue;
+ }
rc = run_state_hook(ctx, full_path, dirent->d_name, action);
if (rc)