[patch] fix find_mount_point() (bug #145)
Bernhard Fischer
rep.nop at aon.at
Wed Mar 29 10:25:04 UTC 2006
Hi,
I'll check in the attached patch to fix find_mount_point() for the case
that / is /dev/root.
This closes bug #145 (http://bugs.busybox.net/view.php?id=145)
Previously, in this case, we got:
# df /
Filesystem 1k-blocks Used Available Use% Mounted on
#
i.e. nothing.
The patch fixes this so it correctly does:
# ./busybox df /
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/root 121459 29274 88423 25% /
The mtab to reproduce this problem is:
# cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / ext3 rw 0 0
none /dev devfs rw 0 0
/proc /proc proc rw 0 0
devpts /dev/pts devpts rw 0 0
tmpfs /dev/shm tmpfs rw 0 0
-------------- next part --------------
Index: busybox/libbb/find_mount_point.c
===================================================================
--- busybox/libbb/find_mount_point.c (revision 14683)
+++ busybox/libbb/find_mount_point.c (working copy)
@@ -4,19 +4,7 @@
*
* Copyright (C) 1999-2004 by Erik Andersen <andersen at codepoet.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*/
#include <stdio.h>
@@ -53,12 +41,15 @@ struct mntent *find_mount_point(const ch
while ((mountEntry = getmntent(mountTable)) != 0) {
- if(strcmp(name, mountEntry->mnt_dir) == 0
- || strcmp(name, mountEntry->mnt_fsname) == 0) /* String match. */
- break;
- if (stat(mountEntry->mnt_fsname, &s) == 0 && s.st_rdev == mountDevice) /* Match the device. */
- break;
- if (stat(mountEntry->mnt_dir, &s) == 0 && s.st_dev == mountDevice) /* Match the directory's mount point. */
+ if (strcmp(mountEntry->mnt_fsname, "rootfs") == 0)
+ continue; /* Seen rootfs, continue to look for real dev */
+ if ((strcmp(name, mountEntry->mnt_dir) == 0
+ || strcmp(name, mountEntry->mnt_fsname) == 0) /* String match */
+ || (stat(mountEntry->mnt_fsname, &s) == 0 &&
+ s.st_rdev == mountDevice) /* Match the device */
+ || (stat(mountEntry->mnt_dir, &s) == 0 &&
+ s.st_dev == mountDevice) /* Match the dir's mount point */
+ )
break;
}
endmntent(mountTable);
More information about the busybox
mailing list