summaryrefslogtreecommitdiffstats
path: root/libcutils
diff options
context:
space:
mode:
authorKen Sumrall <ksumrall@android.com>2013-04-15 10:35:31 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-04-15 10:35:31 -0700
commit3b0511788c86968860a682b6652c26c4415fa222 (patch)
tree2dbe336ef1c432428e0dd07c547b6bba82f14e98 /libcutils
parentc08b50dfc68504b692c13194e86d33328d373019 (diff)
parent774814d1940a87175fc7dc692fef5c626d893968 (diff)
downloadsystem_core-3b0511788c86968860a682b6652c26c4415fa222.tar.gz
system_core-3b0511788c86968860a682b6652c26c4415fa222.tar.bz2
system_core-3b0511788c86968860a682b6652c26c4415fa222.zip
am 774814d1: Merge "klog: Have klog_write() call klog_init() if needed" into jb-mr2-dev
* commit '774814d1940a87175fc7dc692fef5c626d893968': klog: Have klog_write() call klog_init() if needed
Diffstat (limited to 'libcutils')
-rw-r--r--libcutils/klog.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libcutils/klog.c b/libcutils/klog.c
index b586a575b..812af3bbf 100644
--- a/libcutils/klog.c
+++ b/libcutils/klog.c
@@ -35,6 +35,9 @@ void klog_set_level(int level) {
void klog_init(void)
{
static const char *name = "/dev/__kmsg__";
+
+ if (klog_fd >= 0) return; /* Already initialized */
+
if (mknod(name, S_IFCHR | 0600, (1 << 8) | 11) == 0) {
klog_fd = open(name, O_WRONLY);
fcntl(klog_fd, F_SETFD, FD_CLOEXEC);
@@ -50,7 +53,7 @@ void klog_write(int level, const char *fmt, ...)
va_list ap;
if (level > klog_level) return;
- if (klog_fd < 0) return;
+ if (klog_fd < 0) klog_init();
va_start(ap, fmt);
vsnprintf(buf, LOG_BUF_MAX, fmt, ap);