summaryrefslogtreecommitdiffstats
path: root/src/shared/mount-util.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-12-24 00:13:00 +0100
committerGitHub <noreply@github.com>2022-12-24 00:13:00 +0100
commit20ada514648d2c479a49689c6714c72af31ab8f6 (patch)
tree81b91da00312fef71aeb10ed9e0d339ce708474a /src/shared/mount-util.c
parentprioq: make prioq_reshuffle() void (diff)
parentlock-file: various updates (diff)
downloadsystemd-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/mount-util.c')
-rw-r--r--src/shared/mount-util.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/shared/mount-util.c b/src/shared/mount-util.c
index 603eb7b780..8aad531a4d 100644
--- a/src/shared/mount-util.c
+++ b/src/shared/mount-util.c
@@ -952,7 +952,7 @@ static int mount_in_namespace(
if (r < 0)
goto finish;
if (r == 0) {
- const char *mount_inside;
+ _cleanup_free_ char *mount_outside_fn = NULL, *mount_inside = NULL;
errno_pipe_fd[0] = safe_close(errno_pipe_fd[0]);
@@ -965,8 +965,19 @@ static int mount_in_namespace(
}
/* Fifth, move the mount to the right place inside */
- mount_inside = strjoina(incoming_path, basename(mount_outside));
- r = mount_nofollow_verbose(LOG_ERR, mount_inside, dest, NULL, MS_MOVE, NULL);
+ r = path_extract_filename(mount_outside, &mount_outside_fn);
+ if (r < 0) {
+ log_debug_errno(r, "Failed to extract filename from propagation file or directory '%s': %m", mount_outside);
+ goto child_fail;
+ }
+
+ mount_inside = path_join(incoming_path, mount_outside_fn);
+ if (!mount_inside) {
+ r = log_oom_debug();
+ goto child_fail;
+ }
+
+ r = mount_nofollow_verbose(LOG_DEBUG, mount_inside, dest, NULL, MS_MOVE, NULL);
if (r < 0)
goto child_fail;