From 4dc36c99cdfdad3463b94d2bd943208c17220db9 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Mon, 5 Nov 2012 12:25:41 +0800 Subject: [PATCH] Fix incorrect access mode check The O_* variales are integers and aren't not suitable with bit operation, because O_RDONLY is 0, so if the mode is O_RDONLY, (mode & O_RDONLY) always return false. So the access mode is always 0, that means F_OK rather than R_OK. Change-Id: If750f85864d32f7d0a039b2ee114ef133a311434 Signed-off-by: Chengwei Yang --- logutil.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/logutil.c b/logutil.c index 671efee..d9d369f 100755 --- a/logutil.c +++ b/logutil.c @@ -661,8 +661,8 @@ int main(int argc, char **argv) g_dev_count = 1; int accessmode = - (mode & O_RDONLY) ? R_OK : 0 - | (mode & O_WRONLY) ? W_OK : 0; + (mode == O_RDONLY) ? R_OK : 0 + | (mode == O_WRONLY) ? W_OK : 0; // only add this if it's available if (0 == access("/dev/"LOGGER_LOG_SYSTEM, accessmode)) { -- 2.7.4