2013-03-19 22:28:29

by William Hubbs

[permalink] [raw]
Subject: Re: [PATCH] init: fix name of root device in /proc/mounts

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


Attachments:
(No filename) (754.00 B)
(No filename) (198.00 B)
Download all attachments

2013-03-19 23:17:42

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH] init: fix name of root device in /proc/mounts

On 03/19/2013 03:28 PM, William Hubbs wrote:
> 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.

2013-03-20 00:20:24

by William Hubbs

[permalink] [raw]
Subject: Re: [PATCH] init: fix name of root device in /proc/mounts

On Tue, Mar 19, 2013 at 04:17:11PM -0700, H. Peter Anvin wrote:
> On 03/19/2013 03:28 PM, William Hubbs wrote:
> > 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


Attachments:
(No filename) (826.00 B)
(No filename) (198.00 B)
Download all attachments

2013-03-20 00:24:49

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH] init: fix name of root device in /proc/mounts

On 03/19/2013 05:20 PM, William Hubbs wrote:
>
> 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.

2013-03-20 15:00:22

by Rob Landley

[permalink] [raw]
Subject: Re: [PATCH] init: fix name of root device in /proc/mounts

On 03/19/2013 07:20:17 PM, William Hubbs wrote:
> On Tue, Mar 19, 2013 at 04:17:11PM -0700, H. Peter Anvin wrote:
> > On 03/19/2013 03:28 PM, William Hubbs wrote:
> > > 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.

What gave you that idea?

wget http://landley.net/aboriginal/bin/system-image-i686.tar.bz2
extract it and ./run-emulator.sh and in there:

(i686:1) /home # cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / squashfs ro,relatime 0 0
proc /proc proc rw,relatime 0 0
sys /sys sysfs rw,relatime 0 0
dev /dev devtmpfs rw,relatime,size=63072k,nr_inodes=15768,mode=755 0 0
dev/pts /dev/pts devpts rw,relatime,mode=600 0 0
/tmp /tmp tmpfs rw,relatime 0 0
/home /home tmpfs rw,relatime 0 0

Userspace can totally determine what /dev/root points to, I made mdev
do it in 2006 (udev started doing so shortly thereafter). Busybox git
commit a7e3d052.

Heck, the userspace "stat /" command says "Device: 801h" and /dev/sda1
is 08:01 on my netbook.

Rob-

2013-03-20 15:02:49

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH] init: fix name of root device in /proc/mounts

Yes, but the current udev maintainer refuses to.

Rob Landley <[email protected]> wrote:

>On 03/19/2013 07:20:17 PM, William Hubbs wrote:
>> On Tue, Mar 19, 2013 at 04:17:11PM -0700, H. Peter Anvin wrote:
>> > On 03/19/2013 03:28 PM, William Hubbs wrote:
>> > > 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.
>
>What gave you that idea?
>
>wget http://landley.net/aboriginal/bin/system-image-i686.tar.bz2
>extract it and ./run-emulator.sh and in there:
>
>(i686:1) /home # cat /proc/mounts
>rootfs / rootfs rw 0 0
>/dev/root / squashfs ro,relatime 0 0
>proc /proc proc rw,relatime 0 0
>sys /sys sysfs rw,relatime 0 0
>dev /dev devtmpfs rw,relatime,size=63072k,nr_inodes=15768,mode=755 0 0
>dev/pts /dev/pts devpts rw,relatime,mode=600 0 0
>/tmp /tmp tmpfs rw,relatime 0 0
>/home /home tmpfs rw,relatime 0 0
>
>Userspace can totally determine what /dev/root points to, I made mdev
>do it in 2006 (udev started doing so shortly thereafter). Busybox git
>commit a7e3d052.
>
>Heck, the userspace "stat /" command says "Device: 801h" and /dev/sda1
>
>is 08:01 on my netbook.
>
>Rob

--
Sent from my mobile phone. Please excuse brevity and lack of formatting.

2013-03-20 21:11:32

by William Hubbs

[permalink] [raw]
Subject: Re: [PATCH] init: fix name of root device in /proc/mounts

On Wed, Mar 20, 2013 at 02:03:20AM -0500, Rob Landley wrote:
> On 03/19/2013 07:20:17 PM, William Hubbs wrote:
> > On Tue, Mar 19, 2013 at 04:17:11PM -0700, H. Peter Anvin wrote:
> > > On 03/19/2013 03:28 PM, William Hubbs wrote:
> > > > 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.
>
> What gave you that idea?
>
> wget http://landley.net/aboriginal/bin/system-image-i686.tar.bz2
> extract it and ./run-emulator.sh and in there:
>
> (i686:1) /home # cat /proc/mounts
> rootfs / rootfs rw 0 0
> /dev/root / squashfs ro,relatime 0 0
> proc /proc proc rw,relatime 0 0
> sys /sys sysfs rw,relatime 0 0
> dev /dev devtmpfs rw,relatime,size=63072k,nr_inodes=15768,mode=755 0 0
> dev/pts /dev/pts devpts rw,relatime,mode=600 0 0
> /tmp /tmp tmpfs rw,relatime 0 0
> /home /home tmpfs rw,relatime 0 0
>
> Userspace can totally determine what /dev/root points to, I made mdev
> do it in 2006 (udev started doing so shortly thereafter). Busybox git
> commit a7e3d052.:4

There are situations where it doesn't work though -- suppose that root
is btrfs for example.

Also, the other message that answered you is correct, the udev
maintainers say we should not be relying on /dev/root at all so to make
it work distro packagers have to add a rule themselves.

