diff options
-rw-r--r-- | utility.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -1469,6 +1469,42 @@ extern char *find_unused_loop_device(void) | |||
1469 | } | 1469 | } |
1470 | #endif /* BB_FEATURE_MOUNT_LOOP */ | 1470 | #endif /* BB_FEATURE_MOUNT_LOOP */ |
1471 | 1471 | ||
1472 | #if defined BB_MOUNT | ||
1473 | char* find_real_root_device_name(void) | ||
1474 | { | ||
1475 | int gotIt=0; | ||
1476 | DIR *dir; | ||
1477 | struct dirent *entry; | ||
1478 | struct stat statBuf, rootStat; | ||
1479 | char fileName[BUFSIZ]; | ||
1480 | |||
1481 | if (stat("/", &rootStat) != 0) | ||
1482 | fatalError("Wierd. I could not stat '/'\n"); | ||
1483 | |||
1484 | if (!(dir = opendir("/dev")); | ||
1485 | fatalError("Wierd. I could not open '/dev'\n"); | ||
1486 | |||
1487 | while((entry = readdir(dir)) != NULL) { | ||
1488 | /* Must skip ".." since that is "/", and so we | ||
1489 | * would get a false positive on ".." */ | ||
1490 | |||
1491 | if (strcmp(entry->d_name, "..") == 0) | ||
1492 | continue; | ||
1493 | |||
1494 | sprintf( fileName, "/dev/%s", entry->d_name); | ||
1495 | |||
1496 | if (stat(fileName, &statBuf) != 0) | ||
1497 | continue; | ||
1498 | if (statBuf.st_rdev == rootStat.st_rdev) { | ||
1499 | return (strdup(fileName)); | ||
1500 | } | ||
1501 | } | ||
1502 | |||
1503 | return( NULL); | ||
1504 | } | ||
1505 | #endif | ||
1506 | |||
1507 | |||
1472 | #if defined BB_MTAB | 1508 | #if defined BB_MTAB |
1473 | #define whine_if_fstab_is_missing() {} | 1509 | #define whine_if_fstab_is_missing() {} |
1474 | #else | 1510 | #else |