diff mbox series

[BlueZ] mesh: Don't log error for false positive mkdir failure

Message ID 20211130231412.97437-1-inga.stotland@intel.com
State New
Headers show
Series [BlueZ] mesh: Don't log error for false positive mkdir failure | expand

Commit Message

Inga Stotland Nov. 30, 2021, 11:14 p.m. UTC
When invoking mkdir() for mesh configuration storage, do not
report an error if a target directory already exists.
---
 mesh/keyring.c | 2 +-
 mesh/rpl.c     | 4 ++--
 mesh/util.c    | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

Comments

bluez.test.bot@gmail.com Nov. 30, 2021, 11:38 p.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=588207

---Test result---

Test Summary:
CheckPatch                    PASS      1.33 seconds
GitLint                       PASS      0.89 seconds
Prep - Setup ELL              PASS      52.68 seconds
Build - Prep                  PASS      0.44 seconds
Build - Configure             PASS      9.91 seconds
Build - Make                  PASS      220.95 seconds
Make Check                    PASS      10.23 seconds
Make Distcheck                PASS      266.36 seconds
Build w/ext ELL - Configure   PASS      10.03 seconds
Build w/ext ELL - Make        PASS      208.33 seconds



---
Regards,
Linux Bluetooth
Brian Gix Dec. 6, 2021, 6:32 p.m. UTC | #2
Applied, Thanks.

On Tue, 2021-11-30 at 15:14 -0800, Inga Stotland wrote:
> When invoking mkdir() for mesh configuration storage, do not
> report an error if a target directory already exists.
> ---
>  mesh/keyring.c | 2 +-
>  mesh/rpl.c     | 4 ++--
>  mesh/util.c    | 4 ++--
>  3 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/mesh/keyring.c b/mesh/keyring.c
> index 51621777d..b44091154 100644
> --- a/mesh/keyring.c
> +++ b/mesh/keyring.c
> @@ -50,7 +50,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 9a99afe7b..6bb3532b2 100644
> --- a/mesh/rpl.c
> +++ b/mesh/rpl.c
> @@ -255,7 +255,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);
> @@ -293,7 +293,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 d505e7a0c..82b57f642 100644
> --- a/mesh/util.c
> +++ b/mesh/util.c
> @@ -118,13 +118,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;
diff mbox series

Patch

diff --git a/mesh/keyring.c b/mesh/keyring.c
index 51621777d..b44091154 100644
--- a/mesh/keyring.c
+++ b/mesh/keyring.c
@@ -50,7 +50,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 9a99afe7b..6bb3532b2 100644
--- a/mesh/rpl.c
+++ b/mesh/rpl.c
@@ -255,7 +255,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);
@@ -293,7 +293,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 d505e7a0c..82b57f642 100644
--- a/mesh/util.c
+++ b/mesh/util.c
@@ -118,13 +118,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;