Merge "Use WaitForProperty() to wait for restorecon"

am: 963a205a1b

Change-Id: I4a11f21c0849922cda49e3f771a0b0dcfc5a3177
gugelfrei
Tom Cherry 7 years ago committed by android-build-merger
commit 80ce34d6cb

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

Loading…
Cancel
Save