summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/util/util.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/util/util.c b/lib/util/util.c
index 0d9ffe5cb7b..52fc61a3e81 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -339,6 +339,7 @@ _PUBLIC_ bool directory_exist(const char *dname)
/**
* Try to create the specified directory if it didn't exist.
+ * A symlink to a directory is also accepted as a valid existing directory.
*
* @retval true if the directory already existed
* or was successfully created.
@@ -372,9 +373,22 @@ _PUBLIC_ bool directory_create_or_exist(const char *dname,
return false;
}
- if (!S_ISDIR(sbuf.st_mode)) {
- return false;
+ if (S_ISDIR(sbuf.st_mode)) {
+ return true;
}
+
+ if (S_ISLNK(sbuf.st_mode)) {
+ ret = stat(dname, &sbuf);
+ if (ret != 0) {
+ return false;
+ }
+
+ if (S_ISDIR(sbuf.st_mode)) {
+ return true;
+ }
+ }
+
+ return false;
}
return true;