aboutsummaryrefslogtreecommitdiff
path: root/libbb/find_root_device.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-01-13 11:39:22 +0000
committerEric Andersen <andersen@codepoet.org>2004-01-13 11:39:22 +0000
commit1cda715bbcaba253ffb81463f6b9260154e7a32d (patch)
tree9a0ba9636cfe7c96b86d89fc6b6521ea1408985e /libbb/find_root_device.c
parent7c87b67c08b7fe379f203ecdfff6bb7d604719a5 (diff)
downloadbusybox-w32-1cda715bbcaba253ffb81463f6b9260154e7a32d.tar.gz
busybox-w32-1cda715bbcaba253ffb81463f6b9260154e7a32d.tar.bz2
busybox-w32-1cda715bbcaba253ffb81463f6b9260154e7a32d.zip
Fix a bug where mount could check the wrong device. st_rdev is the correct
device ID iff the named file is a character or block special device. Otherwise it is meaningless junk, in which case st_dev should be used. This was done incorrectly, which could cause mount to display bogus mount info. -Erik
Diffstat (limited to 'libbb/find_root_device.c')
-rw-r--r--libbb/find_root_device.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libbb/find_root_device.c b/libbb/find_root_device.c
index c595321df..836ce44d5 100644
--- a/libbb/find_root_device.c
+++ b/libbb/find_root_device.c
@@ -38,8 +38,11 @@ extern char *find_real_root_device_name(const char* name)
38 if (stat("/", &rootStat) != 0) 38 if (stat("/", &rootStat) != 0)
39 bb_perror_msg("could not stat '/'"); 39 bb_perror_msg("could not stat '/'");
40 else { 40 else {
41 if ((dev = rootStat.st_rdev)==0) 41 /* This check is here in case they pass in /dev name */
42 dev=rootStat.st_dev; 42 if ((rootStat.st_mode & S_IFMT) == S_IFBLK)
43 dev = rootStat.st_rdev;
44 else
45 dev = rootStat.st_dev;
43 46
44 dir = opendir("/dev"); 47 dir = opendir("/dev");
45 if (!dir) 48 if (!dir)