Convert vold_prepare_subdirs to C++
Minimize overhead in boot by replacing shell script invoked multiple
times with a C++ program invoked once.
Bug: 67901036
Test: create user, run adb shell ls -laZ /data/misc_ce/10; delete user
and check logs.
Change-Id: I886cfd6505cca1f5b5902f2071e13f48e612214d
diff --git a/Utils.cpp b/Utils.cpp
index 1f6ff21..38edcb3 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -271,14 +271,18 @@
}
}
- if (setexeccon(context)) {
- LOG(ERROR) << "Failed to setexeccon";
- abort();
+ if (context) {
+ if (setexeccon(context)) {
+ LOG(ERROR) << "Failed to setexeccon";
+ abort();
+ }
}
status_t res = android_fork_execvp(argc, argv, NULL, false, true);
- if (setexeccon(nullptr)) {
- LOG(ERROR) << "Failed to setexeccon";
- abort();
+ if (context) {
+ if (setexeccon(nullptr)) {
+ LOG(ERROR) << "Failed to setexeccon";
+ abort();
+ }
}
free(argv);
@@ -304,14 +308,18 @@
}
output.clear();
- if (setexeccon(context)) {
- LOG(ERROR) << "Failed to setexeccon";
- abort();
+ if (context) {
+ if (setexeccon(context)) {
+ LOG(ERROR) << "Failed to setexeccon";
+ abort();
+ }
}
FILE* fp = popen(cmd.c_str(), "r"); // NOLINT
- if (setexeccon(nullptr)) {
- LOG(ERROR) << "Failed to setexeccon";
- abort();
+ if (context) {
+ if (setexeccon(nullptr)) {
+ LOG(ERROR) << "Failed to setexeccon";
+ abort();
+ }
}
if (!fp) {