Merge "Use WaitForProperty() to wait for restorecon" am: 963a205a1b am: 80ce34d6cb

am: dfd0492354

Change-Id: Id3b68e5b946fc1bf886f59e59fee3960a2899041
gugelfrei
Tom Cherry 7 years ago committed by android-build-merger
commit bd40570e25

@ -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;
@ -670,7 +663,7 @@ status_t SaneReadLinkAt(int dirfd, const char* path, char* buf, size_t bufsiz) {
}
bool IsRunningInEmulator() {
return property_get_bool("ro.kernel.qemu", 0);
return android::base::GetBoolProperty("ro.kernel.qemu", false);
}
} // namespace vold

Loading…
Cancel
Save