aboutsummaryrefslogtreecommitdiffstats
path: root/roots.cpp
diff options
context:
space:
mode:
authorDan Pasanen <dan.pasanen@gmail.com>2015-01-13 21:25:26 -0600
committerTom Marshall <tdm@cyngn.com>2015-11-25 15:35:47 -0800
commitd644eb58fde7d39a416850af3caeb4cbce514ec8 (patch)
tree8a42e59be879186f543a96f49c929bb5796dd1db /roots.cpp
parent0176875fba9ceb5674dfd71108fb66fa53164791 (diff)
downloadbootable_recovery-d644eb58fde7d39a416850af3caeb4cbce514ec8.zip
bootable_recovery-d644eb58fde7d39a416850af3caeb4cbce514ec8.tar.gz
bootable_recovery-d644eb58fde7d39a416850af3caeb4cbce514ec8.tar.bz2
recovery: autodetect filesystem type
* Multiple fstab lines (supported in android) cause recovery to fail to mount partitions if the fs type is not the same as the first fstab entry. So when we attempt to find an fstab entry that matches a path for an f2fs, ext4 or vfat type, check it against blkid's determination of what filesystem type it is. If there is a discrepancy, query fs_mgr for the next possible entry that matches that path until either we find one that is good, or run out of fstab entries. * Also attempt to autodetect the filesystem type for mounting from update.zips. Change-Id: Ib6f4535dd88ef714ae1ca6fb0ffae1c7dac0f7ce
Diffstat (limited to 'roots.cpp')
-rw-r--r--roots.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/roots.cpp b/roots.cpp
index d27a2dd..3c51c35 100644
--- a/roots.cpp
+++ b/roots.cpp
@@ -37,6 +37,7 @@ extern "C" {
}
#include "voldclient.h"
+#include <blkid/blkid.h>
static struct fstab *fstab = NULL;
@@ -143,7 +144,27 @@ bool volume_is_verity(Volume *v)
}
Volume* volume_for_path(const char* path) {
- return fs_mgr_get_entry_for_mount_point(fstab, path);
+ Volume *rec = fs_mgr_get_entry_for_mount_point(fstab, path);
+
+ if (rec == NULL)
+ return rec;
+
+ if (strcmp(rec->fs_type, "ext4") == 0 || strcmp(rec->fs_type, "f2fs") == 0 ||
+ strcmp(rec->fs_type, "vfat") == 0) {
+ char *detected_fs_type = blkid_get_tag_value(NULL, "TYPE", rec->blk_device);
+
+ if (detected_fs_type == NULL)
+ return rec;
+
+ Volume *fetched_rec = rec;
+ while (rec != NULL && strcmp(rec->fs_type, detected_fs_type) != 0)
+ rec = fs_mgr_get_entry_for_mount_point_after(rec, fstab, path);
+
+ if (rec == NULL)
+ return fetched_rec;
+ }
+
+ return rec;
}
Volume* volume_for_label(const char* label) {