summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'init/ueventd.cpp')
-rw-r--r--init/ueventd.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/init/ueventd.cpp b/init/ueventd.cpp
index ff64e8eeb..c0eae1e9a 100644
--- a/init/ueventd.cpp
+++ b/init/ueventd.cpp
@@ -27,9 +27,9 @@
27#include <set> 27#include <set>
28#include <thread> 28#include <thread>
29 29
30#include <android-base/chrono_utils.h>
30#include <android-base/logging.h> 31#include <android-base/logging.h>
31#include <android-base/properties.h> 32#include <android-base/properties.h>
32#include <android-base/stringprintf.h>
33#include <selinux/android.h> 33#include <selinux/android.h>
34#include <selinux/selinux.h> 34#include <selinux/selinux.h>
35 35
@@ -100,6 +100,9 @@
100// the uevent listener resumes in polling mode and will handle the uevents that occurred during 100// the uevent listener resumes in polling mode and will handle the uevents that occurred during
101// coldboot. 101// coldboot.
102 102
103namespace android {
104namespace init {
105
103class ColdBoot { 106class ColdBoot {
104 public: 107 public:
105 ColdBoot(UeventListener& uevent_listener, DeviceHandler& device_handler) 108 ColdBoot(UeventListener& uevent_listener, DeviceHandler& device_handler)
@@ -158,9 +161,7 @@ void ColdBoot::ForkSubProcesses() {
158} 161}
159 162
160void ColdBoot::DoRestoreCon() { 163void ColdBoot::DoRestoreCon() {
161 for (const char* path : kRegenerationPaths) { 164 selinux_android_restorecon("/sys", SELINUX_ANDROID_RESTORECON_RECURSE);
162 selinux_android_restorecon(path, SELINUX_ANDROID_RESTORECON_RECURSE);
163 }
164 device_handler_.set_skip_restorecon(false); 165 device_handler_.set_skip_restorecon(false);
165} 166}
166 167
@@ -198,7 +199,7 @@ void ColdBoot::WaitForSubProcesses() {
198} 199}
199 200
200void ColdBoot::Run() { 201void ColdBoot::Run() {
201 Timer cold_boot_timer; 202 android::base::Timer cold_boot_timer;
202 203
203 RegenerateUevents(); 204 RegenerateUevents();
204 205
@@ -209,7 +210,7 @@ void ColdBoot::Run() {
209 WaitForSubProcesses(); 210 WaitForSubProcesses();
210 211
211 close(open(COLDBOOT_DONE, O_WRONLY | O_CREAT | O_CLOEXEC, 0000)); 212 close(open(COLDBOOT_DONE, O_WRONLY | O_CREAT | O_CLOEXEC, 0000));
212 LOG(INFO) << "Coldboot took " << cold_boot_timer; 213 LOG(INFO) << "Coldboot took " << cold_boot_timer.duration().count() / 1000.0f << " seconds";
213} 214}
214 215
215DeviceHandler CreateDeviceHandler() { 216DeviceHandler CreateDeviceHandler() {
@@ -268,6 +269,13 @@ int ueventd_main(int argc, char** argv) {
268 cold_boot.Run(); 269 cold_boot.Run();
269 } 270 }
270 271
272 // We use waitpid() in ColdBoot, so we can't ignore SIGCHLD until now.
273 signal(SIGCHLD, SIG_IGN);
274 // Reap and pending children that exited between the last call to waitpid() and setting SIG_IGN
275 // for SIGCHLD above.
276 while (waitpid(-1, nullptr, WNOHANG) > 0) {
277 }
278
271 uevent_listener.Poll([&device_handler](const Uevent& uevent) { 279 uevent_listener.Poll([&device_handler](const Uevent& uevent) {
272 HandleFirmwareEvent(uevent); 280 HandleFirmwareEvent(uevent);
273 device_handler.HandleDeviceEvent(uevent); 281 device_handler.HandleDeviceEvent(uevent);
@@ -276,3 +284,6 @@ int ueventd_main(int argc, char** argv) {
276 284
277 return 0; 285 return 0;
278} 286}
287
288} // namespace init
289} // namespace android