Discussion:
[PATCH] init: fix name of root device in /proc/mounts
William Hubbs
2013-01-31 22:51:39 UTC
Permalink
On a system that does not use an initramfs, /dev/root was always
listed in /proc/mounts. This breaks software which scans /proc/mounts to
determine which file systems are mounted since /dev/root is not a valid
device name.

This changes that processing so that "/dev/root" is only added to
/proc/mounts if a root device is not specified with the root= option on
the kernel command line.

Signed-off-by: William Hubbs <***@gmail.com>
---
init/do_mounts.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/init/do_mounts.c b/init/do_mounts.c
index 1d1b634..efc37d2 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -480,7 +480,10 @@ void __init change_floppy(char *fmt, ...)
va_start(args, fmt);
vsprintf(buf, fmt, args);
va_end(args);
- fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
+ if (saved_root_name[0])
+ fd = sys_open(saved_root_name, O_RDWR | O_NDELAY, 0);
+ else
+ fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
if (fd >= 0) {
sys_ioctl(fd, FDEJECT, 0);
sys_close(fd);
@@ -523,8 +526,13 @@ void __init mount_root(void)
}
#endif
#ifdef CONFIG_BLOCK
- create_dev("/dev/root", ROOT_DEV);
- mount_block_root("/dev/root", root_mountflags);
+ if (saved_root_name[0]) {
+ create_dev(saved_root_name, ROOT_DEV);
+ mount_block_root(saved_root_name, root_mountflags);
+ } else {
+ create_dev("/dev/root", ROOT_DEV);
+ mount_block_root("/dev/root", root_mountflags);
+ }
#endif
}
--
1.7.12.4
H. Peter Anvin
2013-01-31 23:22:09 UTC
Permalink
Post by William Hubbs
On a system that does not use an initramfs, /dev/root was always
listed in /proc/mounts. This breaks software which scans /proc/mounts to
determine which file systems are mounted since /dev/root is not a valid
device name.
This changes that processing so that "/dev/root" is only added to
/proc/mounts if a root device is not specified with the root= option on
the kernel command line.
Let me also point out that most of the time, the kernel actually has a
udev device name for an actual device...

-hpa
William Hubbs
2013-02-01 17:14:53 UTC
Permalink
Post by H. Peter Anvin
Post by William Hubbs
On a system that does not use an initramfs, /dev/root was always
listed in /proc/mounts. This breaks software which scans /proc/mounts to
determine which file systems are mounted since /dev/root is not a valid
device name.
This changes that processing so that "/dev/root" is only added to
/proc/mounts if a root device is not specified with the root= option on
the kernel command line.
Let me also point out that most of the time, the kernel actually has a
udev device name for an actual device...
I'm not sure what you mean. If you mean /dev/root is not an actual
device and should not be listed in /proc/mounts, that is correct and
that is why I am proposing this patch.

William
H. Peter Anvin
2013-02-01 19:03:20 UTC
Permalink
Post by William Hubbs
Post by H. Peter Anvin
Post by William Hubbs
On a system that does not use an initramfs, /dev/root was always
listed in /proc/mounts. This breaks software which scans /proc/mounts to
determine which file systems are mounted since /dev/root is not a valid
device name.
This changes that processing so that "/dev/root" is only added to
/proc/mounts if a root device is not specified with the root= option on
the kernel command line.
Let me also point out that most of the time, the kernel actually has a
udev device name for an actual device...
I'm not sure what you mean. If you mean /dev/root is not an actual
device and should not be listed in /proc/mounts, that is correct and
that is why I am proposing this patch.
What I meant is that even if you *don't* specify a root= device the
modern kernel will generally have a usable name.

-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
Rob Landley
2013-02-05 02:42:21 UTC
Permalink
Post by William Hubbs
Post by William Hubbs
On a system that does not use an initramfs, /dev/root was always
listed in /proc/mounts. This breaks software which scans
/proc/mounts to
Post by William Hubbs
determine which file systems are mounted since /dev/root is not a
valid
Post by William Hubbs
device name.
This changes that processing so that "/dev/root" is only added to
/proc/mounts if a root device is not specified with the root=
option on
Post by William Hubbs
the kernel command line.
Let me also point out that most of the time, the kernel actually has a
udev device name for an actual device...
So your software is broken by overmounts? /dev/root is just one example
of this. (And you can specify a root= on the kernel command line and
have that be parsed by initramfs. I vaguely recall klibc does this...)

For an example of how to parse this stuff, how about:

http://landley.net/hg/toybox/file/4ffb735aea59/toys/posix/df.c

I.E. parse from the end of the list (most recent match is the
overmount), and eliminate synthetic filesystems. Note that code is from
2006, other people have managed to cope all this time...

Rob--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
H. Peter Anvin
2013-02-05 02:54:32 UTC
Permalink
The difference is that it used to be customary to have a /dev/root symlink; iirc udev created one. Devtmpfs does not (for largely valid reasons, but it does break some userspaces.)
Post by Rob Landley
Post by William Hubbs
Post by William Hubbs
On a system that does not use an initramfs, /dev/root was always
listed in /proc/mounts. This breaks software which scans
/proc/mounts to
Post by William Hubbs
determine which file systems are mounted since /dev/root is not a
valid
Post by William Hubbs
device name.
This changes that processing so that "/dev/root" is only added to
/proc/mounts if a root device is not specified with the root=
option on
Post by William Hubbs
the kernel command line.
Let me also point out that most of the time, the kernel actually has
a
Post by William Hubbs
udev device name for an actual device...
So your software is broken by overmounts? /dev/root is just one example
of this. (And you can specify a root= on the kernel command line and
have that be parsed by initramfs. I vaguely recall klibc does this...)
http://landley.net/hg/toybox/file/4ffb735aea59/toys/posix/df.c
I.E. parse from the end of the list (most recent match is the
overmount), and eliminate synthetic filesystems. Note that code is from
2006, other people have managed to cope all this time...
Rob
--
Sent from my mobile phone. Please excuse brevity and lack of formatting.
William Hubbs
2013-02-05 04:19:53 UTC
Permalink
Post by H. Peter Anvin
The difference is that it used to be customary to have a /dev/root symlink; iirc udev created one. Devtmpfs does not (for largely valid reasons, but it does break some userspaces.)
Correct. The /dev/root symlink is not created any longer. If you boot
with an initramfs this path does not show up in /proc/mounts. If you
boot without one, however, it does.

