summaryrefslogtreecommitdiff
path: root/src/basic/fs-util.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-09-13 03:30:34 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-09-14 06:22:09 +0900
commit590d81002bbce1a1bcce21056d12873fb96ee3a9 (patch)
tree361e80b7ad8eef8ac2ca4ba43a9eebf029e294fb /src/basic/fs-util.c
parent449375d2adadb0ce7a8975876ca797ae4f926e48 (diff)
downloadsystemd-590d81002bbce1a1bcce21056d12873fb96ee3a9.tar.gz
fs-util,label: introduce symlink_atomic_full() and symlink_atomic_full_label()
These new functions optionally create symlink of relative path.
Diffstat (limited to 'src/basic/fs-util.c')
-rw-r--r--src/basic/fs-util.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c
index a0898bf4f5..cbab59b777 100644
--- a/src/basic/fs-util.c
+++ b/src/basic/fs-util.c
@@ -432,13 +432,21 @@ int symlink_idempotent(const char *from, const char *to, bool make_relative) {
return 0;
}
-int symlink_atomic(const char *from, const char *to) {
- _cleanup_free_ char *t = NULL;
+int symlink_atomic_full(const char *from, const char *to, bool make_relative) {
+ _cleanup_free_ char *relpath = NULL, *t = NULL;
int r;
assert(from);
assert(to);
+ if (make_relative) {
+ r = path_make_relative_parent(to, from, &relpath);
+ if (r < 0)
+ return r;
+
+ from = relpath;
+ }
+
r = tempfn_random(to, NULL, &t);
if (r < 0)
return r;