yanglint: fix race around mkdir()
I've actually seen this on our CI on Mac OS:
```
Start 60: yanglint_in_list
58/61 Test #57: regress_fuzz_lys_parse_mem ........ Passed 0.85 sec
Start 61: yanglint_in_feature
59/61 Test #56: headers ........................... Passed 2.65 sec
60/61 Test #60: yanglint_in_list ..................***Failed 2.41 sec
spawn /Users/runner/work/oopt-gnpy-libyang/build-libyang/yanglint
YANGLINT[W]: Configuration directory "/Users/runner/.yanglint" does not exist, creating it.
YANGLINT[E]: Configuration directory "/Users/runner/.yanglint" cannot be created (File exists).
61/61 Test #61: yanglint_in_feature ...............***Failed 2.40 sec
spawn /Users/runner/work/oopt-gnpy-libyang/build-libyang/yanglint
YANGLINT[W]: Configuration directory "/Users/runner/.yanglint" does not exist, creating it.
YANGLINT[W]: No saved history.
```
diff --git a/tools/lint/configuration.c b/tools/lint/configuration.c
index fe37f6d..86179fa 100644
--- a/tools/lint/configuration.c
+++ b/tools/lint/configuration.c
@@ -55,9 +55,12 @@
/* directory does not exist */
YLMSG_W("Configuration directory \"%s\" does not exist, creating it.\n", yl_dir);
if (mkdir(yl_dir, 00700)) {
- YLMSG_E("Configuration directory \"%s\" cannot be created (%s).\n", yl_dir, strerror(errno));
- free(yl_dir);
- return NULL;
+ if (errno != EEXIST) {
+ /* parallel execution, yay */
+ YLMSG_E("Configuration directory \"%s\" cannot be created (%s).\n", yl_dir, strerror(errno));
+ free(yl_dir);
+ return NULL;
+ }
}
} else {
YLMSG_E("Configuration directory \"%s\" exists but cannot be accessed (%s).\n", yl_dir, strerror(errno));