mirror of
https://github.com/systemd/systemd.git
synced 2025-01-12 13:18:14 +03:00
nspawn: port over basename() → path_extract_filename()
This commit is contained in:
parent
451f0dba60
commit
b36e39d2eb
@ -47,10 +47,14 @@ int systemd_installation_has_version(const char *root, const char *minimal_versi
|
|||||||
*c = '\0'; /* truncate the glob part */
|
*c = '\0'; /* truncate the glob part */
|
||||||
|
|
||||||
STRV_FOREACH(name, names) {
|
STRV_FOREACH(name, names) {
|
||||||
|
_cleanup_free_ char *bn = NULL;
|
||||||
/* This is most likely to run only once, hence let's not optimize anything. */
|
/* This is most likely to run only once, hence let's not optimize anything. */
|
||||||
char *t, *t2;
|
char *t, *t2;
|
||||||
|
|
||||||
t = startswith(basename(*name), "libsystemd-shared-");
|
if (path_extract_filename(*name, &bn) < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
t = startswith(bn, "libsystemd-shared-");
|
||||||
if (!t)
|
if (!t)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -3045,16 +3045,19 @@ static int determine_names(void) {
|
|||||||
else if (arg_image) {
|
else if (arg_image) {
|
||||||
char *e;
|
char *e;
|
||||||
|
|
||||||
arg_machine = strdup(basename(arg_image));
|
r = path_extract_filename(arg_image, &arg_machine);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to extract file name from '%s': %m", arg_image);
|
||||||
|
|
||||||
/* Truncate suffix if there is one */
|
/* Truncate suffix if there is one */
|
||||||
e = endswith(arg_machine, ".raw");
|
e = endswith(arg_machine, ".raw");
|
||||||
if (e)
|
if (e)
|
||||||
*e = 0;
|
*e = 0;
|
||||||
} else
|
} else {
|
||||||
arg_machine = strdup(basename(arg_directory));
|
r = path_extract_filename(arg_directory, &arg_machine);
|
||||||
if (!arg_machine)
|
if (r < 0)
|
||||||
return log_oom();
|
return log_error_errno(r, "Failed to extract file name from '%s': %m", arg_directory);
|
||||||
|
}
|
||||||
|
|
||||||
hostname_cleanup(arg_machine);
|
hostname_cleanup(arg_machine);
|
||||||
if (!hostname_is_valid(arg_machine, 0))
|
if (!hostname_is_valid(arg_machine, 0))
|
||||||
|
Loading…
Reference in New Issue
Block a user