[BusyBox] [PATCH] bug in find_real_root_device.c and code clean up
Tito
farmatito at tiscali.it
Wed Jul 28 11:51:21 UTC 2004
Hi,
after a couple hours of sleep I've put togheter a patch.
This patch is useful for:
1) remove an unused var from extern char *find_real_root_device_name(const char* name)
changing it to extern char *find_real_root_device_name(void).
2) fixes include/libbb.h, coreutils/df.c, util-linux/mount.c and util-linux/umount.c accordingly.
3) fixes a bug, really a false positive, in find_real_root_device_name() that happens if
in the /dev directory exists a link named root (/dev/root) that should be skipped but
is not. This affects applets like df that display wrong results like
#./busybox df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/root 4024188 148408 3671356 4% /
/dev/hdb3 4032124 41216 3786080 1% /home
rather than
# ./busybox df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/hdb1 4024188 148408 3671356 4% /
/dev/hdb3 4032124 41216 3786080 1% /home
Same thing for ./busybox mount.
Please apply.
Thanks in advance and ciao
Tito
-------------- next part --------------
--- include/libbb.h.orig 2004-06-22 10:07:15.000000000 +0000
+++ include/libbb.h 2004-07-28 10:00:33.618336752 +0000
@@ -134,7 +134,7 @@
char* filesystemType, long flags, char* string_flags);
extern void erase_mtab(const char * name);
extern long *find_pid_by_name( const char* pidName);
-extern char *find_real_root_device_name(const char* name);
+extern char *find_real_root_device_name(void);
extern char *bb_get_line_from_file(FILE *file);
extern char *bb_get_chomped_line_from_file(FILE *file);
extern int bb_copyfd_size(int fd1, int fd2, const off_t size);
--- coreutils/df.c.orig 2004-04-14 17:51:09.000000000 +0000
+++ coreutils/df.c 2004-07-28 10:01:23.588740096 +0000
@@ -130,7 +130,7 @@
} else if (strcmp(device, "/dev/root") == 0) {
/* Adjusts device to be the real root device,
* or leaves device alone if it can't find it */
- if ((device = find_real_root_device_name(device)) == NULL) {
+ if ((device = find_real_root_device_name()) == NULL) {
goto SET_ERROR;
}
}
--- util-linux/mount.c.orig 2004-05-26 21:26:07.000000000 +0000
+++ util-linux/mount.c 2004-07-28 10:04:44.624178064 +0000
@@ -345,7 +345,7 @@
if (strcmp(blockDevice, "rootfs") == 0) {
continue;
} else if (strcmp(blockDevice, "/dev/root") == 0) {
- blockDevice = find_real_root_device_name(blockDevice);
+ blockDevice = find_real_root_device_name();
}
if (!onlytype || (strcmp(m->mnt_type, onlytype) == 0)) {
printf("%s on %s type %s (%s)\n", blockDevice, m->mnt_dir,
--- util-linux/umount.c.orig 2004-03-15 08:29:22.000000000 +0000
+++ util-linux/umount.c 2004-07-28 10:06:35.805275968 +0000
@@ -115,7 +115,7 @@
} else if (strcmp(cur->device, "/dev/root") == 0) {
/* Adjusts device to be the real root device,
* or leaves device alone if it can't find it */
- cur->device = find_real_root_device_name(cur->device);
+ cur->device = find_real_root_device_name();
}
#endif
return cur->device;
--- libbb/find_root_device.c.orig 2004-03-15 08:28:42.000000000 +0000
+++ libbb/find_root_device.c 2004-07-28 11:40:48.269970720 +0000
@@ -27,7 +27,7 @@
-extern char *find_real_root_device_name(const char* name)
+extern char *find_real_root_device_name(void)
{
DIR *dir;
struct dirent *entry;
@@ -54,6 +54,9 @@
* would get a false positive on ".." */
if (myname[0] == '.' && myname[1] == '.' && !myname[2])
continue;
+ /* if there is a link named root skip it too */
+ if (strcmp(myname, "root")==0)
+ continue;
fileName = concat_path_file("/dev", myname);
More information about the busybox
mailing list