ctdb-common: Improve error handling in run_event
authorAmitay Isaacs <amitay@gmail.com>
Thu, 10 May 2018 06:50:35 +0000 (16:50 +1000)
committerMartin Schwenke <martins@samba.org>
Tue, 5 Jun 2018 20:34:19 +0000 (22:34 +0200)
If event script directory does not exist, then return ENOTDIR.  If a
directory gets removed at runtime, report error from scandir in
get_script_list().

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/common/run_event.c

index 9487d2d4cf72d85a98e1924dff17e825bbf83350..9ff18707715199ae28f143e4f21e2029fde546fd 100644 (file)
@@ -70,7 +70,6 @@ static int get_script_list(TALLOC_CTX *mem_ctx,
                                  script_dir, ret);
                }
                *out = NULL;
-               ret = 0;
                goto done;
        }
 
@@ -296,7 +295,7 @@ int run_event_init(TALLOC_CTX *mem_ctx, struct run_proc_context *run_proc_ctx,
 
        if (! S_ISDIR(st.st_mode)) {
                talloc_free(run_ctx);
-               return EINVAL;
+               return ENOTDIR;
        }
 
        run_ctx->script_dir = talloc_strdup(run_ctx, script_dir);