aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)
if (stat("/", &rootStat) != 0)
bb_perror_msg("could not stat '/'");
else {
- if ((dev = rootStat.st_rdev)==0)
- dev=rootStat.st_dev;
+ /* This check is here in case they pass in /dev name */
+ if ((rootStat.st_mode & S_IFMT) == S_IFBLK)
+ dev = rootStat.st_rdev;
+ else
+ dev = rootStat.st_dev;
dir = opendir("/dev");
if (!dir)