summaryrefslogtreecommitdiff
path: root/src/shared/mount-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-12-21 16:51:05 +0100
committerLennart Poettering <lennart@poettering.net>2022-12-23 17:35:21 +0100
commit03469b770bbe056b8df3bd109926b3941c0da878 (patch)
treeb61883dcf8facf19076670ce9a8de2be27e01c41 /src/shared/mount-util.c
parent7b2ffb593e57b4e3e13de06f0ce382bdd19d37cc (diff)
downloadsystemd-03469b770bbe056b8df3bd109926b3941c0da878.tar.gz
shared: port various shared helpers basename() → 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;