From: Eric Andersen Date: Tue, 13 Jan 2004 11:39:22 +0000 (-0000) Subject: Fix a bug where mount could check the wrong device. st_rdev is the correct X-Git-Tag: 1_00_pre6~52 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1cda715bbcaba253ffb81463f6b9260154e7a32d;p=platform%2Fupstream%2Fbusybox.git 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 --- diff --git a/libbb/find_root_device.c b/libbb/find_root_device.c index c595321..836ce44 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)