diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-13 03:30:34 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-14 06:22:09 +0900 |
commit | 590d81002bbce1a1bcce21056d12873fb96ee3a9 (patch) | |
tree | 361e80b7ad8eef8ac2ca4ba43a9eebf029e294fb /src/basic/fs-util.c | |
parent | 449375d2adadb0ce7a8975876ca797ae4f926e48 (diff) | |
download | systemd-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.c | 12 |
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; |