From 90f568a14e3a233233376974aa9cadc86a5d13c4 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Thu, 20 May 2021 23:16:10 -0700 Subject: f2fs_utils: support -O ro "-O ro" sets the filesystem as readonly. Bug: 171942852 Signed-off-by: Jaegeuk Kim Change-Id: Ia561618557e4e72bcc702b1e1d954a380a90d1b2 --- f2fs_utils/mkf2fsuserimg.sh | 63 ++++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/f2fs_utils/mkf2fsuserimg.sh b/f2fs_utils/mkf2fsuserimg.sh index 522f9ea4..013ff543 100755 --- a/f2fs_utils/mkf2fsuserimg.sh +++ b/f2fs_utils/mkf2fsuserimg.sh @@ -8,7 +8,7 @@ Usage: ${0##*/} OUTPUT_FILE SIZE [-S] [-C FS_CONFIG] [-f SRC_DIR] [-D PRODUCT_OUT] [-s FILE_CONTEXTS] [-t MOUNT_POINT] [-T TIMESTAMP] - [-L LABEL] [--prjquota] [--casefold] [--compression] + [-L LABEL] [--prjquota] [--casefold] [--compression] [--readonly] [--sldc [sload compression sub-options]] : number of the sload compression args, e.g. -a LZ4 counts as 2 when sload compression args are not given, must be 0, @@ -95,6 +95,11 @@ if [[ "$1" == "--compression" ]]; then MKFS_OPTS+=" -O compression,extra_attr" shift; fi +if [[ "$1" == "--readonly" ]]; then + MKFS_OPTS+=" -O ro" + READONLY=1 + shift; +fi if [[ "$1" == "--sldc" ]]; then if [ -z "$COMPRESS_SUPPORT" ]; then @@ -122,32 +127,54 @@ if [ -z $SIZE ]; then exit 2 fi -if [ "$SPARSE_IMG" = "false" ]; then +function _truncate() +{ + if [ "$SPARSE_IMG" = "true" ]; then + return + fi + TRUNCATE_CMD="truncate -s $SIZE $OUTPUT_FILE" echo $TRUNCATE_CMD $TRUNCATE_CMD if [ $? -ne 0 ]; then exit 3 fi -fi +} -MAKE_F2FS_CMD="make_f2fs -g android $MKFS_OPTS $OUTPUT_FILE" -echo $MAKE_F2FS_CMD -$MAKE_F2FS_CMD -if [ $? -ne 0 ]; then - if [ "$SPARSE_IMG" = "false" ]; then +function _build() +{ + MAKE_F2FS_CMD="make_f2fs -g android $MKFS_OPTS $OUTPUT_FILE" + echo $MAKE_F2FS_CMD + $MAKE_F2FS_CMD + if [ $? -ne 0 ]; then + if [ "$SPARSE_IMG" = "false" ]; then + rm -f $OUTPUT_FILE + fi + exit 4 + fi + + SLOAD_F2FS_CMD="sload_f2fs $SLOAD_OPTS $OUTPUT_FILE" + echo $SLOAD_F2FS_CMD + MB_SIZE=`$SLOAD_F2FS_CMD | grep "Max image size" | awk '{print $5}'` + # allow 1: Filesystem errors corrected + ret=$? + if [ $ret -ne 0 ] && [ $ret -ne 1 ]; then rm -f $OUTPUT_FILE + exit 4 fi - exit 4 -fi + SIZE=$(((MB_SIZE + 6) * 1024 * 1024)) +} + +_truncate +_build -SLOAD_F2FS_CMD="sload_f2fs $SLOAD_OPTS $OUTPUT_FILE" -echo $SLOAD_F2FS_CMD -$SLOAD_F2FS_CMD -# allow 1: Filesystem errors corrected -ret=$? -if [ $ret -ne 0 ] && [ $ret -ne 1 ]; then - rm -f $OUTPUT_FILE - exit 4 +# readonly + compress can reduce the image +if [ "$READONLY" ] && [ "$COMPRESS_SUPPORT" ]; then + if [ "$SPARSE_IMG" = "true" ]; then + MKFS_OPTS+=" -S $SIZE" + rm -f $OUTPUT_FILE && touch $OUTPUT_FILE + fi + _truncate + _build fi exit 0 -- cgit v1.2.3 From ac2789745fef896809548b1c1e894c1e3a15d68d Mon Sep 17 00:00:00 2001 From: Pirama Arumuga Nainar Date: Wed, 19 May 2021 10:30:01 -0700 Subject: Remove at_quick_exit call This doesn't help with coverage for ART tools. Bug: http://b/186576313 Test: N/A Change-Id: I5c2ab63485f2b07d9e026492835072ab85dcccfb (cherry picked from commit 91e13733870df7f6df8aa68d0b17711ba98c3c5a) --- toolchain-extras/profile-clang-extras.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/toolchain-extras/profile-clang-extras.cpp b/toolchain-extras/profile-clang-extras.cpp index 4e5aca97..89c18b2a 100644 --- a/toolchain-extras/profile-clang-extras.cpp +++ b/toolchain-extras/profile-clang-extras.cpp @@ -36,16 +36,6 @@ static void llvm_signal_handler(__unused int signum) { } } -#if __ANDROID_API__ >= 21 -void writeFileWithoutReturn() { - __llvm_profile_write_file(); -} - -__attribute__((constructor)) void register_quick_exit_handler(void) { - at_quick_exit(writeFileWithoutReturn); -} -#endif // #if __ANDROID_API__ >= 21 - __attribute__((weak)) int init_profile_extras_once = 0; // Initialize libprofile-extras: -- cgit v1.2.3