diff options
author | Dan Pasanen <dan.pasanen@gmail.com> | 2015-01-28 16:41:29 -0800 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-10-16 06:17:42 -0700 |
commit | 93a0c2a7c03224fc4b71689a7cc57f7b04ffd2a7 (patch) | |
tree | 3f5a2b46cb0f399d2ae3bca1f63682a8c8bd5a34 /fs_mgr | |
parent | 4e41dec5467470c533f40b1e2d7d482ab27e0260 (diff) | |
download | system_core-93a0c2a7c03224fc4b71689a7cc57f7b04ffd2a7.zip system_core-93a0c2a7c03224fc4b71689a7cc57f7b04ffd2a7.tar.gz system_core-93a0c2a7c03224fc4b71689a7cc57f7b04ffd2a7.tar.bz2 |
fs_mgr: Skip filesystem check unless fs_type matches
* Prevent accidentally destroying a partition of the wrong type.
* Don't skip iterations of the internal mount_all loop, otherwise
encryptability may not be properly handled.
Change-Id: I8f3ddc396a5fb85f4ae0a0a11dd61fb4d6462d6d
Diffstat (limited to 'fs_mgr')
-rw-r--r-- | fs_mgr/Android.mk | 6 | ||||
-rw-r--r-- | fs_mgr/fs_mgr.c | 15 |
2 files changed, 16 insertions, 5 deletions
diff --git a/fs_mgr/Android.mk b/fs_mgr/Android.mk index 8ed5cc9..ecd13cc 100644 --- a/fs_mgr/Android.mk +++ b/fs_mgr/Android.mk @@ -12,8 +12,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/include \ external/openssl/include LOCAL_MODULE:= libfs_mgr -LOCAL_STATIC_LIBRARIES := liblogwrap libmincrypt libext4_utils_static libsquashfs_utils -LOCAL_C_INCLUDES += system/extras/ext4_utils system/extras/squashfs_utils +LOCAL_STATIC_LIBRARIES := liblogwrap libmincrypt libext4_utils_static libsquashfs_utils libext2_blkid libext2_uuid +LOCAL_C_INCLUDES += system/extras/ext4_utils system/extras/squashfs_utils external/e2fsprogs/lib LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include LOCAL_CFLAGS := -Werror @@ -38,7 +38,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 liblogwrap libcutils liblog libc libmincrypt libext4_utils_static libsquashfs_utils +LOCAL_STATIC_LIBRARIES := libfs_mgr liblogwrap libcutils liblog libc libmincrypt libext4_utils_static libsquashfs_utils libext2_blkid libext2_uuid LOCAL_STATIC_LIBRARIES += libsparse_static libz libselinux LOCAL_CXX_STL := libc++_static diff --git a/fs_mgr/fs_mgr.c b/fs_mgr/fs_mgr.c index 1b26b43..d79932d 100644 --- a/fs_mgr/fs_mgr.c +++ b/fs_mgr/fs_mgr.c @@ -39,6 +39,7 @@ #include <cutils/partition_utils.h> #include <cutils/properties.h> #include <logwrap/logwrap.h> +#include <blkid/blkid.h> #include "mincrypt/rsa.h" #include "mincrypt/sha.h" @@ -304,6 +305,8 @@ static int mount_with_alternatives(struct fstab *fstab, int start_idx, int *end_ int i; int mount_errno = 0; int mounted = 0; + int cmp_len; + char *detected_fs_type; if (!end_idx || !attempted_idx || start_idx >= fstab->num_entries) { errno = EINVAL; @@ -329,8 +332,16 @@ static int mount_with_alternatives(struct fstab *fstab, int start_idx, int *end_ } if (fstab->recs[i].fs_mgr_flags & MF_CHECK) { - check_fs(fstab->recs[i].blk_device, fstab->recs[i].fs_type, - fstab->recs[i].mount_point); + /* Skip file system check unless we are sure we are the right type */ + detected_fs_type = blkid_get_tag_value(NULL, "TYPE", fstab->recs[i].blk_device); + if (detected_fs_type) { + cmp_len = (!strncmp(detected_fs_type, "ext", 3) && + strlen(detected_fs_type) == 4) ? 3 : strlen(detected_fs_type); + if (!strncmp(fstab->recs[i].fs_type, detected_fs_type, cmp_len)) { + check_fs(fstab->recs[i].blk_device, fstab->recs[i].fs_type, + fstab->recs[i].mount_point); + } + } } if (!__mount(fstab->recs[i].blk_device, fstab->recs[i].mount_point, &fstab->recs[i])) { *attempted_idx = i; |