shutdown: propagate correct error when remounting fails

Here the logging was fine, but the bogus r == -1 value was propagated
as the return value. The parent then logged
"Remounting '…' failed abnormally, child process … failed: Operation not permitted"
whatever the real error was, and returned -EPERM. Do what
umount_with_timeout() already does with umount2().

(cherry picked from commit 8087660ccc)
(cherry picked from commit 3e9368f0e9)
This commit is contained in:
Zbigniew Jędrzejewski-Szmek authored and Luca Boccassi committed 2026-11-05 14:48:10 +00:00
1 parent 87c4028d8a
commit c365aa1ddf
1 file changed
+2 -2
+2 -2
View File
@@ -273,10 +273,10 @@ static int remount_with_timeout(MountPoint *m, bool last_try) {
log_info("Remounting '%s' read-only with options '%s'.", m->path, strempty(m->remount_options));
/* Start the mount operation here in the child */
r = mount(NULL, m->path, NULL, m->remount_flags, m->remount_options);
r = RET_NERRNO(mount(/* source= */ NULL, m->path, /* filesystemtype= */ NULL, m->remount_flags, m->remount_options));
if (r < 0)
log_full_errno(last_try ? LOG_ERR : LOG_INFO,
errno,
r,
"Failed to remount '%s' read-only: %m",
m->path);