diff options
author | Alessandro Astone <ales.astone@gmail.com> | 2020-03-01 13:33:27 +0100 |
---|---|---|
committer | Alessandro Astone <ales.astone@gmail.com> | 2020-03-25 23:38:53 +0100 |
commit | e3ba93a60f2af21c0aeb8538ca3bbda083b83475 (patch) | |
tree | f4214d4a71ed24cea4809a25a5d2e93d9af27618 | |
parent | 3f55a863ac34969f95bfb38641747d2fd9939630 (diff) | |
download | android_bootable_recovery-e3ba93a60f2af21c0aeb8538ca3bbda083b83475.tar.gz android_bootable_recovery-e3ba93a60f2af21c0aeb8538ca3bbda083b83475.tar.bz2 android_bootable_recovery-e3ba93a60f2af21c0aeb8538ca3bbda083b83475.zip |
recovery: make /etc/fstab only include entries that match the detected fs type
* toybox's `mount` does not support multiple entries like we do,
so if we can detect the filesystem of an fstab enrtry print that
and only that one to /etc/fstab, so that mounting via toybox has
a better chance of succeding.
* as a bonus, this patch also gets rid of duplicates in /etc/fstab
caused by the fact that ReadDefaultFstab() combines entries from
DT and from recovery.fstab
Change-Id: Iec4ab38044054555d2a33da6f5d53de7716e7bee
-rw-r--r-- | roots.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
@@ -72,6 +72,9 @@ Volume* get_device_volumes() { return fstab->recs; } +// We need this declared for load_volume_table(). +Volume* get_entry_for_mount_point_detect_fs(const std::string&); + void load_volume_table() { fstab = fs_mgr_read_fstab_default(); if (!fstab) { @@ -87,24 +90,31 @@ void load_volume_table() { return; } - // Create a boring /etc/fstab so tools like Busybox work - FILE* file = fopen("/etc/fstab", "w"); - if (!file) { - LOG(ERROR) << "Unable to create /etc/fstab"; - } - + struct fstab* fake_fstab = static_cast<struct fstab *>(calloc(1, sizeof(struct fstab))); printf("recovery filesystem table\n"); printf("=========================\n"); for (int i = 0; i < fstab->num_entries; ++i) { const Volume* v = &fstab->recs[i]; printf(" %d %s %s %s %lld\n", i, v->mount_point, v->fs_type, v->blk_device, v->length); - if (file) { - write_fstab_entry(v, file); + if (fs_mgr_get_entry_for_mount_point(fake_fstab, v->mount_point) == NULL) { + const Volume* v_detectfs = get_entry_for_mount_point_detect_fs(v->mount_point); + if (!strcmp(v->fs_type, v_detectfs->fs_type)) { + fs_mgr_add_entry(fake_fstab, v->mount_point, v->fs_type, v->blk_device); + } } } printf("\n"); + + // Create a boring /etc/fstab so tools like Busybox work + FILE* file = fopen("/etc/fstab", "w"); if (file) { + for (int i = 0; i < fake_fstab->num_entries; ++i) { + write_fstab_entry(&fake_fstab->recs[i], file); + } fclose(file); + fs_mgr_free_fstab(fake_fstab); + } else { + LOG(ERROR) << "Unable to create /etc/fstab"; } } |