Skip to content

Commit 4aa8421

Browse files
Treehugger RobotGerrit Code Review
authored andcommitted
Merge "init: Add warning in init first stage mount"
2 parents b7761b2 + fdafb3d commit 4aa8421

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

init/uevent_listener.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323

2424
#include <memory>
2525

26+
#include <android-base/chrono_utils.h>
27+
#include <android-base/file.h>
2628
#include <android-base/logging.h>
29+
#include <android-base/scopeguard.h>
30+
#include <android-base/stringprintf.h>
2731
#include <cutils/uevent.h>
2832

2933
namespace android {
@@ -130,9 +134,19 @@ ListenerAction UeventListener::RegenerateUeventsForDir(DIR* d,
130134

131135
int fd = openat(dfd, "uevent", O_WRONLY);
132136
if (fd >= 0) {
137+
android::base::Timer t;
133138
write(fd, "add\n", 4);
139+
const std::string fd_path = android::base::StringPrintf("/proc/self/fd/%d", fd);
140+
std::string uevent_file_path;
141+
android::base::Readlink(fd_path, &uevent_file_path);
134142
close(fd);
135143

144+
auto guard = android::base::make_scope_guard([&t, &uevent_file_path]() {
145+
if (t.duration() > 50ms) {
146+
LOG(WARNING) << "ReadUevent took " << t << " on '" << uevent_file_path << "'";
147+
}
148+
});
149+
136150
Uevent uevent;
137151
while (ReadUevent(&uevent)) {
138152
if (callback(uevent) == ListenerAction::kStop) return ListenerAction::kStop;

0 commit comments

Comments
 (0)