summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/fs-util.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c
index 00c3a4e1b..33467c379 100644
--- a/src/basic/fs-util.c
+++ b/src/basic/fs-util.c
@@ -38,7 +38,6 @@
#include "mkdir.h"
#include "parse-util.h"
#include "path-util.h"
-#include "process-util.h"
#include "stat-util.h"
#include "stdio-util.h"
#include "string-util.h"
@@ -367,22 +366,25 @@ int touch(const char *path) {
#if 0 /// UNNEEDED by elogind
int symlink_idempotent(const char *from, const char *to) {
- _cleanup_free_ char *p = NULL;
int r;
assert(from);
assert(to);
if (symlink(from, to) < 0) {
+ _cleanup_free_ char *p = NULL;
+
if (errno != EEXIST)
return -errno;
r = readlink_malloc(to, &p);
- if (r < 0)
+ if (r == -EINVAL) /* Not a symlink? In that case return the original error we encountered: -EEXIST */
+ return -EEXIST;
+ if (r < 0) /* Any other error? In that case propagate it as is */
return r;
- if (!streq(p, from))
- return -EINVAL;
+ if (!streq(p, from)) /* Not the symlink we want it to be? In that case, propagate the original -EEXIST */
+ return -EEXIST;
}
return 0;