Gitweb:
http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=5f329b5b...
Commit: 5f329b5b8a35ca56fe70cb4fc067e4aff34b1b94
Parent: 7e3a8b6da97574d086aaecb94a08596925b82d41
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon Oct 6 12:44:49 2014 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Apr 1 16:51:34 2015 +0100
libgfs2: Fix check for O_RDONLY
Spotted by coverity: Execution cannot reach this statement "i->readonly
= 1U;"
This is due to a broken bitwise check for O_RDONLY which is 0 on Linux.
Use O_ACCMODE to mask out the access mode and check it properly.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/device_geometry.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gfs2/libgfs2/device_geometry.c b/gfs2/libgfs2/device_geometry.c
index 27e846d..1303f11 100644
--- a/gfs2/libgfs2/device_geometry.c
+++ b/gfs2/libgfs2/device_geometry.c
@@ -53,7 +53,7 @@ int lgfs2_get_dev_info(int fd, struct lgfs2_dev_info *i)
case S_IFREG:
i->size = i->stat.st_size;
ret = fcntl(fd, F_GETFL, 0);
- if (ret & O_RDONLY)
+ if ((ret & O_ACCMODE) == O_RDONLY)
i->readonly = 1;
i->io_optimal_size = i->stat.st_blksize;
goto size_check;