+static int doRemount = FALSE;
+extern const char mtab_file[]; /* Defined in utility.c */
+
+
+
+/* These functions are here because the getmntent functions do not appear
+ * to be re-entrant, which leads to all sorts of problems when we try to
+ * use them recursively - randolph
+ *
+ * TODO: Perhaps switch to using Glibc's getmntent_r
+ * -Erik
+ */
+void mtab_read(void)
+{
+ struct _mtab_entry_t *entry = NULL;
+ struct mntent *e;
+ FILE *fp;
+
+ if (mtab_cache != NULL)
+ return;
+
+ if ((fp = setmntent(mtab_file, "r")) == NULL) {
+ error_msg("Cannot open %s", mtab_file);
+ return;
+ }
+ while ((e = getmntent(fp))) {
+ entry = xmalloc(sizeof(struct _mtab_entry_t));
+ entry->device = strdup(e->mnt_fsname);
+ entry->mountpt = strdup(e->mnt_dir);
+ entry->next = mtab_cache;
+ mtab_cache = entry;
+ }
+ endmntent(fp);
+}
+
+char *mtab_getinfo(const char *match, const char which)
+{
+ struct _mtab_entry_t *cur = mtab_cache;
+
+ while (cur) {
+ if (strcmp(cur->mountpt, match) == 0 ||
+ strcmp(cur->device, match) == 0) {
+ if (which == MTAB_GETMOUNTPT) {
+ return cur->mountpt;
+ } else {
+#if !defined BB_FEATURE_MTAB_SUPPORT
+ if (strcmp(cur->device, "/dev/root") == 0) {
+ /* Adjusts device to be the real root device,
+ * or leaves device alone if it can't find it */
+ find_real_root_device_name( cur->device);
+ return ( cur->device);
+ }
+#endif
+ return cur->device;
+ }
+ }
+ cur = cur->next;
+ }
+ return NULL;
+}
+
+char *mtab_first(void **iter)
+{
+ struct _mtab_entry_t *mtab_iter;