From 8749d0dfe3d865461bd3696ea729af5ae4a8e490 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Thu, 21 May 2026 00:20:42 +0200 Subject: [PATCH] Handle the cases of directory already create by another process --- cmdline/check.c | 2 +- cmdline/support.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmdline/check.c b/cmdline/check.c index 361f8afa..53a8fb89 100644 --- a/cmdline/check.c +++ b/cmdline/check.c @@ -1880,7 +1880,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna /* create it */ ret = mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); - if (ret != 0) { + if (ret != 0 && errno != EEXIST) { /* LCOV_EXCL_START */ log_fatal(errno, "Error creating directory '%s%s'. %s.\n", disk->dir, dir->sub, strerror(errno)); log_tag("dir_%s:%u:%s:%s: Create directory error. %s.\n", es(errno), i, disk->name, esc_tag(dir->sub, esc_buffer), strerror(errno)); diff --git a/cmdline/support.c b/cmdline/support.c index 62fd8b72..a46ada0b 100644 --- a/cmdline/support.c +++ b/cmdline/support.c @@ -1209,7 +1209,8 @@ int mkancestor(const char* file) } /* create it */ - if (mkdir(dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0) { + int ret = mkdir(dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); + if (ret != 0 && errno != EEXIST) { /* LCOV_EXCL_START */ log_fatal(errno, "Error creating directory '%s'. %s.\n", dir, strerror(errno)); return -1;