From 28483d7ec497e06850be1d8f87d7fa522c8ab9d4 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Mon, 17 Feb 2014 11:14:44 +0100 Subject: [PATCH] fs_mgr: Don't run e2fsck inside SDK system images. These images do not have GPL-ed binaries like /system/bin/e2fsck so avoid running the program when we detect that we're running inside one of them. Note that this does not affect other emulator-based build products (e..g full-eng instead of sdk-eng), which do have the binaries. BUG=13057123 Change-Id: Ia42f1d02a3845fbf4b2f9d95818f35d760711a12 --- fs_mgr/fs_mgr.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/fs_mgr/fs_mgr.c b/fs_mgr/fs_mgr.c index 4c2f24707..dcda005bc 100644 --- a/fs_mgr/fs_mgr.c +++ b/fs_mgr/fs_mgr.c @@ -116,15 +116,24 @@ static void check_fs(char *blk_device, char *fs_type, char *target) umount(target); } - INFO("Running %s on %s\n", E2FSCK_BIN, blk_device); + /* + * Some system images do not have e2fsck for licensing reasons + * (e.g. recent SDK system images). Detect these and skip the check. + */ + if (access(E2FSCK_BIN, X_OK)) { + INFO("Not running %s on %s (executable not in system image)\n", + E2FSCK_BIN, blk_device); + } else { + INFO("Running %s on %s\n", E2FSCK_BIN, blk_device); - ret = android_fork_execvp_ext(ARRAY_SIZE(e2fsck_argv), e2fsck_argv, - &status, true, LOG_KLOG | LOG_FILE, - true, FSCK_LOG_FILE); + ret = android_fork_execvp_ext(ARRAY_SIZE(e2fsck_argv), e2fsck_argv, + &status, true, LOG_KLOG | LOG_FILE, + true, FSCK_LOG_FILE); - if (ret < 0) { - /* No need to check for error in fork, we can't really handle it now */ - ERROR("Failed trying to run %s\n", E2FSCK_BIN); + if (ret < 0) { + /* No need to check for error in fork, we can't really handle it now */ + ERROR("Failed trying to run %s\n", E2FSCK_BIN); + } } }