aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Andersen <andersen@codepoet.org>2000-03-22 00:58:54 +0000
committerErik Andersen <andersen@codepoet.org>2000-03-22 00:58:54 +0000
commit016ffe93077975b01e84493d7cc303f78f70441a (patch)
treebeb56b390dfd7db3fb0239ba40e44d6bb5ad4fa7
parent0d068a20676144e9fd6796cc77764c420d785394 (diff)
downloadbusybox-016ffe93077975b01e84493d7cc303f78f70441a.tar.gz
Add in a nifty function for mount to use.
-Erik
-rw-r--r--utility.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/utility.c b/utility.c
index 29edbf1c4..37f698ea4 100644
--- a/utility.c
+++ b/utility.c
@@ -1469,6 +1469,42 @@ extern char *find_unused_loop_device(void)
}
#endif /* BB_FEATURE_MOUNT_LOOP */
+#if defined BB_MOUNT
+char* find_real_root_device_name(void)
+{
+ int gotIt=0;
+ DIR *dir;
+ struct dirent *entry;
+ struct stat statBuf, rootStat;
+ char fileName[BUFSIZ];
+
+ if (stat("/", &rootStat) != 0)
+ fatalError("Wierd. I could not stat '/'\n");
+
+ if (!(dir = opendir("/dev"));
+ fatalError("Wierd. I could not open '/dev'\n");
+
+ while((entry = readdir(dir)) != NULL) {
+ /* Must skip ".." since that is "/", and so we
+ * would get a false positive on ".." */
+
+ if (strcmp(entry->d_name, "..") == 0)
+ continue;
+
+ sprintf( fileName, "/dev/%s", entry->d_name);
+
+ if (stat(fileName, &statBuf) != 0)
+ continue;
+ if (statBuf.st_rdev == rootStat.st_rdev) {
+ return (strdup(fileName));
+ }
+ }
+
+ return( NULL);
+}
+#endif
+
+
#if defined BB_MTAB
#define whine_if_fstab_is_missing() {}
#else