Merge changes I3506c8e7,I198c0e8c,I8a5d4e36

am: 6bd04c1570

Change-Id: If0bf047ecc94463415455ad48e82390dbef6b8a4
This commit is contained in:
Mark Salyzyn 2019-03-06 14:40:21 -08:00 committed by android-build-merger
commit 492ae86814
2 changed files with 76 additions and 26 deletions

View file

@ -263,35 +263,43 @@ int main(int argc, char* argv[]) {
// Check verity and optionally setup overlayfs backing. // Check verity and optionally setup overlayfs backing.
auto reboot_later = false; auto reboot_later = false;
auto uses_overlayfs = fs_mgr_overlayfs_valid() != OverlayfsValidResult::kNotSupported;
for (auto it = partitions.begin(); it != partitions.end();) { for (auto it = partitions.begin(); it != partitions.end();) {
auto& entry = *it; auto& entry = *it;
auto& mount_point = entry.mount_point; auto& mount_point = entry.mount_point;
if (fs_mgr_is_verity_enabled(entry)) { if (fs_mgr_is_verity_enabled(entry)) {
LOG(WARNING) << "Verity enabled on " << mount_point; retval = VERITY_PARTITION;
if (can_reboot && if (android::base::GetProperty("ro.boot.vbmeta.devices_state", "") != "locked") {
(android::base::GetProperty("ro.boot.vbmeta.devices_state", "") != "locked")) {
if (AvbOps* ops = avb_ops_user_new()) { if (AvbOps* ops = avb_ops_user_new()) {
auto ret = avb_user_verity_set( auto ret = avb_user_verity_set(
ops, android::base::GetProperty("ro.boot.slot_suffix", "").c_str(), ops, android::base::GetProperty("ro.boot.slot_suffix", "").c_str(),
false); false);
avb_ops_user_free(ops); avb_ops_user_free(ops);
if (ret) { if (ret) {
if (fs_mgr_overlayfs_valid() == OverlayfsValidResult::kNotSupported) { LOG(WARNING) << "Disable verity for " << mount_point;
retval = VERITY_PARTITION; reboot_later = can_reboot;
if (reboot_later) {
// w/o overlayfs available, also check for dedupe // w/o overlayfs available, also check for dedupe
reboot_later = true; if (!uses_overlayfs) {
++it; ++it;
continue; continue;
}
reboot(false);
} }
reboot(false);
} else if (fs_mgr_set_blk_ro(entry.blk_device, false)) { } else if (fs_mgr_set_blk_ro(entry.blk_device, false)) {
fec::io fh(entry.blk_device.c_str(), O_RDWR); fec::io fh(entry.blk_device.c_str(), O_RDWR);
if (fh && fh.set_verity_status(false)) reboot_later = true; if (fh && fh.set_verity_status(false)) {
LOG(WARNING) << "Disable verity for " << mount_point;
reboot_later = can_reboot;
if (reboot_later && !uses_overlayfs) {
++it;
continue;
}
}
} }
} }
} }
LOG(ERROR) << "Skipping " << mount_point; LOG(ERROR) << "Skipping " << mount_point;
retval = VERITY_PARTITION;
it = partitions.erase(it); it = partitions.erase(it);
continue; continue;
} }
@ -318,7 +326,8 @@ int main(int argc, char* argv[]) {
} }
// Mount overlayfs. // Mount overlayfs.
if (!fs_mgr_overlayfs_mount_all(&partitions)) { errno = 0;
if (!fs_mgr_overlayfs_mount_all(&partitions) && errno) {
retval = BAD_OVERLAY; retval = BAD_OVERLAY;
PLOG(ERROR) << "Can not mount overlayfs for partitions"; PLOG(ERROR) << "Can not mount overlayfs for partitions";
} }
@ -346,11 +355,15 @@ int main(int argc, char* argv[]) {
break; break;
} }
if ((mount_point == "/") && (rentry.mount_point == "/system")) { if ((mount_point == "/") && (rentry.mount_point == "/system")) {
if (blk_device != "/dev/root") blk_device = rentry.blk_device; blk_device = rentry.blk_device;
mount_point = "/system"; mount_point = "/system";
break; break;
} }
} }
if (blk_device == "/dev/root") {
auto from_fstab = GetEntryForMountPoint(&fstab, mount_point);
if (from_fstab) blk_device = from_fstab->blk_device;
}
fs_mgr_set_blk_ro(blk_device, false); fs_mgr_set_blk_ro(blk_device, false);
// Now remount! // Now remount!

