Merge "fs_mgr: remount: manufacture a missing / entry for default fstab"

This commit is contained in:
Treehugger Robot 2019-03-20 15:01:16 +00:00 committed by Gerrit Code Review
commit 4dd15cbe24
2 changed files with 22 additions and 7 deletions

View File

@ -176,6 +176,15 @@ int main(int argc, char* argv[]) {
fstab_read = android::fs_mgr::ReadFstabFromFile(fstab_file, &fstab);
} else {
fstab_read = android::fs_mgr::ReadDefaultFstab(&fstab);
// Manufacture a / entry from /proc/mounts if missing.
if (!GetEntryForMountPoint(&fstab, "/system") && !GetEntryForMountPoint(&fstab, "/")) {
android::fs_mgr::Fstab mounts;
if (android::fs_mgr::ReadFstabFromFile("/proc/mounts", &mounts)) {
if (auto entry = GetEntryForMountPoint(&mounts, "/")) {
if (entry->fs_type != "rootfs") fstab.emplace_back(*entry);
}
}
}
}
if (!fstab_read || fstab.empty()) {
PLOG(ERROR) << "Failed to read fstab";
@ -211,21 +220,21 @@ int main(int argc, char* argv[]) {
// Do we know about the partition?
auto it = std::find_if(fstab.begin(), fstab.end(), find_part);
if (it == fstab.end()) {
LOG(ERROR) << "Unknown partition " << partition << ", skipping";
LOG(ERROR) << "Unknown partition " << argv[optind] << ", skipping";
retval = UNKNOWN_PARTITION;
continue;
}
// Is that one covered by an existing overlayfs?
auto wrap = is_wrapped(overlayfs_candidates, *it);
if (wrap) {
LOG(INFO) << "partition " << partition << " covered by overlayfs for "
LOG(INFO) << "partition " << argv[optind] << " covered by overlayfs for "
<< wrap->mount_point << ", switching";
partition = system_mount_point(*wrap);
}
// Is it a remountable partition?
it = std::find_if(all.begin(), all.end(), find_part);
if (it == all.end()) {
LOG(ERROR) << "Invalid partition " << partition << ", skipping";
LOG(ERROR) << "Invalid partition " << argv[optind] << ", skipping";
retval = INVALID_PARTITION;
continue;
}

View File

@ -514,8 +514,8 @@ skip_administrative_mounts() {
cat -
fi |
grep -v \
-e "^\(overlay\|tmpfs\|none\|sysfs\|proc\|selinuxfs\|debugfs\) " \
-e "^\(bpf\|cg2_bpf\|pstore\|tracefs\|adb\|mtp\|ptp\|devpts\) " \
-e "^\(overlay\|tmpfs\|none\|sysfs\|proc\|selinuxfs\|debugfs\|bpf\) " \
-e "^\(binfmt_misc\|cg2_bpf\|pstore\|tracefs\|adb\|mtp\|ptp\|devpts\) " \
-e "^\(/data/media\|/dev/block/loop[0-9]*\) " \
-e "^rootfs / rootfs rw," \
-e " /\(cache\|mnt/scratch\|mnt/vendor/persist\|persist\|metadata\) "
@ -608,7 +608,7 @@ fi
D=`get_property ro.serialno`
[ -n "${D}" ] || D=`get_property ro.boot.serialno`
[ -z "${D}" ] || ANDROID_SERIAL=${D}
[ -z "${D}" -o -n "${ANDROID_SERIAL}" ] || ANDROID_SERIAL=${D}
USB_SERIAL=
[ -z "${ANDROID_SERIAL}" ] || USB_SERIAL=`find /sys/devices -name serial |
grep usb |
@ -998,8 +998,14 @@ echo "${GREEN}[ OK ]${NORMAL} /system/lib/bootstrap/libc.so content remain
echo "${GREEN}[ RUN ]${NORMAL} flash vendor, confirm its content disappears" >&2
H=`adb_sh echo '${HOSTNAME}' </dev/null 2>/dev/null`
is_bootloader_fastboot=false
# cuttlefish?
[ X"${H}" != X"${H#vsoc}" ] || is_bootloader_fastboot=true
is_userspace_fastboot=false
if [ -z "${ANDROID_PRODUCT_OUT}" ]; then
if ! ${is_bootloader_fastboot}; then
echo "${ORANGE}[ WARNING ]${NORMAL} does not support fastboot, skipping"
elif [ -z "${ANDROID_PRODUCT_OUT}" ]; then
echo "${ORANGE}[ WARNING ]${NORMAL} build tree not setup, skipping"
elif [ ! -s "${ANDROID_PRODUCT_OUT}/vendor.img" ]; then
echo "${ORANGE}[ WARNING ]${NORMAL} vendor image missing, skipping"