[BusyBox 0000145]: Fix strange behavior when issue df with pseudo root device(/dev/root).

bugs at busybox.net bugs at busybox.net
Sun Sep 3 15:03:01 UTC 2006


A NOTE has been added to this issue. 
====================================================================== 
http://busybox.net/bugs/view.php?id=145 
====================================================================== 
Reported By:                tkato
Assigned To:                BusyBox
====================================================================== 
Project:                    BusyBox
Issue ID:                   145
Category:                   Standards Compliance
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             03-12-2005 20:11 PST
Last Modified:              09-03-2006 08:03 PDT
====================================================================== 
Summary:                    Fix strange behavior when issue df with pseudo root
device(/dev/root).
Description: 
Brent Roman reports following problem.

FYI, as long as I know, current busybox behavior follows the manner which

is described in Linux device
list(http://www.lanana.org/docs/device-list/devices-2.6+.txt).

--
     	Locally defined links

	The following links may be established locally to conform to
	the configuration of the system.  This is merely a tabulation
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
	of existing practice, and does not constitute a
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	recommendation.  However, if they exist, they should have the
        ^^^^^^^^^^^^^^^
	following uses.
[snip]
        /dev/root	root device	symbolic	Current root filesystem
--

If busybox meets /dev/root entry, it try to find real device name
of root device.
And then, it try to print a real device name instead.

The problem mentioned by Brent is caused by the behavior of
find_mount_device function.

The function returns error when
it is passed "/dev/root" as its argument.
Because it returns error if it stat syscall fail.

Current busybox'df may try to find real root device
to attempt to avoid this issue(Sorry if my interpretation
of the implementation is incorrect).

Certainly, this behavior make good if df's
argument is pathname("/").
But if the argument is "/dev/root", it returns error
and it does not try to find real root device.

It may be strange behavior from view of consistency.
Because operations mentioned above is performed in order
to know some stats of rootfs.

So, I've written the patch to fix this issue.

FYI, There is another problem which is that
"df /" exit silently if /etc/mtab is created as symbolic link to
/proc/mounts.

I show the issue as follows:
-- evidence
[ares at galaxy bin]$ ./busybox df /
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/hda1            238142564 108932032 117113588  48% /
[ares at galaxy bin]$ sudo mv /etc/mtab /etc/mtab.orig
[ares at galaxy bin]$ sudo ln -sf /proc/mounts /etc/mtab
[ares at galaxy bin]$ ./busybox df /
Filesystem           1k-blocks      Used Available Use% Mounted on
[ares at galaxy bin]$
-- evidence

This patch also fix this problem.

It may be useful for embedded systems,
because many people are concerned with
embedded systems uses /proc/mounts as /etc/mtab.


-- The problem which Brent reports

Larry,

I'm copying this to the list in case anyone there wants to
dig into this issue...

OK.  Guess I jumped the gun.
Here's some info, if you want to dig further

The system that produced the /dev/root: no such file or directory message
is running Fedora 2 with kernel 2.6.7.   Here's its /proc/mounts:

rootfs / rootfs rw 0 0
/dev/root / ext3 rw 0 0
/proc /proc proc rw,nodiratime 0 0
/sys /sys sysfs rw 0 0
none /dev/pts devpts rw 0 0
usbdevfs /proc/bus/usb usbdevfs rw 0 0
/dev/hda2 /boot ext3 rw 0 0
none /dev/shm tmpfs rw 0 0
/dev/hda6 /home ext3 rw 0 0
automount(pid1899) /net autofs rw 0 0
automount(pid1897) /misc autofs rw 0 0

When I run busybox df /dev/root on this box, it complains:

./df /dev/root
Filesystem           1k-blocks      Used Available Use% Mounted on
df: /dev/root: can't find mount point.

The system where coreutils df /dev/root produces:

$ /bin/df /dev/root
Filesystem           1K-blocks      Used Available Use% Mounted on
none                         0         0         0   -  /dev

$ /bin/df --version
df (coreutils) 5.2.1

$ uname -a
Linux bufflehead 2.4.26-win4lin-r12 http://busybox.net/bugs/view.php?id=22 Wed
Mar 9 22:55:58 PST 2005 i686
Pentium III (Coppermine) GenuineIntel GNU/Linux

$ cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / ext3 rw,noatime 0 0
none /dev devfs rw 0 0
none /proc proc rw 0 0
none /proc/bus/usb usbfs rw 0 0
none /dev/shm tmpfs rw 0 0
/dev/sdb2 /tmp ext3 rw,noatime 0 0
/dev/sdb5 /home ext3 rw,noatime 0 0
/dev/sda7 /redhat ext3 ro 0 0
/dev/hda3 /archive ext3 ro 0 0
/dev/hda1 /boot ext2 ro 0 0
/dev/sdb1 /boot-scsi ext2 ro 0 0
automount(pid2201) /net autofs rw 0 0
automount(pid2211) /smb autofs rw 0 0
automount(pid2221) /misc autofs rw 0 0
/dev/auto/cdr /misc/cdr iso9660 ro,nosuid,nodev 0 0


This box is running the latest gentoo "release"
busybox df /dev/root works properly on this box.

At *this* point I'm starting to suspect a change in glibc behavior
might be the root cause of this.  The busybox systems run
libc-2.2.5.  The gentoo box runs libc-2.3.4.  The fedora 2 box
runs libc-2.3.3.

-brent


======================================================================
Relationships       ID      Summary
----------------------------------------------------------------------
has duplicate       0000894 df.c Does not report info for "roo...
====================================================================== 

---------------------------------------------------------------------- 
 vda - 09-03-06 08:03  
---------------------------------------------------------------------- 
bbox df and coreutils df are giving different results for me too, but
_both_ are mostly useless. They fail miserable in this new era of multiple
mounts on the same directory...

# cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / ext3 rw,noatime,data=ordered 0 0
none /proc proc rw 0 0
none /sys sysfs rw 0 0
none /dev ramfs rw 0 0
/dev/root /.local ext3 rw,noatime,data=ordered 0 0
none /dev/pts devpts rw 0 0
automount(pid650) /.local/mnt/auto autofs
rw,fd=4,pgrp=650,timeout=15,minproto=2,maxproto=4,indirect 0 0
none /proc/bus/usb usbfs rw 0 0
# df
Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs                27870012   8269544  18184740  32% /
/dev/root             27870012   8269544  18184740  32% /
/dev/root             27870012   8269544  18184740  32% /.local
# ./busybox df
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/hda2             27870012   8269544  18184740  31% /
/dev/hda2             27870012   8269544  18184740  31% /.local

W/o parameters, bbox is even better (shows the real device mounted).
With parameters, both are giving nonsense (not shown).

Dunno what to do about this. 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
03-12-05 20:11  tkato          New Issue                                    
03-12-05 20:11  tkato          File Added: find_mount_point-fix1.patch          
         
03-16-05 12:27  andersen       Assigned To              andersen => BusyBox 
06-02-06 08:21  bernhardf      Relationship added       has duplicate 0000894
09-03-06 08:03  vda            Note Added: 0001612                          
======================================================================




More information about the busybox-cvs mailing list