summaryrefslogtreecommitdiff
path: root/src/basic/fs-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-09-26 18:26:20 +0200
committerSven Eden <yamakuzure@gmx.net>2017-11-22 08:25:10 +0100
commit9b74c28b7c2329b86d92c504c3455c178ec14e87 (patch)
treee0e74927f00afe29664f76c3b05057c294f01c6b /src/basic/fs-util.c
parenteed88c29597329268e5bdcbf192f2133812091c2 (diff)
fs-util: propagate EEXIST error in symlink_idempotent() as EEXIST
We really shouldn't silently translate the error code here for no reason.
Diffstat (limited to 'src/basic/fs-util.c')
-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;