shared/generator: allow absolute symlink target in generator_add_symlink()

Also remove the stray ".d" from comment and rename directory argument to "dir"
(we usually use "root" for arg_root, so using it here was misleading).
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2019-01-03 15:30:25 +01:00
parent 01a0f7d03e
commit 5c176eb4bf
2 changed files with 6 additions and 5 deletions
+5 -4
View File
@@ -55,13 +55,14 @@ int generator_open_unit_file(
return 0;
}
int generator_add_symlink(const char *root, const char *dst, const char *dep_type, const char *src) {
/* Adds a symlink from <dst>.<dep_type>.d/ to ../<src> */
int generator_add_symlink(const char *dir, const char *dst, const char *dep_type, const char *src) {
/* Adds a symlink from <dst>.<dep_type>/ to <src> (if src is absolute)
* or ../<src> (otherwise). */
const char *from, *to;
from = strjoina("../", src);
to = strjoina(root, "/", dst, ".", dep_type, "/", src);
from = path_is_absolute(src) ? src : strjoina("../", src);
to = strjoina(dir, "/", dst, ".", dep_type, "/", basename(src));
mkdir_parents_label(to, 0755);
if (symlink(from, to) < 0)
+1 -1
View File
@@ -11,7 +11,7 @@ int generator_open_unit_file(
const char *name,
FILE **file);
int generator_add_symlink(const char *root, const char *dst, const char *dep_type, const char *src);
int generator_add_symlink(const char *dir, const char *dst, const char *dep_type, const char *src);
int generator_write_fsck_deps(
FILE *f,