Fix vold dump
- Original code of re-opening /proc/self/fd/fd does not work
due to selinux violation.
- fd (=pipe) passed over binder should be used as it is.
Bug: 202999256
Test: $ adb shell su root dumpsys vold
Change-Id: I1fceba89f1b07228e1677c266f87e431e93f7cb5
diff --git a/VoldNativeService.cpp b/VoldNativeService.cpp
index cad92f5..b4b9276 100644
--- a/VoldNativeService.cpp
+++ b/VoldNativeService.cpp
@@ -26,6 +26,7 @@
#include <private/android_filesystem_config.h>
#include <utils/Trace.h>
+#include <stdio.h>
#include <sys/vfs.h>
#include <fstream>
#include <thread>
@@ -133,15 +134,14 @@
}
status_t VoldNativeService::dump(int fd, const Vector<String16>& /* args */) {
- auto out = std::fstream(StringPrintf("/proc/self/fd/%d", fd));
const binder::Status dump_permission = CheckPermission(kDump);
if (!dump_permission.isOk()) {
- out << dump_permission.toString8() << endl;
+ dprintf(fd, "%s\n", dump_permission.toString8().c_str());
return PERMISSION_DENIED;
}
ACQUIRE_LOCK;
- out << "vold is happy!" << endl;
+ dprintf(fd, "vold is happy!\n");
return NO_ERROR;
}