mount.nilfs2: fix broken overlapping rw-mount protection

The check for overlapping rw-mounts in nilfs_prepare_mount() detects
the condition and prints an error message, but fails to stop the mount
process.

This occurs because the return variable 'res' remains 0 (success) when
jumping to the failure label.

Consequently, the mount succeeds illegally, leading to a state where
umount fails with -EBUSY (due to unhandled garbage collector shutdown),
forcing manual process termination.

Fix this by setting 'res' to -EBUSY.  While any negative value would
abort the mount, -EBUSY is chosen to accurately reflect the cause and
align with libmount's error reporting granularity.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
This commit is contained in:
Ryusuke Konishi 2026-01-14 01:02:34 +09:00
parent d0e8cc2caf
commit 53a23b7069

View File

@ -334,6 +334,7 @@ static int nilfs_prepare_mount(struct nilfs_mount_info *mi)
error(_("%s: the device already has a rw-mount on %s.\n"
"\t\tmultiple rw-mount is not allowed."),
progname, mnt_fs_get_target(fs));
res = -EBUSY;
goto failed;
case MS_RDONLY: /* ro-mount (a rw-mount exists) */
break;