am 9c58a871: Use monotonic clock for cryptfs progress
* commit '9c58a871f9fb356409d3b90734bf706d1463f041':
Use monotonic clock for cryptfs progress
diff --git a/Android.mk b/Android.mk
index 1a1d28a..8647c97 100644
--- a/Android.mk
+++ b/Android.mk
@@ -23,8 +23,6 @@
system/extras/ext4_utils \
system/extras/f2fs_utils \
external/openssl/include \
- external/stlport/stlport \
- bionic \
external/scrypt/lib/crypto \
frameworks/native/include \
system/security/keystore \
@@ -33,7 +31,6 @@
common_shared_libraries := \
libsysutils \
- libstlport \
libbinder \
libcutils \
liblog \
@@ -56,48 +53,38 @@
include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_MODULE := libvold
-
LOCAL_SRC_FILES := $(common_src_files)
-
LOCAL_C_INCLUDES := $(common_c_includes)
-
LOCAL_SHARED_LIBRARIES := $(common_shared_libraries)
-
LOCAL_STATIC_LIBRARIES := $(common_static_libraries)
-
LOCAL_MODULE_TAGS := eng tests
+include external/stlport/libstlport.mk
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_MODULE:= vold
-
LOCAL_SRC_FILES := \
main.cpp \
$(common_src_files)
LOCAL_C_INCLUDES := $(common_c_includes)
-
LOCAL_CFLAGS := -Werror=format
-
LOCAL_SHARED_LIBRARIES := $(common_shared_libraries)
-
LOCAL_STATIC_LIBRARIES := $(common_static_libraries)
+include external/stlport/libstlport.mk
include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_SRC_FILES:= vdc.c
-
LOCAL_MODULE:= vdc
-
-LOCAL_C_INCLUDES :=
-
-LOCAL_CFLAGS :=
-
LOCAL_SHARED_LIBRARIES := libcutils
include $(BUILD_EXECUTABLE)
diff --git a/DirectVolume.cpp b/DirectVolume.cpp
index cfa1e0b..64d7744 100644
--- a/DirectVolume.cpp
+++ b/DirectVolume.cpp
@@ -321,11 +321,17 @@
char msg[255];
bool enabled;
- if (mVm->shareEnabled(getLabel(), "ums", &enabled) == 0 && enabled) {
+ SLOGD("Volume %s %s disk %d:%d removed\n", getLabel(), getMountpoint(), major, minor);
+ if ((dev_t) MKDEV(major, minor) == mCurrentlyMountedKdev) {
+ /*
+ * Yikes, our mounted disk is going away!
+ */
+
+ doUnmount(major, minor);
+ } else if (mVm->shareEnabled(getLabel(), "ums", &enabled) == 0 && enabled) {
mVm->unshareVolume(getLabel(), "ums");
}
- SLOGD("Volume %s %s disk %d:%d removed\n", getLabel(), getMountpoint(), major, minor);
snprintf(msg, sizeof(msg), "Volume %s %s disk removed (%d:%d)",
getLabel(), getFuseMountpoint(), major, minor);
mVm->getBroadcaster()->sendBroadcast(ResponseCode::VolumeDiskRemoved,
@@ -352,29 +358,12 @@
if (state != Volume::State_Mounted && state != Volume::State_Shared) {
return;
}
-
+
if ((dev_t) MKDEV(major, minor) == mCurrentlyMountedKdev) {
/*
* Yikes, our mounted partition is going away!
*/
-
- bool providesAsec = (getFlags() & VOL_PROVIDES_ASEC) != 0;
- if (providesAsec && mVm->cleanupAsec(this, true)) {
- SLOGE("Failed to cleanup ASEC - unmount will probably fail!");
- }
-
- snprintf(msg, sizeof(msg), "Volume %s %s bad removal (%d:%d)",
- getLabel(), getFuseMountpoint(), major, minor);
- mVm->getBroadcaster()->sendBroadcast(ResponseCode::VolumeBadRemoval,
- msg, false);
-
- if (Volume::unmountVol(true, false)) {
- SLOGE("Failed to unmount volume on bad removal (%s)",
- strerror(errno));
- // XXX: At this point we're screwed for now
- } else {
- SLOGD("Crisis averted");
- }
+ doUnmount(major, minor);
} else if (state == Volume::State_Shared) {
/* removed during mass storage */
snprintf(msg, sizeof(msg), "Volume %s bad removal (%d:%d)",
@@ -391,6 +380,27 @@
}
}
+void DirectVolume::doUnmount(int major, int minor) {
+ char msg[255];
+ bool providesAsec = (getFlags() & VOL_PROVIDES_ASEC) != 0;
+ if (providesAsec && mVm->cleanupAsec(this, true)) {
+ SLOGE("Failed to cleanup ASEC - unmount will probably fail!");
+ }
+
+ snprintf(msg, sizeof(msg), "Volume %s %s bad removal (%d:%d)",
+ getLabel(), getFuseMountpoint(), major, minor);
+ mVm->getBroadcaster()->sendBroadcast(ResponseCode::VolumeBadRemoval,
+ msg, false);
+
+ if (Volume::unmountVol(true, false)) {
+ SLOGE("Failed to unmount volume on bad removal (%s)",
+ strerror(errno));
+ // XXX: At this point we're screwed for now
+ } else {
+ SLOGD("Crisis averted");
+ }
+}
+
/*
* Called from base to get a list of devicenodes for mounting
*/
diff --git a/DirectVolume.h b/DirectVolume.h
index 5e0df74..96f46af 100644
--- a/DirectVolume.h
+++ b/DirectVolume.h
@@ -84,6 +84,7 @@
void handlePartitionChanged(const char *devpath, NetlinkEvent *evt);
int doMountVfat(const char *deviceNode, const char *mountPoint);
+ void doUnmount(int major, int minor);
};
diff --git a/Volume.cpp b/Volume.cpp
index ca56d1c..0baf008 100644
--- a/Volume.cpp
+++ b/Volume.cpp
@@ -252,7 +252,7 @@
dev_t diskNode = getDiskDevice();
dev_t partNode =
MKDEV(MAJOR(diskNode),
- MINOR(diskNode) + (formatEntireDevice ? 1 : mPartIdx));
+ MINOR(diskNode) + (formatEntireDevice ? 0 : mPartIdx));
setState(Volume::State_Formatting);
diff --git a/cryptfs.c b/cryptfs.c
index 2878b20..85a71e9 100644
--- a/cryptfs.c
+++ b/cryptfs.c
@@ -1283,7 +1283,8 @@
}
/* Initialize the decryption engine */
- if (! EVP_EncryptInit(&e_ctx, EVP_aes_128_cbc(), ikey, ikey+KEY_LEN_BYTES)) {
+ EVP_CIPHER_CTX_init(&e_ctx);
+ if (! EVP_EncryptInit_ex(&e_ctx, EVP_aes_128_cbc(), NULL, ikey, ikey+KEY_LEN_BYTES)) {
SLOGE("EVP_EncryptInit failed\n");
return -1;
}
@@ -1295,7 +1296,7 @@
SLOGE("EVP_EncryptUpdate failed\n");
return -1;
}
- if (! EVP_EncryptFinal(&e_ctx, encrypted_master_key + encrypted_len, &final_len)) {
+ if (! EVP_EncryptFinal_ex(&e_ctx, encrypted_master_key + encrypted_len, &final_len)) {
SLOGE("EVP_EncryptFinal failed\n");
return -1;
}
@@ -1345,7 +1346,8 @@
}
/* Initialize the decryption engine */
- if (! EVP_DecryptInit(&d_ctx, EVP_aes_128_cbc(), ikey, ikey+KEY_LEN_BYTES)) {
+ EVP_CIPHER_CTX_init(&d_ctx);
+ if (! EVP_DecryptInit_ex(&d_ctx, EVP_aes_128_cbc(), NULL, ikey, ikey+KEY_LEN_BYTES)) {
return -1;
}
EVP_CIPHER_CTX_set_padding(&d_ctx, 0); /* Turn off padding as our data is block aligned */
@@ -1354,7 +1356,7 @@
encrypted_master_key, KEY_LEN_BYTES)) {
return -1;
}
- if (! EVP_DecryptFinal(&d_ctx, decrypted_master_key + decrypted_len, &final_len)) {
+ if (! EVP_DecryptFinal_ex(&d_ctx, decrypted_master_key + decrypted_len, &final_len)) {
return -1;
}
diff --git a/tests/Android.mk b/tests/Android.mk
index 8ae4b5d..bcdcfca 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -1,36 +1,20 @@
# Build the unit tests.
LOCAL_PATH := $(call my-dir)
+
include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-test_src_files := \
- VolumeManager_test.cpp
+LOCAL_C_INCLUDES := \
+ system/core/fs_mgr/include \
+ external/openssl/include \
-shared_libraries := \
- liblog \
- libstlport \
- libcrypto
+LOCAL_SHARED_LIBRARIES := \
+ liblog \
+ libcrypto \
-static_libraries := \
- libvold \
- libgtest \
- libgtest_main
+LOCAL_STATIC_LIBRARIES := libvold
+LOCAL_SRC_FILES := VolumeManager_test.cpp
+LOCAL_MODULE := vold_tests
+LOCAL_MODULE_TAGS := eng tests
-c_includes := \
- external/openssl/include \
- bionic \
- bionic/libstdc++/include \
- external/gtest/include \
- external/stlport/stlport
-
-module_tags := eng tests
-
-$(foreach file,$(test_src_files), \
- $(eval include $(CLEAR_VARS)) \
- $(eval LOCAL_SHARED_LIBRARIES := $(shared_libraries)) \
- $(eval LOCAL_STATIC_LIBRARIES := $(static_libraries)) \
- $(eval LOCAL_C_INCLUDES := $(c_includes)) \
- $(eval LOCAL_SRC_FILES := $(file)) \
- $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \
- $(eval LOCAL_MODULE_TAGS := $(module_tags)) \
- $(eval include $(BUILD_EXECUTABLE)) \
-)
+include $(BUILD_NATIVE_TEST)