aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-12-09 20:56:43 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-12-09 20:56:43 +0100
commit56ee5765074b2f2389066f3234a4da21501d3eaa (patch)
treeb4fe1bbbd147350eaf90b688285cfb09ed07f3ab
parente7d853b4eb080dd8ea6433d010378e119e5a4cb3 (diff)
downloadbusybox-w32-56ee5765074b2f2389066f3234a4da21501d3eaa.tar.gz
busybox-w32-56ee5765074b2f2389066f3234a4da21501d3eaa.tar.bz2
busybox-w32-56ee5765074b2f2389066f3234a4da21501d3eaa.zip
mount: fix incorrect "success" exitcode if loop device setup fails
When mounting, in parallel, multiple loop devices (squashfs for the submitter's case), the following behavior can be observed: stat64(/path/to/image, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 openat(AT_FDCWD, /path/to/image, O_RDWR|O_LARGEFILE) = 3 openat(AT_FDCWD, /dev/loop-control, O_RDWR|O_LARGEFILE|O_CLOEXEC) = 4 ioctl(4, LOOP_CTL_GET_FREE) = 12 close(4) = 0 openat(AT_FDCWD, /dev/loop12, O_RDWR|O_LARGEFILE) = 4 ioctl(4, LOOP_GET_STATUS64, {lo_offset=0, lo_number=12, lo_flags=LO_FLAGS_AUTOCLEAR, lo_file_name=/path/to/image, ...}) = 0 close(4) = 0 close(3) = 0 write(2, "mount: can't setup loop device\n", 31mount: can't setup loop device ) = 31 exit_group(0) = ? +++ exited with 0 +++ The ioctl LOOP_CTL_GET_FREE has resulted in the same result for a competing mount process. The subsequent ioctl LOOP_GET_STATUS64 fails, having succeeded for the competing mount process. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--util-linux/mount.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 2eadee88b..0814a5256 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -2078,8 +2078,8 @@ static int singlemount(struct mntent *mp, int ignore_busy)
2078 && (!mp->mnt_type || is_prefixed_with(mp->mnt_type, "nfs")) 2078 && (!mp->mnt_type || is_prefixed_with(mp->mnt_type, "nfs"))
2079 ) { 2079 ) {
2080 char *colon = strchr(mp->mnt_fsname, ':'); 2080 char *colon = strchr(mp->mnt_fsname, ':');
2081 if (colon /* looks like "hostname:..." */ 2081 if (colon // looks like "hostname:..."
2082 && strchrnul(mp->mnt_fsname, '/') > colon /* "hostname:" has no slashes */ 2082 && strchrnul(mp->mnt_fsname, '/') > colon // "hostname:" has no slashes
2083 ) { 2083 ) {
2084 if (!mp->mnt_type) 2084 if (!mp->mnt_type)
2085 mp->mnt_type = (char*)"nfs"; 2085 mp->mnt_type = (char*)"nfs";
@@ -2125,7 +2125,7 @@ static int singlemount(struct mntent *mp, int ignore_busy)
2125 bb_simple_error_msg(bb_msg_perm_denied_are_you_root); 2125 bb_simple_error_msg(bb_msg_perm_denied_are_you_root);
2126 else 2126 else
2127 bb_simple_perror_msg("can't setup loop device"); 2127 bb_simple_perror_msg("can't setup loop device");
2128 return errno; 2128 return loopfd; // was "return errno", but it can be 0 here
2129 } 2129 }
2130 2130
2131 // Autodetect bind mounts 2131 // Autodetect bind mounts