Loading fs_mgr/fs_mgr.c +5 −1 Original line number Diff line number Diff line Loading @@ -586,6 +586,7 @@ int fs_mgr_mount_all(struct fstab *fstab) /* mount(2) returned an error, handle the encryptable/formattable case */ bool wiped = partition_wiped(fstab->recs[top_idx].blk_device); bool crypt_footer = false; if (mret && mount_errno != EBUSY && mount_errno != EACCES && fs_mgr_is_formattable(&fstab->recs[top_idx]) && wiped) { /* top_idx and attempted_idx point at the same partition, but sometimes Loading @@ -606,8 +607,11 @@ int fs_mgr_mount_all(struct fstab *fstab) ERROR("%s(): %s wouldn't open (%s)\n", __func__, fstab->recs[top_idx].key_loc, strerror(errno)); } } else if (fs_mgr_is_encryptable(&fstab->recs[top_idx]) && !strcmp(fstab->recs[top_idx].key_loc, KEY_IN_FOOTER)) { crypt_footer = true; } if (fs_mgr_do_format(&fstab->recs[top_idx]) == 0) { if (fs_mgr_do_format(&fstab->recs[top_idx], crypt_footer) == 0) { /* Let's replay the mount actions. */ i = top_idx - 1; continue; Loading fs_mgr/fs_mgr_format.c +7 −3 Original line number Diff line number Diff line Loading @@ -32,11 +32,12 @@ #include "ext4.h" #include "make_ext4fs.h" #include "fs_mgr_priv.h" #include "cryptfs.h" extern struct fs_info info; /* magic global from ext4_utils */ extern void reset_ext4fs_info(); static int format_ext4(char *fs_blkdev, char *fs_mnt_point) static int format_ext4(char *fs_blkdev, char *fs_mnt_point, bool crypt_footer) { uint64_t dev_sz; int fd, rc = 0; Loading @@ -63,6 +64,9 @@ static int format_ext4(char *fs_blkdev, char *fs_mnt_point) /* Format the partition using the calculated length */ reset_ext4fs_info(); info.len = (off64_t)dev_sz; if (crypt_footer) { info.len -= CRYPT_FOOTER_OFFSET; } /* Use make_ext4fs_internal to avoid wiping an already-wiped partition. */ rc = make_ext4fs_internal(fd, NULL, NULL, fs_mnt_point, 0, 0, 0, 0, 0, 0, sehandle, 0, 0, NULL); Loading Loading @@ -118,7 +122,7 @@ static int format_f2fs(char *fs_blkdev) return rc; } int fs_mgr_do_format(struct fstab_rec *fstab) int fs_mgr_do_format(struct fstab_rec *fstab, bool crypt_footer) { int rc = -EINVAL; Loading @@ -127,7 +131,7 @@ int fs_mgr_do_format(struct fstab_rec *fstab) if (!strncmp(fstab->fs_type, "f2fs", 4)) { rc = format_f2fs(fstab->blk_device); } else if (!strncmp(fstab->fs_type, "ext4", 4)) { rc = format_ext4(fstab->blk_device, fstab->mount_point); rc = format_ext4(fstab->blk_device, fstab->mount_point, crypt_footer); } else { ERROR("File system type '%s' is not supported\n", fstab->fs_type); } Loading fs_mgr/include/fs_mgr.h +2 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #define __CORE_FS_MGR_H #include <stdint.h> #include <stdbool.h> #include <linux/dm-ioctl.h> // Magic number at start of verity metadata Loading Loading @@ -108,7 +109,7 @@ int fs_mgr_is_formattable(struct fstab_rec *fstab); int fs_mgr_is_nofail(struct fstab_rec *fstab); int fs_mgr_swapon_all(struct fstab *fstab); int fs_mgr_do_format(struct fstab_rec *fstab); int fs_mgr_do_format(struct fstab_rec *fstab, bool reserve_footer); #ifdef __cplusplus } Loading Loading
fs_mgr/fs_mgr.c +5 −1 Original line number Diff line number Diff line Loading @@ -586,6 +586,7 @@ int fs_mgr_mount_all(struct fstab *fstab) /* mount(2) returned an error, handle the encryptable/formattable case */ bool wiped = partition_wiped(fstab->recs[top_idx].blk_device); bool crypt_footer = false; if (mret && mount_errno != EBUSY && mount_errno != EACCES && fs_mgr_is_formattable(&fstab->recs[top_idx]) && wiped) { /* top_idx and attempted_idx point at the same partition, but sometimes Loading @@ -606,8 +607,11 @@ int fs_mgr_mount_all(struct fstab *fstab) ERROR("%s(): %s wouldn't open (%s)\n", __func__, fstab->recs[top_idx].key_loc, strerror(errno)); } } else if (fs_mgr_is_encryptable(&fstab->recs[top_idx]) && !strcmp(fstab->recs[top_idx].key_loc, KEY_IN_FOOTER)) { crypt_footer = true; } if (fs_mgr_do_format(&fstab->recs[top_idx]) == 0) { if (fs_mgr_do_format(&fstab->recs[top_idx], crypt_footer) == 0) { /* Let's replay the mount actions. */ i = top_idx - 1; continue; Loading
fs_mgr/fs_mgr_format.c +7 −3 Original line number Diff line number Diff line Loading @@ -32,11 +32,12 @@ #include "ext4.h" #include "make_ext4fs.h" #include "fs_mgr_priv.h" #include "cryptfs.h" extern struct fs_info info; /* magic global from ext4_utils */ extern void reset_ext4fs_info(); static int format_ext4(char *fs_blkdev, char *fs_mnt_point) static int format_ext4(char *fs_blkdev, char *fs_mnt_point, bool crypt_footer) { uint64_t dev_sz; int fd, rc = 0; Loading @@ -63,6 +64,9 @@ static int format_ext4(char *fs_blkdev, char *fs_mnt_point) /* Format the partition using the calculated length */ reset_ext4fs_info(); info.len = (off64_t)dev_sz; if (crypt_footer) { info.len -= CRYPT_FOOTER_OFFSET; } /* Use make_ext4fs_internal to avoid wiping an already-wiped partition. */ rc = make_ext4fs_internal(fd, NULL, NULL, fs_mnt_point, 0, 0, 0, 0, 0, 0, sehandle, 0, 0, NULL); Loading Loading @@ -118,7 +122,7 @@ static int format_f2fs(char *fs_blkdev) return rc; } int fs_mgr_do_format(struct fstab_rec *fstab) int fs_mgr_do_format(struct fstab_rec *fstab, bool crypt_footer) { int rc = -EINVAL; Loading @@ -127,7 +131,7 @@ int fs_mgr_do_format(struct fstab_rec *fstab) if (!strncmp(fstab->fs_type, "f2fs", 4)) { rc = format_f2fs(fstab->blk_device); } else if (!strncmp(fstab->fs_type, "ext4", 4)) { rc = format_ext4(fstab->blk_device, fstab->mount_point); rc = format_ext4(fstab->blk_device, fstab->mount_point, crypt_footer); } else { ERROR("File system type '%s' is not supported\n", fstab->fs_type); } Loading
fs_mgr/include/fs_mgr.h +2 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #define __CORE_FS_MGR_H #include <stdint.h> #include <stdbool.h> #include <linux/dm-ioctl.h> // Magic number at start of verity metadata Loading Loading @@ -108,7 +109,7 @@ int fs_mgr_is_formattable(struct fstab_rec *fstab); int fs_mgr_is_nofail(struct fstab_rec *fstab); int fs_mgr_swapon_all(struct fstab *fstab); int fs_mgr_do_format(struct fstab_rec *fstab); int fs_mgr_do_format(struct fstab_rec *fstab, bool reserve_footer); #ifdef __cplusplus } Loading