summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Sumrall <ksumrall@android.com>2013-04-15 17:34:15 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-04-15 17:34:15 +0000
commit1a6d9ec2af7b3151c64a167162c87d258d30735b (patch)
tree64aee1a35720ea6dbf49e1e58d84c1c2c3618ebf
parent1f75eb1eae4dde3e7d8c625fca3063cf5a488079 (diff)
parentbf021b4cd760a48b38c58347a35157180593c4b8 (diff)
downloadcore-1a6d9ec2af7b3151c64a167162c87d258d30735b.tar.gz
Merge "fs_mgr: Capture the output of e2fsck and add to the kernel log" into jb-mr2-dev
-rw-r--r--fs_mgr/Android.mk3
-rw-r--r--fs_mgr/fs_mgr.c32
-rw-r--r--init/Android.mk2
3 files changed, 18 insertions, 19 deletions
diff --git a/fs_mgr/Android.mk b/fs_mgr/Android.mk
index 7c66f6ab0..0ce07c12b 100644
--- a/fs_mgr/Android.mk
+++ b/fs_mgr/Android.mk
@@ -8,6 +8,7 @@ LOCAL_SRC_FILES:= fs_mgr.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_MODULE:= libfs_mgr
+LOCAL_STATIC_LIBRARIES := liblogwrap
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
include $(BUILD_STATIC_LIBRARY)
@@ -27,7 +28,7 @@ LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)/sbin
LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
-LOCAL_STATIC_LIBRARIES := libfs_mgr libcutils libc
+LOCAL_STATIC_LIBRARIES := libfs_mgr liblogwrap libcutils libc
include $(BUILD_EXECUTABLE)
diff --git a/fs_mgr/fs_mgr.c b/fs_mgr/fs_mgr.c
index 8f647578b..fecc556a3 100644
--- a/fs_mgr/fs_mgr.c
+++ b/fs_mgr/fs_mgr.c
@@ -14,11 +14,6 @@
* limitations under the License.
*/
-/* TO DO:
- * 1. Re-direct fsck output to the kernel log?
- *
- */
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -36,6 +31,7 @@
#include <private/android_filesystem_config.h>
#include <cutils/partition_utils.h>
#include <cutils/properties.h>
+#include <logwrap/logwrap.h>
#include "fs_mgr_priv.h"
@@ -44,6 +40,8 @@
#define E2FSCK_BIN "/system/bin/e2fsck"
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
+
struct flag_list {
const char *name;
unsigned flag;
@@ -434,11 +432,15 @@ void fs_mgr_free_fstab(struct fstab *fstab)
static void check_fs(char *blk_device, char *fs_type, char *target)
{
- pid_t pid;
int status;
int ret;
long tmpmnt_flags = MS_NOATIME | MS_NOEXEC | MS_NOSUID;
char *tmpmnt_opts = "nomblk_io_submit,errors=remount-ro";
+ char *e2fsck_argv[] = {
+ E2FSCK_BIN,
+ "-y",
+ blk_device
+ };
/* Check for the types of filesystems we know how to check */
if (!strcmp(fs_type, "ext2") || !strcmp(fs_type, "ext3") || !strcmp(fs_type, "ext4")) {
@@ -461,19 +463,13 @@ static void check_fs(char *blk_device, char *fs_type, char *target)
}
INFO("Running %s on %s\n", E2FSCK_BIN, blk_device);
- pid = fork();
- if (pid > 0) {
- /* Parent, wait for the child to return */
- waitpid(pid, &status, 0);
- } else if (pid == 0) {
- /* child, run checker */
- execlp(E2FSCK_BIN, E2FSCK_BIN, "-y", blk_device, (char *)NULL);
-
- /* Only gets here on error */
- ERROR("Cannot run fs_mgr binary %s\n", E2FSCK_BIN);
- } else {
+
+ ret = android_fork_execvp_ext(ARRAY_SIZE(e2fsck_argv), e2fsck_argv,
+ &status, true, LOG_KLOG, true);
+
+ if (ret < 0) {
/* No need to check for error in fork, we can't really handle it now */
- ERROR("Fork failed trying to run %s\n", E2FSCK_BIN);
+ ERROR("Failed trying to run %s\n", E2FSCK_BIN);
}
}
diff --git a/init/Android.mk b/init/Android.mk
index 00d214456..ef62bce5c 100644
--- a/init/Android.mk
+++ b/init/Android.mk
@@ -35,7 +35,9 @@ LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
LOCAL_STATIC_LIBRARIES := \
libfs_mgr \
+ liblogwrap \
libcutils \
+ liblog \
libc \
libselinux