Check that either VAR_DIR or ALT_DIR is actually writable before selecting it. Signed-off-by: Luca Berra <bluca@xxxxxxxxxx> --- mdmon.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mdmon.c b/mdmon.c index 11b4f32..57fd492 100644 --- a/mdmon.c +++ b/mdmon.c @@ -480,9 +480,9 @@ static int mdmon(char *devname, int devnum, int must_fork, int takeover) */ if (victim > 0) remove_pidfile(devname); - if (mkdir(VAR_RUN, 0600) >= 0 || errno == EEXIST) + if (mkdir(VAR_RUN, 0600) >= 0 || (errno == EEXIST && access(VAR_RUN, W_OK) >= 0)) pid_dir = VAR_RUN; - else if (mkdir(ALT_RUN, 0600) >= 0 || errno == EEXIST) + else if (mkdir(ALT_RUN, 0600) >= 0 || (errno == EEXIST && access(ALT_RUN, W_OK) >= 0)) pid_dir = ALT_RUN; else { fprintf(stderr, "mdmon: Neither %s nor %s are writable\n" -- 1.7.0 -- Luca Berra -- bluca@xxxxxxxxxx Communication Media & Services S.r.l. /"\ \ / ASCII RIBBON CAMPAIGN X AGAINST HTML MAIL / \ -- To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html