summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2016-10-27 10:13:42 -0500
committerMark Salyzyn2016-11-03 15:34:27 -0500
commitc377843258d08d31a2eb7df1a577740e588d2761 (patch)
tree6db18ce43e0aa872c2202ae5c081d301050f9a79 /libcutils/klog.cpp
parent77fdb22cf686002dfba8a24cf36666d7257b3034 (diff)
downloadplatform-system-core-c377843258d08d31a2eb7df1a577740e588d2761.tar.gz
platform-system-core-c377843258d08d31a2eb7df1a577740e588d2761.tar.xz
platform-system-core-c377843258d08d31a2eb7df1a577740e588d2761.zip
libcutils: klog inherit android_get_control_file("/dev/kmsg")
If the file descriptor is in the environment, use it. Test: compile Bug: 32450474 Change-Id: Id208b11b727a44dc861a141130a644d7d8009c5f
Diffstat (limited to 'libcutils/klog.cpp')
-rw-r--r--libcutils/klog.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/libcutils/klog.cpp b/libcutils/klog.cpp
index 061af1bf4..9d823cfae 100644
--- a/libcutils/klog.cpp
+++ b/libcutils/klog.cpp
@@ -24,6 +24,7 @@
24#include <sys/types.h> 24#include <sys/types.h>
25#include <unistd.h> 25#include <unistd.h>
26 26
27#include <cutils/files.h>
27#include <cutils/klog.h> 28#include <cutils/klog.h>
28 29
29static int klog_level = KLOG_DEFAULT_LEVEL; 30static int klog_level = KLOG_DEFAULT_LEVEL;
@@ -37,7 +38,11 @@ void klog_set_level(int level) {
37} 38}
38 39
39static int __open_klog(void) { 40static int __open_klog(void) {
40 return TEMP_FAILURE_RETRY(open("/dev/kmsg", O_WRONLY | O_CLOEXEC)); 41 static const char kmsg_device[] = "/dev/kmsg";
42
43 int ret = android_get_control_file(kmsg_device);
44 if (ret >= 0) return ret;
45 return TEMP_FAILURE_RETRY(open(kmsg_device, O_WRONLY | O_CLOEXEC));
41} 46}
42 47
43#define LOG_BUF_MAX 512 48#define LOG_BUF_MAX 512