summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2018-08-10 11:14:54 +0800
committerJeremy Kerr <jk@ozlabs.org>2018-08-10 11:14:54 +0800
commit9b00deb26b4cd03bc1e33afe7a5e2c5e0e87f06c (patch)
tree657d11b13154a402d489da4bdd42b1e3a43f156c
parentcaf6bb9c4b95710dd5b184894e94a183fe728ef4 (diff)
downloadjsnbd-9b00deb26b4cd03bc1e33afe7a5e2c5e0e87f06c.tar.gz
jsnbd-9b00deb26b4cd03bc1e33afe7a5e2c5e0e87f06c.zip
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>
-rw-r--r--nbd-proxy.c10
1 files changed, 7 insertions, 3 deletions
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_hook(struct ctx *ctx,
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 @@ static int run_state_hooks(struct ctx *ctx, const char *action)
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 @@ static int run_state_hooks(struct ctx *ctx, const char *action)
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)
OpenPOWER on IntegriCloud