|
|
@ -20,11 +20,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include <android-base/file.h>
|
|
|
|
#include <android-base/file.h>
|
|
|
|
#include <android-base/logging.h>
|
|
|
|
#include <android-base/logging.h>
|
|
|
|
|
|
|
|
#include <android-base/properties.h>
|
|
|
|
#include <android-base/stringprintf.h>
|
|
|
|
#include <android-base/stringprintf.h>
|
|
|
|
#include <cutils/fs.h>
|
|
|
|
#include <cutils/fs.h>
|
|
|
|
#include <cutils/properties.h>
|
|
|
|
|
|
|
|
#include <private/android_filesystem_config.h>
|
|
|
|
|
|
|
|
#include <logwrap/logwrap.h>
|
|
|
|
#include <logwrap/logwrap.h>
|
|
|
|
|
|
|
|
#include <private/android_filesystem_config.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
#include <mutex>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <dirent.h>
|
|
|
@ -639,19 +639,12 @@ dev_t GetDevice(const std::string& path) {
|
|
|
|
status_t RestoreconRecursive(const std::string& path) {
|
|
|
|
status_t RestoreconRecursive(const std::string& path) {
|
|
|
|
LOG(VERBOSE) << "Starting restorecon of " << path;
|
|
|
|
LOG(VERBOSE) << "Starting restorecon of " << path;
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: find a cleaner way of waiting for restorecon to finish
|
|
|
|
static constexpr const char* kRestoreconString = "selinux.restorecon_recursive";
|
|
|
|
const char* cpath = path.c_str();
|
|
|
|
|
|
|
|
property_set("selinux.restorecon_recursive", "");
|
|
|
|
android::base::SetProperty(kRestoreconString, "");
|
|
|
|
property_set("selinux.restorecon_recursive", cpath);
|
|
|
|
android::base::SetProperty(kRestoreconString, path);
|
|
|
|
|
|
|
|
|
|
|
|
char value[PROPERTY_VALUE_MAX];
|
|
|
|
android::base::WaitForProperty(kRestoreconString, path);
|
|
|
|
while (true) {
|
|
|
|
|
|
|
|
property_get("selinux.restorecon_recursive", value, "");
|
|
|
|
|
|
|
|
if (strcmp(cpath, value) == 0) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
usleep(100000); // 100ms
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LOG(VERBOSE) << "Finished restorecon of " << path;
|
|
|
|
LOG(VERBOSE) << "Finished restorecon of " << path;
|
|
|
|
return OK;
|
|
|
|
return OK;
|
|
|
@ -684,7 +677,7 @@ ScopedDir::~ScopedDir() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool IsRunningInEmulator() {
|
|
|
|
bool IsRunningInEmulator() {
|
|
|
|
return property_get_bool("ro.kernel.qemu", 0);
|
|
|
|
return android::base::GetBoolProperty("ro.kernel.qemu", false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace vold
|
|
|
|
} // namespace vold
|
|
|
|