lkml.org 
[lkml]   [1999]   [Oct]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch] replacing "/dev/root" in /proc/mounts

There seems to currently be no mechanism (at least none I am aware of)
from user space to determine what the root device name _really_ is. The
kernel knows what the kdev_t for the root filesystem's device is, but
it apparently has no method of sharing that knowledge with userspace.
This patch lets /proc/mounts tell userspace the major/minor number of
the root filesystem. The patch applies to both 2.3.18 and 2.2.12.

some background:

I'm working on some _very_ stripped down utils for embedded systems, and
so I wanted to use /proc/mounts instead of making my own /etc/mtab file
<rant>and why do folks put mtab in /etc instead of /var? </rant>

Anyway, I noticed the following

[andersen@dillweed andersen]$ cat /proc/mounts
/dev/root / ext2 rw 0 0
proc /proc proc rw 0 0

It claims the root device is /dev/root. Ugh, at reboot time, you can't
remount /dev/root ro (since there isn't really a /dev/root), so you
can't get a clean reboot.

So I looked through the source and found the spot in
/usr/src/linux/fs/super.c where folks stuck the "/dev/root" kludge,
and realised they did this since the kernel doesn't have a real
/dev/<something> name for the root device (since the root filesystem
isn't yet mounted that makes sense). The kernel _does_ know the root
filesystem's device major and minor number, so it seems like a more
reasonable entry would be kdevname(ROOT_DEV), which can then be parsed
from user space and used to umount /.

So, unless somebody knows of another way to find out from user space
what the root filesystem's device name is, I propose the following
patch. With this in place, you can get results which allow you to find
the root filesystem's device, i.e:

[andersen@dillweed src]$ cat /proc/mounts
ide0(3,3) / ext2 rw 0 0
proc /proc proc rw 0 0

-Erik

p.s. please CC me on any followup, as I am not currently
subscribed.

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



--- linux/fs/super.c.orig Wed Oct 6 15:57:13 1999
+++ linux/fs/super.c Wed Oct 6 18:43:13 1999
@@ -1205,7 +1205,7 @@
* and bad superblock on root device.
*/
printk("VFS: Cannot open root device %s\n",
- kdevname(ROOT_DEV));
+ bdevname(ROOT_DEV));
else for (fs_type = file_systems ; fs_type ; fs_type = fs_type->next) {
if (!(fs_type->fs_flags & FS_REQUIRES_DEV))
continue;
@@ -1217,14 +1217,14 @@
printk ("VFS: Mounted root (%s filesystem)%s.\n",
fs_type->name,
(sb->s_flags & MS_RDONLY) ? " readonly" : "");
- vfsmnt = add_vfsmnt(sb, "/dev/root", "/");
+ vfsmnt = add_vfsmnt(sb, bdevname(ROOT_DEV), "/");
if (vfsmnt)
return;
panic("VFS: add_vfsmnt failed for root fs");
}
}
panic("VFS: Unable to mount root fs on %s",
- kdevname(ROOT_DEV));
+ bdevname(ROOT_DEV));
}


@@ -1286,7 +1286,7 @@
return error;
}
remove_vfsmnt(old_root_dev);
- vfsmnt = add_vfsmnt(old_root->d_sb, "/dev/root.old", put_old);
+ vfsmnt = add_vfsmnt(old_root->d_sb, bdevname(ROOT_DEV), put_old);
if (vfsmnt) {
d_mount(dir_d,old_root);
return 0;
-
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.087 / U:0.740 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site