diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-12-21 16:50:18 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2022-12-23 15:04:19 +0100 |
commit | 7b2ffb593e57b4e3e13de06f0ce382bdd19d37cc (patch) | |
tree | c628ce3a1638ac68917e4b6d76fe8eb71b875a4a /src/partition/makefs.c | |
parent | 7e763f940273e7566ab23d584b576a91b5f1b93c (diff) | |
download | systemd-7b2ffb593e57b4e3e13de06f0ce382bdd19d37cc.tar.gz |
repart/makefs: port over to path_extract_filename()
Diffstat (limited to 'src/partition/makefs.c')
-rw-r--r-- | src/partition/makefs.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/partition/makefs.c b/src/partition/makefs.c index 3f54bbb0da..2733763eb2 100644 --- a/src/partition/makefs.c +++ b/src/partition/makefs.c @@ -13,12 +13,13 @@ #include "fd-util.h" #include "main-func.h" #include "mkfs-util.h" +#include "path-util.h" #include "process-util.h" #include "signal-util.h" #include "string-util.h" static int run(int argc, char *argv[]) { - _cleanup_free_ char *device = NULL, *fstype = NULL, *detected = NULL; + _cleanup_free_ char *device = NULL, *fstype = NULL, *detected = NULL, *label = NULL; _cleanup_close_ int lock_fd = -EBADF; sd_id128_t uuid; struct stat st; @@ -65,7 +66,11 @@ static int run(int argc, char *argv[]) { if (r < 0) return log_error_errno(r, "Failed to generate UUID for file system: %m"); - return make_filesystem(device, fstype, basename(device), NULL, uuid, true, NULL); + r = path_extract_filename(device, &label); + if (r < 0) + return log_error_errno(r, "Failed to extract file name from '%s': %m", device); + + return make_filesystem(device, fstype, label, NULL, uuid, true, NULL); } DEFINE_MAIN_FUNCTION(run); |