aboutsummaryrefslogtreecommitdiffstats
path: root/uncrypt
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2015-05-29 14:24:02 -0700
committerTao Bao <tbao@google.com>2015-05-29 14:24:02 -0700
commit2c2cae8a4a18b85043bb6260a59ac7d1589016bf (patch)
treedb9b0d1566601089cf2a25df4f5ba0fc178c0b3f /uncrypt
parent92eea1bc414a7b6faedaf812c33ede17403fcaf7 (diff)
downloadbootable_recovery-2c2cae8a4a18b85043bb6260a59ac7d1589016bf.zip
bootable_recovery-2c2cae8a4a18b85043bb6260a59ac7d1589016bf.tar.gz
bootable_recovery-2c2cae8a4a18b85043bb6260a59ac7d1589016bf.tar.bz2
uncrypt: Write status when it reboots to factory reset
When it reboots into recovery for a factory reset, it still needs to write the uncrypt status (-1) to the pipe. Bug: 21511893 Change-Id: I1a725820f1e1875146e49b5a6f28af2fbf284fc7
Diffstat (limited to 'uncrypt')
-rw-r--r--uncrypt/uncrypt.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/uncrypt/uncrypt.cpp b/uncrypt/uncrypt.cpp
index 6e670a4..1db3013 100644
--- a/uncrypt/uncrypt.cpp
+++ b/uncrypt/uncrypt.cpp
@@ -427,26 +427,29 @@ int main(int argc, char** argv) {
wipe_misc();
reboot_to_recovery();
} else {
- std::string package;
+ // The pipe has been created by the system server.
+ int status_fd = open(status_file.c_str(), O_WRONLY | O_CREAT | O_SYNC, S_IRUSR | S_IWUSR);
+ if (status_fd == -1) {
+ ALOGE("failed to open pipe \"%s\": %s\n", status_file.c_str(), strerror(errno));
+ return 1;
+ }
+
if (argc == 3) {
// when command-line args are given this binary is being used
// for debugging.
input_path = argv[1];
map_file = argv[2];
} else {
+ std::string package;
if (!find_uncrypt_package(package)) {
+ android::base::WriteStringToFd("-1\n", status_fd);
+ close(status_fd);
return 1;
}
input_path = package.c_str();
map_file = cache_block_map.c_str();
}
- // The pipe has been created by the system server.
- int status_fd = open(status_file.c_str(), O_WRONLY | O_CREAT | O_SYNC, S_IRUSR | S_IWUSR);
- if (status_fd == -1) {
- ALOGE("failed to open pipe \"%s\": %s\n", status_file.c_str(), strerror(errno));
- return 1;
- }
int status = uncrypt(input_path, map_file, status_fd);
if (status != 0) {
android::base::WriteStringToFd("-1\n", status_fd);