Loading fs_mgr/fs_mgr.cpp +25 −9 Original line number Original line Diff line number Diff line Loading @@ -47,6 +47,7 @@ #include <ext4_utils/wipe.h> #include <ext4_utils/wipe.h> #include <linux/fs.h> #include <linux/fs.h> #include <linux/loop.h> #include <linux/loop.h> #include <linux/magic.h> #include <logwrap/logwrap.h> #include <logwrap/logwrap.h> #include <private/android_logger.h> // for __android_log_is_debuggable() #include <private/android_logger.h> // for __android_log_is_debuggable() Loading Loading @@ -83,6 +84,7 @@ enum FsStatFlags { FS_STAT_FULL_MOUNT_FAILED = 0x0100, FS_STAT_FULL_MOUNT_FAILED = 0x0100, FS_STAT_E2FSCK_FAILED = 0x0200, FS_STAT_E2FSCK_FAILED = 0x0200, FS_STAT_E2FSCK_FS_FIXED = 0x0400, FS_STAT_E2FSCK_FS_FIXED = 0x0400, FS_STAT_EXT4_INVALID_MAGIC = 0x0800, }; }; /* /* Loading Loading @@ -141,6 +143,9 @@ static void check_fs(const char *blk_device, char *fs_type, char *target, int *f /* Check for the types of filesystems we know how to check */ /* Check for the types of filesystems we know how to check */ if (!strcmp(fs_type, "ext2") || !strcmp(fs_type, "ext3") || !strcmp(fs_type, "ext4")) { if (!strcmp(fs_type, "ext2") || !strcmp(fs_type, "ext3") || !strcmp(fs_type, "ext4")) { if (*fs_stat & FS_STAT_EXT4_INVALID_MAGIC) { // will fail, so do not try return; } /* /* * First try to mount and unmount the filesystem. We do this because * First try to mount and unmount the filesystem. We do this because * the kernel is more efficient than e2fsck in running the journal and * the kernel is more efficient than e2fsck in running the journal and Loading Loading @@ -287,6 +292,11 @@ static int do_quota_with_shutdown_check(char *blk_device, char *fs_type, PERROR << "Can't read '" << blk_device << "' super block"; PERROR << "Can't read '" << blk_device << "' super block"; return force_check; return force_check; } } if (sb.s_magic != EXT4_SUPER_MAGIC) { LINFO << "Invalid ext4 magic:0x" << std::hex << sb.s_magic << "," << blk_device; *fs_stat |= FS_STAT_EXT4_INVALID_MAGIC; return 0; // not a valid fs, tune2fs, fsck, and mount will all fail. } *fs_stat |= FS_STAT_IS_EXT4; *fs_stat |= FS_STAT_IS_EXT4; LINFO << "superblock s_max_mnt_count:" << sb.s_max_mnt_count << "," << blk_device; LINFO << "superblock s_max_mnt_count:" << sb.s_max_mnt_count << "," << blk_device; if (sb.s_max_mnt_count == 0xffff) { // -1 (int16) in ext2, but uint16 in ext4 if (sb.s_max_mnt_count == 0xffff) { // -1 (int16) in ext2, but uint16 in ext4 Loading Loading @@ -547,7 +557,13 @@ static int mount_with_alternatives(struct fstab *fstab, int start_idx, int *end_ int force_check = do_quota_with_shutdown_check(fstab->recs[i].blk_device, int force_check = do_quota_with_shutdown_check(fstab->recs[i].blk_device, fstab->recs[i].fs_type, fstab->recs[i].fs_type, &fstab->recs[i], &fs_stat); &fstab->recs[i], &fs_stat); if (fs_stat & FS_STAT_EXT4_INVALID_MAGIC) { LERROR << __FUNCTION__ << "(): skipping mount, invalid ext4, mountpoint=" << fstab->recs[i].mount_point << " rec[" << i << "].fs_type=" << fstab->recs[i].fs_type; mount_errno = EINVAL; // continue bootup for FDE continue; } if ((fstab->recs[i].fs_mgr_flags & MF_CHECK) || force_check) { if ((fstab->recs[i].fs_mgr_flags & MF_CHECK) || force_check) { check_fs(fstab->recs[i].blk_device, fstab->recs[i].fs_type, check_fs(fstab->recs[i].blk_device, fstab->recs[i].fs_type, fstab->recs[i].mount_point, &fs_stat); fstab->recs[i].mount_point, &fs_stat); Loading Loading
fs_mgr/fs_mgr.cpp +25 −9 Original line number Original line Diff line number Diff line Loading @@ -47,6 +47,7 @@ #include <ext4_utils/wipe.h> #include <ext4_utils/wipe.h> #include <linux/fs.h> #include <linux/fs.h> #include <linux/loop.h> #include <linux/loop.h> #include <linux/magic.h> #include <logwrap/logwrap.h> #include <logwrap/logwrap.h> #include <private/android_logger.h> // for __android_log_is_debuggable() #include <private/android_logger.h> // for __android_log_is_debuggable() Loading Loading @@ -83,6 +84,7 @@ enum FsStatFlags { FS_STAT_FULL_MOUNT_FAILED = 0x0100, FS_STAT_FULL_MOUNT_FAILED = 0x0100, FS_STAT_E2FSCK_FAILED = 0x0200, FS_STAT_E2FSCK_FAILED = 0x0200, FS_STAT_E2FSCK_FS_FIXED = 0x0400, FS_STAT_E2FSCK_FS_FIXED = 0x0400, FS_STAT_EXT4_INVALID_MAGIC = 0x0800, }; }; /* /* Loading Loading @@ -141,6 +143,9 @@ static void check_fs(const char *blk_device, char *fs_type, char *target, int *f /* Check for the types of filesystems we know how to check */ /* Check for the types of filesystems we know how to check */ if (!strcmp(fs_type, "ext2") || !strcmp(fs_type, "ext3") || !strcmp(fs_type, "ext4")) { if (!strcmp(fs_type, "ext2") || !strcmp(fs_type, "ext3") || !strcmp(fs_type, "ext4")) { if (*fs_stat & FS_STAT_EXT4_INVALID_MAGIC) { // will fail, so do not try return; } /* /* * First try to mount and unmount the filesystem. We do this because * First try to mount and unmount the filesystem. We do this because * the kernel is more efficient than e2fsck in running the journal and * the kernel is more efficient than e2fsck in running the journal and Loading Loading @@ -287,6 +292,11 @@ static int do_quota_with_shutdown_check(char *blk_device, char *fs_type, PERROR << "Can't read '" << blk_device << "' super block"; PERROR << "Can't read '" << blk_device << "' super block"; return force_check; return force_check; } } if (sb.s_magic != EXT4_SUPER_MAGIC) { LINFO << "Invalid ext4 magic:0x" << std::hex << sb.s_magic << "," << blk_device; *fs_stat |= FS_STAT_EXT4_INVALID_MAGIC; return 0; // not a valid fs, tune2fs, fsck, and mount will all fail. } *fs_stat |= FS_STAT_IS_EXT4; *fs_stat |= FS_STAT_IS_EXT4; LINFO << "superblock s_max_mnt_count:" << sb.s_max_mnt_count << "," << blk_device; LINFO << "superblock s_max_mnt_count:" << sb.s_max_mnt_count << "," << blk_device; if (sb.s_max_mnt_count == 0xffff) { // -1 (int16) in ext2, but uint16 in ext4 if (sb.s_max_mnt_count == 0xffff) { // -1 (int16) in ext2, but uint16 in ext4 Loading Loading @@ -547,7 +557,13 @@ static int mount_with_alternatives(struct fstab *fstab, int start_idx, int *end_ int force_check = do_quota_with_shutdown_check(fstab->recs[i].blk_device, int force_check = do_quota_with_shutdown_check(fstab->recs[i].blk_device, fstab->recs[i].fs_type, fstab->recs[i].fs_type, &fstab->recs[i], &fs_stat); &fstab->recs[i], &fs_stat); if (fs_stat & FS_STAT_EXT4_INVALID_MAGIC) { LERROR << __FUNCTION__ << "(): skipping mount, invalid ext4, mountpoint=" << fstab->recs[i].mount_point << " rec[" << i << "].fs_type=" << fstab->recs[i].fs_type; mount_errno = EINVAL; // continue bootup for FDE continue; } if ((fstab->recs[i].fs_mgr_flags & MF_CHECK) || force_check) { if ((fstab->recs[i].fs_mgr_flags & MF_CHECK) || force_check) { check_fs(fstab->recs[i].blk_device, fstab->recs[i].fs_type, check_fs(fstab->recs[i].blk_device, fstab->recs[i].fs_type, fstab->recs[i].mount_point, &fs_stat); fstab->recs[i].mount_point, &fs_stat); Loading