Kay,

if you are reading, canyou jump in and explain why /dev/root is a bad
idea?

Thanks,

William


Attachments:
(No filename) (2.03 kB)
(No filename) (198.00 B)
Download all attachments

2013-03-20 21:47:16

by Kay Sievers

[permalink] [raw]
Subject: Re: [PATCH] init: fix name of root device in /proc/mounts

On Wed, Mar 20, 2013 at 10:11 PM, William Hubbs <[email protected]> wrote:
> On Wed, Mar 20, 2013 at 02:03:20AM -0500, Rob Landley wrote:
>> On 03/19/2013 07:20:17 PM, William Hubbs wrote:
>> > On Tue, Mar 19, 2013 at 04:17:11PM -0700, H. Peter Anvin wrote:
>> > > On 03/19/2013 03:28 PM, William Hubbs wrote:
>> > > > 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.
>>
>> What gave you that idea?
>>
>> wget http://landley.net/aboriginal/bin/system-image-i686.tar.bz2
>> extract it and ./run-emulator.sh and in there:
>>
>> (i686:1) /home # cat /proc/mounts
>> rootfs / rootfs rw 0 0
>> /dev/root / squashfs ro,relatime 0 0
>> proc /proc proc rw,relatime 0 0
>> sys /sys sysfs rw,relatime 0 0
>> dev /dev devtmpfs rw,relatime,size=63072k,nr_inodes=15768,mode=755 0 0
>> dev/pts /dev/pts devpts rw,relatime,mode=600 0 0
>> /tmp /tmp tmpfs rw,relatime 0 0
>> /home /home tmpfs rw,relatime 0 0
>>
>> Userspace can totally determine what /dev/root points to, I made mdev
>> do it in 2006 (udev started doing so shortly thereafter). Busybox git
>> commit a7e3d052.:4
>
> There are situations where it doesn't work though -- suppose that root
> is btrfs for example.
>
> Also, the other message that answered you is correct, the udev
> maintainers say we should not be relying on /dev/root at all so to make
> it work distro packagers have to add a rule themselves.
>
> Kay,
>
> if you are reading, can you jump in and explain why /dev/root is a bad
> idea?

stat("/") is just the better approach for tools to find out what
"root" is, there is not much point in doing symlinks here just because
the kernel uses that name to mount internally.

/dev/root was never part of the default udev setup, it happened in the
distros init scripts, and only some distributions added that.

Newer filesystems like btrfs do not have an 1:1 fs:device relation
anyway, there cannot be a /dev/root symlink anymore, so tools need to
catch up here anyway, and the sooner the better. /dev/root is a
concept that will probably no longer exist in the future, because
filesystems will work differently than they used to.

As Peter said, the kernel should internally just use the name of the
kernel block device instead of inventing and exporting the name of an
artificial /dev/root node, which does not exist later in the real
system.

Kay

2013-03-22 03:00:59

by Rob Landley

[permalink] [raw]
Subject: Re: [PATCH] init: fix name of root device in /proc/mounts

On 03/20/2013 04:11:25 PM, William Hubbs wrote:
> On Wed, Mar 20, 2013 at 02:03:20AM -0500, Rob Landley wrote:
> > On 03/19/2013 07:20:17 PM, William Hubbs wrote:
> > > On Tue, Mar 19, 2013 at 04:17:11PM -0700, H. Peter Anvin wrote:
> > > > On 03/19/2013 03:28 PM, William Hubbs wrote:
> > > > > 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.
> >
> > What gave you that idea?
> >
> > wget http://landley.net/aboriginal/bin/system-image-i686.tar.bz2
> > extract it and ./run-emulator.sh and in there:
> >
> > (i686:1) /home # cat /proc/mounts
> > rootfs / rootfs rw 0 0
> > /dev/root / squashfs ro,relatime 0 0
> > proc /proc proc rw,relatime 0 0
> > sys /sys sysfs rw,relatime 0 0
> > dev /dev devtmpfs rw,relatime,size=63072k,nr_inodes=15768,mode=755
> 0 0
> > dev/pts /dev/pts devpts rw,relatime,mode=600 0 0
> > /tmp /tmp tmpfs rw,relatime 0 0
> > /home /home tmpfs rw,relatime 0 0
> >
> > Userspace can totally determine what /dev/root points to, I made
> mdev
> > do it in 2006 (udev started doing so shortly thereafter). Busybox
> git
> > commit a7e3d052.:4
>
> There are situations where it doesn't work though -- suppose that root
> is btrfs for example.

So you're saying there's a bug in btrfs?

> Also, the other message that answered you is correct, the udev
> maintainers say we should not be relying on /dev/root at all so to
> make
> it work distro packagers have to add a rule themselves.

These udev maintainers?

http://lkml.indiana.edu/hypermail/linux/kernel/1210.0/01889.html

This is the udev that got Katamari'd into systemd, not one of the forks
that ran screaming trying not to get sucked into the latest escapade of
King of All Cosmos?

Look, if you want to add /dev/root to devtmpfs, that makes a certain
amount of sense. But your patch seems to have missed do_mounts.c doing:

if (strncmp(root_device_name, "/dev/", 5) == 0)
root_device_name += 5;

Which means that if the user does "root=sda1" on the kernel command
line you're not passing an absolute path to create_dev():

- 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);

And last I checked that means /proc/mounts will have a relative path in
it...

I.E. you're modifying kernel code you're not familiar with to fix a
non-problem caused by your unfamiliarity with the corresponding
userspace code. I'm really not seeing the upside here.

Rob-