]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Monitor: Allow no PID in check_one_sharer()
authorMateusz Kusiak <mateusz.kusiak@intel.com>
Wed, 28 Feb 2024 15:37:20 +0000 (16:37 +0100)
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Thu, 29 Feb 2024 13:06:28 +0000 (14:06 +0100)
Commit 5fb5479ad100 ("Monitor: open file before check in
check_one_sharer()") introduced a regression that prohibits monitor
from starting if PID file does not exist.

Add check for no PID file.
Add missing fclose().

Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Monitor.c

index 7cee95d4487ab89bb356c50e74712566079c95c6..9be2b5287a1ad00f3c2cc0045c7d6f524f9fe9f0 100644 (file)
--- a/Monitor.c
+++ b/Monitor.c
@@ -453,12 +453,17 @@ static int check_one_sharer(int scan)
 
        fp = fopen(AUTOREBUILD_PID_PATH, "r");
        if (!fp) {
+               /* PID file does not exist */
+               if (errno == ENOENT)
+                       return 0;
+
                pr_err("Cannot open %s file.\n", AUTOREBUILD_PID_PATH);
                return 2;
        }
 
        if (!is_file(AUTOREBUILD_PID_PATH)) {
                pr_err("%s is not a regular file.\n", AUTOREBUILD_PID_PATH);
+               fclose(fp);
                return 2;
        }