1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-06 13:17:44 +03:00

repart/makefs: port over to path_extract_filename()

This commit is contained in:
Lennart Poettering 2022-12-21 16:50:18 +01:00
parent 7e763f9402
commit 7b2ffb593e
2 changed files with 9 additions and 6 deletions

View File

@ -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);

View File

@ -2580,10 +2580,8 @@ static int partition_hint(const Partition *p, const char *node, char **ret) {
/* Tries really hard to find a suitable description for this partition */
if (p->definition_path) {
buf = strdup(basename(p->definition_path));
goto done;
}
if (p->definition_path)
return path_extract_filename(p->definition_path, ret);
label = partition_label(p);
if (!isempty(label)) {