lkml.org 
[lkml]   [1999]   [Oct]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] replacing "/dev/root" in /proc/mounts
On Thu Oct 07, 1999 at 07:42:13AM -0400, Wakko Warner wrote:
>
> > Having just read the util-linux mount source more carefully, I realised
> > that the /etc/mtab entry mount writes is correct and that has to come
>
> Actually, it does come from somewhere. From /etc/init.d/checkroot.sh

Umm. Sure. Mount writes /etc/mtab. To write /etc/mtab with the correct
root /dev/<foo> name, mount calls getfsfile("/").

> > from somewhere. I couldn't believe they would abuse stat, and I was right;
>
> What do you mean, abuse stat?

I mean, abuseing stat by making foolish assumptions about what a dev_t contains.
In your stat code (and my evil stat example) you have violated the interface,
since you check if ((device >> 8 & 0xff) == 0) for example. And when kdev_t
becomes a struct (which I dearly hope it does)... boom.

> Where does getfsfile get it's information from? The kernel? I don't have a
> manpage for it.


Presumably, glibc uses stat hack, i.e. major=stat.st_dev>>8,
minor=stat.st_dev&0xff. I suppose if there is one piece of code where
cheating and knowing about kernel internals is acceptable, the C library
is probably it. When kdev_t becomes a struct, I can imagine some libc
hacking will be needed anyways.


> > Ok, bad example, sorry. however, my point was that the kernel is lying.
>
> Actually, we could just put the contents of root= in /proc/mounts, couldn't
> we?


hmm, could work. Do you know where root=<foo> gets set? That could
certainly do the job, if root=<foo>is actually set...


> > > So, what happens when / is an nfs mount? [wakko@gohan:/home/wakko]
> > > cat /proc/mounts /dev/root / nfs rw,addr=192.168.2.3 0 0
> > > [wakko@gohan:/home/wakko]
> >
> > same thing as always. I didn't mess with NFS (which is a special case in
> > the kernel mount code), I just touched the non-NFS cases. I don't know
> > what can be done to make the NFS case in /proc/mounts more correct.
>
> Actually, it would probably be correct in saying /dev/nfs. I'm not sure
> what the point of having the / listed in /proc/mounts as being correct
> anyway. The kernel always knows how to do -o remounts with it (and any
> other file system), and is never unmountable so you couldn't unmount then
> mount back.

True, /dev/nfs might be better in that case.

> Maybe I'm confused as to what you wanted in the first message. How is it
> helpful? (of course, it could be annoying) I thought about making a script
> that would actually create /dev/root and it be a symlink to the real device.

My desire was to eliminate the need for /etc/mtab. I have a read-only
root filesystem on my current project, and needing a separate mtab file
when an _almost_ identical and always correct /proc/mounts file exists
led me to try and make the kernel do the Right Thing(tm).

I now have this implemented using /proc/mounts (and no
/etc/mtab), except I special case the device name, where I test
if (strcmp(deviceName, "/dev/root")==0) {
deviceName=(getfsfile("/"))->fs_spec);
}

Works for now (without needing the kernel patch I sent). Of course it
would be better if I didn't need to special case /dev/root. Presumably
when the kernel starts using a struct for kdev_t, /proc/mounts can then
do the right thing.

-Erik

--
Erik B. Andersen Web: http://www.xmission.com/~andersen/
email: andersee@debian.org
--This message was written using 73% post-consumer electrons--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:54    [W:0.139 / U:0.280 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site