diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-12-24 00:13:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-24 00:13:00 +0100 |
commit | 20ada514648d2c479a49689c6714c72af31ab8f6 (patch) | |
tree | 81b91da00312fef71aeb10ed9e0d339ce708474a /src/shared/generator.c | |
parent | prioq: make prioq_reshuffle() void (diff) | |
parent | lock-file: various updates (diff) | |
download | systemd-20ada514648d2c479a49689c6714c72af31ab8f6.tar.xz systemd-20ada514648d2c479a49689c6714c72af31ab8f6.zip |
Merge pull request #25828 from poettering/no-more-basename
convert a number of basename() invocations to path_extract_filename()
Diffstat (limited to 'src/shared/generator.c')
-rw-r--r-- | src/shared/generator.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/shared/generator.c b/src/shared/generator.c index da3eaadbf4..6d95aa72f8 100644 --- a/src/shared/generator.c +++ b/src/shared/generator.c @@ -60,13 +60,19 @@ int generator_open_unit_file( } int generator_add_symlink(const char *dir, const char *dst, const char *dep_type, const char *src) { + _cleanup_free_ char *bn = NULL; + const char *from, *to; + int r; + /* Adds a symlink from <dst>.<dep_type>/ to <src> (if src is absolute) * or ../<src> (otherwise). */ - const char *from, *to; + r = path_extract_filename(src, &bn); + if (r < 0) + return log_error_errno(r, "Failed to extract filename from '%s': %m", src); from = path_is_absolute(src) ? src : strjoina("../", src); - to = strjoina(dir, "/", dst, ".", dep_type, "/", basename(src)); + to = strjoina(dir, "/", dst, ".", dep_type, "/", bn); (void) mkdir_parents_label(to, 0755); if (symlink(from, to) < 0) |