aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-08-03 00:14:02 +0000
committerEric Andersen <andersen@codepoet.org>2004-08-03 00:14:02 +0000
commit93d7fba89288db6f9263c0ce8026f277bc4649e0 (patch)
treeb8a572b7a2ccc68c5edad3a9691fbb017d7a39ae
parentec91de762a7d14cbed5e5972279d2378ae2e5a27 (diff)
downloadbusybox-93d7fba89288db6f9263c0ce8026f277bc4649e0.tar.gz
Tito, farmatito at tiscali dot it writes:
Hi to all, 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
-rw-r--r--coreutils/df.c2
-rw-r--r--include/libbb.h2
-rw-r--r--libbb/find_root_device.c8
-rw-r--r--util-linux/mount.c2
-rw-r--r--util-linux/umount.c2
5 files changed, 10 insertions, 6 deletions
diff --git a/coreutils/df.c b/coreutils/df.c
index cff69fe1a..ba2e7ccc9 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -130,7 +130,7 @@ extern int df_main(int argc, char **argv)
} 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;
}
}
diff --git a/include/libbb.h b/include/libbb.h
index c52e65555..afbd0203e 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -134,7 +134,7 @@ extern void write_mtab(char* blockDevice, char* directory,
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);
diff --git a/libbb/find_root_device.c b/libbb/find_root_device.c
index 81824a216..2600ce5e0 100644
--- a/libbb/find_root_device.c
+++ b/libbb/find_root_device.c
@@ -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,7 +54,11 @@ extern char *find_real_root_device_name(const char* name)
* would get a false positive on ".." */
if (myname[0] == '.' && myname[1] == '.' && !myname[2])
continue;
-
+#ifdef CONFIG_FEATURE_DEVFS
+ /* if there is a link named /dev/root skip that too */
+ if (strcmp(myname, "root")==0)
+ continue;
+#endif
fileName = concat_path_file("/dev", myname);
/* Some char devices have the same dev_t as block
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 0bc46ecb5..b059d7094 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -345,7 +345,7 @@ static void show_mounts(char *onlytype)
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,
diff --git a/util-linux/umount.c b/util-linux/umount.c
index 37a8f061e..21c2e6e4d 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -115,7 +115,7 @@ static char *mtab_getinfo(const char *match, const char which)
} 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;