View file

@ -48,6 +48,7 @@ NORMAL="${ESCAPE}[0m"
TMPDIR=${TMPDIR:-/tmp} TMPDIR=${TMPDIR:-/tmp}
print_time=false print_time=false
start_time=`date +%s` start_time=`date +%s`
ACTIVE_SLOT=
## ##
## Helper Functions ## Helper Functions
@ -77,6 +78,7 @@ inAdb() {
wc -l | grep '^1$' >/dev/null wc -l | grep '^1$' >/dev/null
fi fi
} }
[ "USAGE: inRecovery [ "USAGE: inRecovery
Returns: true if device is in recovery mode" ] Returns: true if device is in recovery mode" ]
@ -221,15 +223,23 @@ format_duration() {
Returns: waits until the device has returned for adb or optional timeout" ] Returns: waits until the device has returned for adb or optional timeout" ]
adb_wait() { adb_wait() {
local ret
if [ -n "${1}" ]; then if [ -n "${1}" ]; then
echo -n ". . . waiting `format_duration ${1}`" ${ANDROID_SERIAL} ${USB_ADDRESS} "${CR}" echo -n ". . . waiting `format_duration ${1}`" ${ANDROID_SERIAL} ${USB_ADDRESS} "${CR}"
timeout --preserve-status --signal=KILL ${1} adb wait-for-device 2>/dev/null timeout --preserve-status --signal=KILL ${1} adb wait-for-device 2>/dev/null
local ret=${?} ret=${?}
echo -n " ${CR}" echo -n " ${CR}"
return ${ret}
else else
adb wait-for-device adb wait-for-device
ret=${?}
fi fi
if [ 0 = ${ret} -a -n "${ACTIVE_SLOT}" ]; then
local active_slot=`get_active_slot`
if [ X"${ACTIVE_SLOT}" != X"${active_slot}" ]; then
echo "${ORANGE}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}" >&2
fi
fi
return ${ret}
} }
[ "USAGE: usb_status > stdout [ "USAGE: usb_status > stdout
@ -254,33 +264,50 @@ usb_status() {
Returns: waits until the device has returned for fastboot or optional timeout" ] Returns: waits until the device has returned for fastboot or optional timeout" ]
fastboot_wait() { fastboot_wait() {
local ret
# fastboot has no wait-for-device, but it does an automatic # fastboot has no wait-for-device, but it does an automatic
# wait and requires (even a nonsensical) command to do so. # wait and requires (even a nonsensical) command to do so.
if [ -n "${1}" ]; then if [ -n "${1}" ]; then
echo -n ". . . waiting `format_duration ${1}`" ${ANDROID_SERIAL} ${USB_ADDRESS} "${CR}" echo -n ". . . waiting `format_duration ${1}`" ${ANDROID_SERIAL} ${USB_ADDRESS} "${CR}"
timeout --preserve-status --signal=KILL ${1} fastboot wait-for-device >/dev/null 2>/dev/null timeout --preserve-status --signal=KILL ${1} fastboot wait-for-device >/dev/null 2>/dev/null
local ret=${?} ret=${?}
echo -n " ${CR}" echo -n " ${CR}"
( exit ${ret} ) ( exit ${ret} )
else else
fastboot wait-for-device >/dev/null 2>/dev/null fastboot wait-for-device >/dev/null 2>/dev/null
fi || fi ||
inFastboot inFastboot
ret=${?}
if [ 0 = ${ret} -a -n "${ACTIVE_SLOT}" ]; then
local active_slot=`get_active_slot`
if [ X"${ACTIVE_SLOT}" != X"${active_slot}" ]; then
echo "${ORANGE}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}" >&2
fi
fi
return ${ret}
} }
[ "USAGE: recovery_wait [timeout] [ "USAGE: recovery_wait [timeout]
Returns: waits until the device has returned for recovery or optional timeout" ] Returns: waits until the device has returned for recovery or optional timeout" ]
recovery_wait() { recovery_wait() {
local ret
if [ -n "${1}" ]; then if [ -n "${1}" ]; then
echo -n ". . . waiting `format_duration ${1}`" ${ANDROID_SERIAL} ${USB_ADDRESS} "${CR}" echo -n ". . . waiting `format_duration ${1}`" ${ANDROID_SERIAL} ${USB_ADDRESS} "${CR}"
timeout --preserve-status --signal=KILL ${1} adb wait-for-recovery 2>/dev/null timeout --preserve-status --signal=KILL ${1} adb wait-for-recovery 2>/dev/null
local ret=${?} ret=${?}
echo -n " ${CR}" echo -n " ${CR}"
return ${ret}
else else
adb wait-for-recovery adb wait-for-recovery
ret=${?}
fi fi
if [ 0 = ${ret} -a -n "${ACTIVE_SLOT}" ]; then
local active_slot=`get_active_slot`
if [ X"${ACTIVE_SLOT}" != X"${active_slot}" ]; then
echo "${ORANGE}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}" >&2
fi
fi
return ${ret}
} }
[ "any_wait [timeout] [ "any_wait [timeout]
@ -326,7 +353,7 @@ adb_unroot() {
[ root != "`adb_sh echo '${USER}' </dev/null`" ] [ root != "`adb_sh echo '${USER}' </dev/null`" ]
} }
[ "USAGE: fastboot_getvar var expected [ "USAGE: fastboot_getvar var expected >/dev/stderr
Returns: true if var output matches expected" ] Returns: true if var output matches expected" ]
fastboot_getvar() { fastboot_getvar() {
@ -350,6 +377,19 @@ fastboot_getvar() {
echo ${O} >&2 echo ${O} >&2
} }
[ "USAGE: get_active_slot >/dev/stdout
Returns: with a or b string reporting active slot" ]
get_active_slot() {
if inAdb || inRecovery; then
get_property ro.boot.slot_suffix | tr -d _
elif inFastboot; then
fastboot_getvar current-slot 2>&1 | sed -n 's/current-slot: //p'
else
false
fi
}
[ "USAGE: restore [ "USAGE: restore
Do nothing: should be redefined when necessary. Called after cleanup. Do nothing: should be redefined when necessary. Called after cleanup.
@ -583,6 +623,9 @@ fi
BUILD_DESCRIPTION=`get_property ro.build.description` BUILD_DESCRIPTION=`get_property ro.build.description`
[ -z "${BUILD_DESCRIPTION}" ] || [ -z "${BUILD_DESCRIPTION}" ] ||
echo "${BLUE}[ INFO ]${NORMAL} ${BUILD_DESCRIPTION}" >&2 echo "${BLUE}[ INFO ]${NORMAL} ${BUILD_DESCRIPTION}" >&2
ACTIVE_SLOT=`get_active_slot`
[ -z "${ACTIVE_SLOT}" ] ||
echo "${BLUE}[ INFO ]${NORMAL} active slot is ${ACTIVE_SLOT}" >&2
# Report existing partition sizes # Report existing partition sizes
adb_sh ls -l /dev/block/by-name/ </dev/null 2>/dev/null | adb_sh ls -l /dev/block/by-name/ </dev/null 2>/dev/null |
@ -1031,13 +1074,7 @@ else
check_eq "${A}" "${B}" system after flash vendor check_eq "${A}" "${B}" system after flash vendor
adb_root || adb_root ||
die "adb root" die "adb root"
B="`adb_cat /vendor/hello`" && B="`adb_cat /vendor/hello`"
if ${is_userspace_fastboot} || ! ${overlayfs_needed}; then
die "re-read /vendor/hello after flash vendor"
else
echo "${ORANGE}[ WARNING ]${NORMAL} user fastboot missing required to invalidate, ignoring a failure" >&2
echo "${ORANGE}[ WARNING ]${NORMAL} re-read /vendor/hello after flash vendor" >&2
fi
if ${is_userspace_fastboot} || ! ${overlayfs_needed}; then if ${is_userspace_fastboot} || ! ${overlayfs_needed}; then
check_eq "cat: /vendor/hello: No such file or directory" "${B}" \ check_eq "cat: /vendor/hello: No such file or directory" "${B}" \
vendor content after flash vendor vendor content after flash vendor