Extract some version constants to header

In order to make it easier to upgrade the crypto footer, extract some
constants to a header file instead. Then the header can control what the
current version is and the upgrade_crypto_ftr code should be the only
thing that needs to be updated.

Change-Id: I3ed5a7d3b640419cd8af91388d94a00de8cc09db
This commit is contained in:
Kenny Root 2013-06-14 12:08:28 -07:00
parent 7434b3111b
commit c96a5f8edf
2 changed files with 13 additions and 9 deletions

View file

@ -339,21 +339,21 @@ static int get_crypt_ftr_and_key(struct crypt_mnt_ftr *crypt_ftr)
goto errout;
}
if (crypt_ftr->major_version != 1) {
SLOGE("Cannot understand major version %d real block device footer\n",
crypt_ftr->major_version);
if (crypt_ftr->major_version != CURRENT_MAJOR_VERSION) {
SLOGE("Cannot understand major version %d real block device footer; expected %d\n",
crypt_ftr->major_version, CURRENT_MAJOR_VERSION);
goto errout;
}
if ((crypt_ftr->minor_version != 0) && (crypt_ftr->minor_version != 1)) {
SLOGW("Warning: crypto footer minor version %d, expected 0 or 1, continuing...\n",
crypt_ftr->minor_version);
if (crypt_ftr->minor_version > CURRENT_MINOR_VERSION) {
SLOGW("Warning: crypto footer minor version %d, expected <= %d, continuing...\n",
crypt_ftr->minor_version, CURRENT_MINOR_VERSION);
}
/* If this is a verion 1.0 crypt_ftr, make it a 1.1 crypt footer, and update the
* copy on disk before returning.
*/
if (crypt_ftr->minor_version == 0) {
if (crypt_ftr->minor_version < CURRENT_MINOR_VERSION) {
upgrade_crypt_ftr(fd, crypt_ftr, starting_off);
}
@ -1282,8 +1282,8 @@ static void cryptfs_init_crypt_mnt_ftr(struct crypt_mnt_ftr *ftr)
memset(ftr, 0, sizeof(struct crypt_mnt_ftr));
ftr->magic = CRYPT_MNT_MAGIC;
ftr->major_version = 1;
ftr->minor_version = 1;
ftr->major_version = CURRENT_MAJOR_VERSION;
ftr->minor_version = CURRENT_MINOR_VERSION;
ftr->ftr_size = sizeof(struct crypt_mnt_ftr);
ftr->keysize = KEY_LEN_BYTES;

View file

@ -28,6 +28,10 @@
#include <cutils/properties.h>
/* The current cryptfs version */
#define CURRENT_MAJOR_VERSION 1
#define CURRENT_MINOR_VERSION 2
#define CRYPT_FOOTER_OFFSET 0x4000
#define CRYPT_FOOTER_TO_PERSIST_OFFSET 0x1000
#define CRYPT_PERSIST_DATA_SIZE 0x1000