From: Inga Stotland Date: Tue, 30 Nov 2021 23:14:12 +0000 (-0800) Subject: mesh: Don't log error for false positive mkdir failure X-Git-Tag: submit/tizen/20220313.220938~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=477f37be48752929226bd8ace2a38703e5d92313;p=platform%2Fupstream%2Fbluez.git mesh: Don't log error for false positive mkdir failure When invoking mkdir() for mesh configuration storage, do not report an error if a target directory already exists. Signed-off-by: Anuj Jain Signed-off-by: Ayush Garg --- diff --git a/mesh/keyring.c b/mesh/keyring.c index fdef5d22..767d5873 100644 --- a/mesh/keyring.c +++ b/mesh/keyring.c @@ -51,7 +51,7 @@ static int open_key_file(struct mesh_node *node, const char *key_dir, if (flags & O_CREAT) { snprintf(fname, PATH_MAX, "%s%s", node_path, key_dir); - if (mkdir(fname, 0755) != 0) + if (mkdir(fname, 0755) != 0 && errno != EEXIST) l_error("Failed to create dir(%d): %s", errno, fname); } diff --git a/mesh/rpl.c b/mesh/rpl.c index 37742638..a55dc89f 100644 --- a/mesh/rpl.c +++ b/mesh/rpl.c @@ -258,7 +258,7 @@ void rpl_update(struct mesh_node *node, uint32_t cur) /* Make sure path exists */ snprintf(path, PATH_MAX, "%s%s", node_path, rpl_dir); - if (mkdir(path, 0755) != 0) + if (mkdir(path, 0755) != 0 && errno != EEXIST) l_error("Failed to create dir(%d): %s", errno, path); dir = opendir(path); @@ -296,7 +296,7 @@ bool rpl_init(const char *node_path) return false; snprintf(path, PATH_MAX, "%s%s", node_path, rpl_dir); - if (mkdir(path, 0755) != 0) + if (mkdir(path, 0755) != 0 && errno != EEXIST) l_error("Failed to create dir(%d): %s", errno, path); return true; } diff --git a/mesh/util.c b/mesh/util.c index a45a2938..37c031aa 100644 --- a/mesh/util.c +++ b/mesh/util.c @@ -117,13 +117,13 @@ int create_dir(const char *dir_name) } strncat(dir, prev + 1, next - prev); - if (mkdir(dir, 0755) != 0) + if (mkdir(dir, 0755) != 0 && errno != EEXIST) l_error("Failed to create dir(%d): %s", errno, dir); prev = next; } - if (mkdir(dir_name, 0755) != 0) + if (mkdir(dir_name, 0755) != 0 && errno != EEXIST) l_error("Failed to create dir(%d): %s", errno, dir_name); return 0;