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

View file

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