mount_fsmount: fix signature of ms_flags_to_mount_attrs
The flags parameter of mount() is an unsigned long on Linux, which means
that the return type of type of ms_flags_to_mount_attrs must also be
unsigned long to avoid possible truncation of unconverted MS_* flags.
However, the attr_flags parameter of fsmount() is unsigned int, so
there's no need to use an unnecessarily large type. Why the kernel ABI
didn't specify this as u64 is beyond me, but there it is.
Fix both problems with the function signature and caller.
Fixes: 14cb7b93bb9688 ("Add support for the new linux mount API")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
diff --git a/lib/mount_fsmount.c b/lib/mount_fsmount.c
index 2afffce..8ae5f05 100644
--- a/lib/mount_fsmount.c
+++ b/lib/mount_fsmount.c
@@ -41,28 +41,28 @@
* Mount attributes control mount-point level behavior.
* To called after set_ms_flags() which consumes the fsconfig flags.
*
- * @attrs MOUNT_ATTR flags, built from MS_ flags
- * @return remaining flags
+ * @mount_attrs MOUNT_ATTR flags, built from MS_ flags
+ * @return remaining MS_* flags
*/
-static int ms_flags_to_mount_attrs(unsigned long flags,
- unsigned long *attrs)
+static unsigned long ms_flags_to_mount_attrs(unsigned long ms_flags,
+ unsigned int *mount_attrs)
{
int i;
- *attrs = 0;
+ *mount_attrs = 0;
- for (i = 0; mount_flags[i].opt != NULL && flags != 0; i++) {
+ for (i = 0; mount_flags[i].opt != NULL && ms_flags != 0; i++) {
/* Only process mount attributes (mount_attr != 0) with on==1 */
if (!mount_flags[i].mount_attr || !mount_flags[i].on)
continue;
- if (flags & mount_flags[i].flag) {
- *attrs |= mount_flags[i].mount_attr;
- flags &= ~mount_flags[i].flag;
+ if (ms_flags & mount_flags[i].flag) {
+ *mount_attrs |= mount_flags[i].mount_attr;
+ ms_flags &= ~mount_flags[i].flag;
}
}
- return flags;
+ return ms_flags;
}
/*
@@ -349,7 +349,7 @@
int fsfd = -1;
int mntfd = -1;
int err, res;
- unsigned long mount_attrs;
+ unsigned int mount_attrs;
/* Build type and source strings */
type = fuse_mnt_build_type(blkdev, subtype);