This patch just makes the /dev/root path not show up at all in
/proc/mounts, regardless of whether an initramfs is used.

Thanks,

William
Post by H. Peter Anvin
Post by Rob Landley
Post by William Hubbs
Post by William Hubbs
On a system that does not use an initramfs, /dev/root was always
listed in /proc/mounts. This breaks software which scans
/proc/mounts to
Post by William Hubbs
determine which file systems are mounted since /dev/root is not a
valid
Post by William Hubbs
device name.
This changes that processing so that "/dev/root" is only added to
/proc/mounts if a root device is not specified with the root=
option on
Post by William Hubbs
the kernel command line.
Let me also point out that most of the time, the kernel actually has
a
Post by William Hubbs
udev device name for an actual device...
So your software is broken by overmounts? /dev/root is just one example
of this. (And you can specify a root= on the kernel command line and
have that be parsed by initramfs. I vaguely recall klibc does this...)
http://landley.net/hg/toybox/file/4ffb735aea59/toys/posix/df.c
I.E. parse from the end of the list (most recent match is the
overmount), and eliminate synthetic filesystems. Note that code is from
2006, other people have managed to cope all this time...
Rob
--
Sent from my mobile phone. Please excuse brevity and lack of formatting.
William Hubbs
2013-03-17 22:23:24 UTC
Permalink
All,

I haven't heard any more on this patch, so I wanted to ping the thread
again and find out the status.

The original message is linked below[1].

The issue is that /dev/root appears in /proc/mounts if you do not boot
with an initramfs, but /dev/root is not a device node. In the past, udev
created a symbolic link from /dev/root to the appropriate block device,
but it does not do this any longer. Also, devtmpfs does not create this
symbolic link.

This is causing bugs with software that depends on the existence of
/dev/root [2] for example.

Do you need any more information on this patch, or is there some reason
it can't go in?

Thanks much,

William

[1] https://lkml.org/lkml/2013/1/31/574
[2] https://bugs.gentoo.org/show_bug.cgi?id=438028
William Hubbs
2013-03-19 22:28:22 UTC
Permalink
All,

I haven't heard any more on this patch, so I wanted to ping the thread
again and find out the status.

The original message is linked below[1].

The issue is that /dev/root appears in /proc/mounts if you do not boot
with an initramfs, but /dev/root is not a device node. In the past, udev
created a symbolic link from /dev/root to the appropriate block device,
but it does not do this any longer. Also, devtmpfs does not create this
symbolic link.

This is causing bugs with software that depends on the existence of
/dev/root [2] for example.

Do you need any more information on this patch, or is there some reason
it can't go in?

Thanks much,

William

[1] https://lkml.org/lkml/2013/1/31/574
[2] https://bugs.gentoo.org/show_bug.cgi?id=438028
H. Peter Anvin
2013-03-19 23:17:11 UTC
Permalink
Post by William Hubbs
All,
I haven't heard any more on this patch, so I wanted to ping the
thread again and find out the status.
The original message is linked below[1].
The issue is that /dev/root appears in /proc/mounts if you do not
boot with an initramfs, but /dev/root is not a device node. In the
past, udev created a symbolic link from /dev/root to the
appropriate block device, but it does not do this any longer. Also,
devtmpfs does not create this symbolic link.
This is causing bugs with software that depends on the existence
of /dev/root [2] for example.
Do you need any more information on this patch, or is there some
reason it can't go in?
Seems okay to me, although even better would be to use the udev name
of the device in question.

-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
William Hubbs
2013-03-20 00:20:17 UTC
Permalink
Post by H. Peter Anvin
Post by William Hubbs
The issue is that /dev/root appears in /proc/mounts if you do not
boot with an initramfs, but /dev/root is not a device node. In the
past, udev created a symbolic link from /dev/root to the
appropriate block device, but it does not do this any longer. Also,
devtmpfs does not create this symbolic link.
This is causing bugs with software that depends on the existence
of /dev/root [2] for example.
Seems okay to me, although even better would be to use the udev name
of the device in question.
I'm not following what you mean.

The problem is that "/dev/root" should not be in /proc/mounts,
since there is always another entry that points to the root
file system.

William
H. Peter Anvin
2013-03-20 00:24:36 UTC
Permalink
Post by William Hubbs
I'm not following what you mean.
The problem is that "/dev/root" should not be in /proc/mounts,
since there is always another entry that points to the root file
system.
You are getting the name from the root= command line option.

The other option is to take the name from the mounted device number,
and look up the udev name (which is known by the kernel). That way it
works even if the user specifies a numeric device, or the default
device is used.

-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
Rob Landley
2013-03-20 07:03:20 UTC
Permalink
Post by William Hubbs
Post by H. Peter Anvin