mountinfo contents changed when rootfs is ramfs
From: Pranay Srivastava
Date: Wed Aug 19 2020 - 07:51:52 EST
Hello,
I'm running a system where rootfs is ramfs. For kernel version 5.2.11
# cat /proc/self/mountinfo
0 0 0:1 / / rw - rootfs rootfs rw
%<---snip>%
while for kernel 5.4.58
# cat /proc/self/mountinfo
0 0 0:1 / / rw - rootfs none rw
%<---snip>%
The reason for the above difference is because for kernel 5.2.11 the
parse_param for
rootfs was set to legacy_parse_param which handled the "source" param
instead of
ignoring it.
With kernel 5.4.58 this is set to ramfs_parse_param which ignores any
parameters not
recognized and also returns 0 instead of -ENOPARAM. This causes
vfs_parse_fs_param
to not set the file context source(fc->source) which results in "none" from
alloc_vfs_mount(fc->source ? : "none")
The commit which introduced the above change was
commit f32356261d44d580649a7abce1156d15d49cf20f
Author: David Howells <dhowells@xxxxxxxxxx>
Date: Mon Mar 25 16:38:31 2019 +0000
vfs: Convert ramfs, shmem, tmpfs, devtmpfs, rootfs to use the new mount API
I'm not sure if this is a regression? But if it is, do we handle it like
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index ee179a81b3da..47a39baa0535 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -200,7 +200,7 @@ static int ramfs_parse_param(struct fs_context
*fc, struct fs_parameter *param)
* and as it is used as a !CONFIG_SHMEM simple substitute
* for tmpfs, better continue to ignore other mount options.
*/
- if (opt == -ENOPARAM)
+ if (opt == -ENOPARAM && strcmp(param->key, "source"))
opt = 0;
return opt;
}
so that mountinfo gives the same information as for earlier kernels.
Thanks!
--
Regards,
Pranay Srivastava