]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/generator: allow absolute symlink target in generator_add_symlink()
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 20 Dec 2018 11:10:36 +0000 (12:10 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 3 Jan 2019 14:30:25 +0000 (15:30 +0100)
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).

src/shared/generator.c
src/shared/generator.h

index 0adaaf2c5671d161fe43d9174b16a6db02490388..ce8305c236649d588fc4666fed52e1a65e4c66c8 100644 (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)
index 5a1c1e32f7f7d765c23bf562031e0f2cda8e1f0e..e2209657cd6233a8f8c575bc8b0296fa71e98994 100644 (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,