[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: busybox: doesn't use /etc/mtab



Petr Cech <cech@atrey.karlin.mff.cuni.cz> writes:

> Hi,
> I'm just working on integrating new busybox into dbootstrap.
> The old mount_xx()/do_umount() used /etc/mtab for information about
> mounted filesystems. The new busybox uses /proc/mounts. These two
> files are almost identical  (except for /proc/mounts lists
> root device as /dev/root instead of the correct one, and misses
> sometimes additional options).
> 
> I think that the old way (/etc/mtab) should be used.
> What if /proc is not mounted? And of source dbootstrap needs to be updated.

/etc/mdtab can be wrong, desn´t work when partitions are changed and
certainly doesn´t work on read-only system.

/proc/mounts is the right way[tm] and should be used when
available. If you need the root device you can look into /etc/fstab,
but that can be wrong too (and is realy ugly i it is).

For my demo-fs I use a small script to create /dev/root to point to
the right device:

------------------- /etc/init.d/mkdev.sh -----------------------
#! /bin/sh

mke2fs /dev/ram1
mount /dev/ram1 /write_and_forget
cd /write_and_forget
tar -xzf /write_and_forget.tar.gz
mknod /write_and_forget/dev/root b `echo \`cat /proc/sys/kernel/real-root-dev\` 
/ 256 | bc` `echo \`cat /proc/sys/kernel/real-root-dev\` - \`cat /proc/sys/kerne
l/real-root-dev\` / 256 \* 256 | bc`
-----------------------------------------------------------------

All except the mknod line is to setup a writeable ramdisk before
trying to write anything. The /dev/root links to
/write_and_forget/dev/root and will be set to whatever the kernel
realy bootet from (too bad /proc/sys/kernel/rea-root-dev is the hex
code and not the major and minor) by the mknod line.

The script will be called by /etc/rcS.d/S08mkdev.sh, right after
/etc/rcS.d/S07mountproc.sh, so proc is awailable.

May the Source be with you.
			Goswin

PS: /proc/sys/kernel/real-root-dev should accept and give major and
minor as text and not in hex.


Reply to: