• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

Revisioneac3e1b8af0e2e7cc57ea5a166a7766c21ba5046 (tree)
Time2016-07-20 18:01:29
AuthorChuanxiao Dong <chuanxiao.dong@inte...>
CommiterChih-Wei Huang

Log Message

fs_mgr: fix encryptable=footer support

If the userdata partition has the encryptable=footer fstab option,
fs_mgr must leave room for the crypt footer.

Upstream: https://android-review.googlesource.com/206992
Change-Id: Id07818c5d93aafc27577f72fb0a780f26db51b16
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
Tracked-On: https://jira01.devtools.intel.com/browse/OAM-23540
Reviewed-on: https://android.intel.com:443/479471

Change Summary

Incremental Difference

--- a/fs_mgr/fs_mgr.c
+++ b/fs_mgr/fs_mgr.c
@@ -577,6 +577,7 @@ int fs_mgr_mount_all(struct fstab *fstab)
577577
578578 /* mount(2) returned an error, handle the encryptable/formattable case */
579579 bool wiped = partition_wiped(fstab->recs[top_idx].blk_device);
580+ bool crypt_footer = false;
580581 if (mret && mount_errno != EBUSY && mount_errno != EACCES &&
581582 fs_mgr_is_formattable(&fstab->recs[top_idx]) && wiped) {
582583 /* top_idx and attempted_idx point at the same partition, but sometimes
@@ -597,8 +598,11 @@ int fs_mgr_mount_all(struct fstab *fstab)
597598 ERROR("%s(): %s wouldn't open (%s)\n", __func__,
598599 fstab->recs[top_idx].key_loc, strerror(errno));
599600 }
601+ } else if (fs_mgr_is_encryptable(&fstab->recs[top_idx]) &&
602+ !strcmp(fstab->recs[top_idx].key_loc, KEY_IN_FOOTER)) {
603+ crypt_footer = true;
600604 }
601- if (fs_mgr_do_format(&fstab->recs[top_idx]) == 0) {
605+ if (fs_mgr_do_format(&fstab->recs[top_idx], crypt_footer) == 0) {
602606 /* Let's replay the mount actions. */
603607 i = top_idx - 1;
604608 continue;
--- a/fs_mgr/fs_mgr_format.c
+++ b/fs_mgr/fs_mgr_format.c
@@ -27,11 +27,12 @@
2727 #include "ext4.h"
2828 #include "make_ext4fs.h"
2929 #include "fs_mgr_priv.h"
30+#include "cryptfs.h"
3031
3132 extern struct fs_info info; /* magic global from ext4_utils */
3233 extern void reset_ext4fs_info();
3334
34-static int format_ext4(char *fs_blkdev, char *fs_mnt_point)
35+static int format_ext4(char *fs_blkdev, char *fs_mnt_point, bool crypt_footer)
3536 {
3637 unsigned int nr_sec;
3738 int fd, rc = 0;
@@ -50,6 +51,9 @@ static int format_ext4(char *fs_blkdev, char *fs_mnt_point)
5051 /* Format the partition using the calculated length */
5152 reset_ext4fs_info();
5253 info.len = ((off64_t)nr_sec * 512);
54+ if (crypt_footer) {
55+ info.len -= CRYPT_FOOTER_OFFSET;
56+ }
5357
5458 /* Use make_ext4fs_internal to avoid wiping an already-wiped partition. */
5559 rc = make_ext4fs_internal(fd, NULL, NULL, fs_mnt_point, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL);
@@ -101,7 +105,7 @@ static int format_f2fs(char *fs_blkdev)
101105 return rc;
102106 }
103107
104-int fs_mgr_do_format(struct fstab_rec *fstab)
108+int fs_mgr_do_format(struct fstab_rec *fstab, bool crypt_footer)
105109 {
106110 int rc = -EINVAL;
107111
@@ -110,7 +114,7 @@ int fs_mgr_do_format(struct fstab_rec *fstab)
110114 if (!strncmp(fstab->fs_type, "f2fs", 4)) {
111115 rc = format_f2fs(fstab->blk_device);
112116 } else if (!strncmp(fstab->fs_type, "ext4", 4)) {
113- rc = format_ext4(fstab->blk_device, fstab->mount_point);
117+ rc = format_ext4(fstab->blk_device, fstab->mount_point, crypt_footer);
114118 } else {
115119 ERROR("File system type '%s' is not supported\n", fstab->fs_type);
116120 }
--- a/fs_mgr/include/fs_mgr.h
+++ b/fs_mgr/include/fs_mgr.h
@@ -18,6 +18,7 @@
1818 #define __CORE_FS_MGR_H
1919
2020 #include <stdint.h>
21+#include <stdbool.h>
2122 #include <linux/dm-ioctl.h>
2223
2324 // Magic number at start of verity metadata
@@ -107,7 +108,7 @@ int fs_mgr_is_notrim(struct fstab_rec *fstab);
107108 int fs_mgr_is_formattable(struct fstab_rec *fstab);
108109 int fs_mgr_swapon_all(struct fstab *fstab);
109110
110-int fs_mgr_do_format(struct fstab_rec *fstab);
111+int fs_mgr_do_format(struct fstab_rec *fstab, bool reserve_footer);
111112
112113 #ifdef __cplusplus
113114 }