Fix a bug in passing parameters to prepare_user_storage.
Add the serial parameter to prepare_user_storage to avoid
confusion when parsing parameters and passing them around.
Change-Id: Id5516c248401ad50585aa8f6e8b1545a6cded549
diff --git a/CryptCommandListener.cpp b/CryptCommandListener.cpp
index 93f953f..5de5cf2 100644
--- a/CryptCommandListener.cpp
+++ b/CryptCommandListener.cpp
@@ -366,8 +366,11 @@
} else if (subcommand == "prepare_user_storage") {
CHECK_ARGC(6, "prepare_user_storage <uuid> <user> <serial> <ephemeral>");
- return sendGenericOkFail(cli, e4crypt_prepare_user_storage(
- parseNull(argv[2]), atoi(argv[3]), atoi(argv[4]) != 0));
+ return sendGenericOkFail(cli,
+ e4crypt_prepare_user_storage(parseNull(argv[2]),
+ atoi(argv[3]),
+ atoi(argv[4]),
+ atoi(argv[5]) != 0));
} else {
dumpArgs(argc, argv, -1);
diff --git a/Ext4Crypt.cpp b/Ext4Crypt.cpp
index 38dc27d..c3dcd0d 100644
--- a/Ext4Crypt.cpp
+++ b/Ext4Crypt.cpp
@@ -753,7 +753,10 @@
return 0;
}
-int e4crypt_prepare_user_storage(const char* volume_uuid, userid_t user_id, bool ephemeral) {
+int e4crypt_prepare_user_storage(const char* volume_uuid,
+ userid_t user_id,
+ int serial,
+ bool ephemeral) {
std::string system_ce_path(android::vold::BuildDataSystemCePath(user_id));
std::string user_ce_path(android::vold::BuildDataUserPath(volume_uuid, user_id));
std::string user_de_path(android::vold::BuildDataUserDePath(volume_uuid, user_id));
diff --git a/Ext4Crypt.h b/Ext4Crypt.h
index a3d9224..eb33876 100644
--- a/Ext4Crypt.h
+++ b/Ext4Crypt.h
@@ -44,6 +44,9 @@
int e4crypt_unlock_user_key(userid_t user_id, const char* token);
int e4crypt_lock_user_key(userid_t user_id);
-int e4crypt_prepare_user_storage(const char* volume_uuid, userid_t user_id, bool ephemeral);
+int e4crypt_prepare_user_storage(const char* volume_uuid,
+ userid_t user_id,
+ int serial,
+ bool ephemeral);
__END_DECLS
diff --git a/main.cpp b/main.cpp
index ea374c5..91e2d98 100644
--- a/main.cpp
+++ b/main.cpp
@@ -98,7 +98,7 @@
}
// Prepare owner storage
- e4crypt_prepare_user_storage(nullptr, 0, false);
+ e4crypt_prepare_user_storage(nullptr, 0, 0, false);
cl = new CommandListener();
ccl = new CryptCommandListener();