Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=53d8c671e58... Commit: 53d8c671e58f471417584e0a68eb49d32afaa295 Parent: 7dcfbae20b74aa10fc597441a0538f654a13891b Author: Andrew Price anprice@redhat.com AuthorDate: Mon Oct 6 12:44:49 2014 +0100 Committer: Andrew Price anprice@redhat.com CommitterDate: Mon Oct 6 13:21:09 2014 +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@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;