liblog: introduce ANDROID_LOG_* flags
Move away from using POSIX open(2) flags and introduce ANDROID_LOG_* flags to
replace them. Add security by preventing random mode flags from getting into
underlying POSIX calls. ANDROID_LOG_* flags overlap POSIX O_* flag definitions.
Change-Id: Ib32bb64c287e8bf150be62242e1ba46bb37839fc
diff --git a/liblog/log_read.c b/liblog/log_read.c
index dbed886..0b126cf 100644
--- a/liblog/log_read.c
+++ b/liblog/log_read.c
@@ -582,7 +582,7 @@
return -EINVAL;
}
- if (logger_list->mode & O_NONBLOCK) {
+ if (logger_list->mode & ANDROID_LOG_NONBLOCK) {
memset(&ignore, 0, sizeof(ignore));
ignore.sa_handler = caught_signal;
sigemptyset(&ignore.sa_mask);
@@ -602,7 +602,7 @@
}
strcpy(buffer,
- (logger_list->mode & O_NONBLOCK) ? "dumpAndClose" : "stream");
+ (logger_list->mode & ANDROID_LOG_NONBLOCK) ? "dumpAndClose" : "stream");
cp = buffer + strlen(buffer);
strcpy(cp, " lids");
@@ -640,14 +640,14 @@
cp += ret;
}
- if (logger_list->mode & O_NONBLOCK) {
+ if (logger_list->mode & ANDROID_LOG_NONBLOCK) {
/* Deal with an unresponsive logd */
sigaction(SIGALRM, &ignore, &old_sigaction);
old_alarm = alarm(30);
}
ret = write(sock, buffer, cp - buffer);
e = errno;
- if (logger_list->mode & O_NONBLOCK) {
+ if (logger_list->mode & ANDROID_LOG_NONBLOCK) {
if (e == EINTR) {
e = ETIMEDOUT;
}
@@ -673,7 +673,7 @@
while(1) {
memset(log_msg, 0, sizeof(*log_msg));
- if (logger_list->mode & O_NONBLOCK) {
+ if (logger_list->mode & ANDROID_LOG_NONBLOCK) {
/* particularily useful if tombstone is reporting for logd */
sigaction(SIGALRM, &ignore, &old_sigaction);
old_alarm = alarm(30);
@@ -681,7 +681,7 @@
/* NOTE: SOCK_SEQPACKET guarantees we read exactly one full entry */
ret = recv(logger_list->sock, log_msg, LOGGER_ENTRY_MAX_LEN, 0);
e = errno;
- if (logger_list->mode & O_NONBLOCK) {
+ if (logger_list->mode & ANDROID_LOG_NONBLOCK) {
if ((ret == 0) || (e == EINTR)) {
e = EAGAIN;
ret = -1;