summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@gluster.com>2009-07-02 00:52:28 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-07-02 10:14:47 -0700
commit94f62eb4d50c7917c7c1ca36386045b110b30eda (patch)
tree7ccaee99b844aad5105ab6fdf62c863b6b20574a /libglusterfsclient
parent52d0ae7bc35680bcec094be39f119d966ea9a77f (diff)
libglusterfsclient: Use O_ACCMODE for access mode checks
Ref: http://www.gnu.org/s/libc/manual/html_node/Access-Modes.html Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
Diffstat (limited to 'libglusterfsclient')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index 576fef7f1b6..7246c91ccc7 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -2403,7 +2403,8 @@ libgf_client_opendir (libglusterfs_client_ctx_t *ctx,
int32_t op_ret = -1;
libgf_client_local_t *local = NULL;
- if ((fd->flags & O_WRONLY) || (fd->flags & O_RDWR)) {
+ if (((fd->flags & O_ACCMODE) == O_WRONLY)
+ || ((fd->flags & O_ACCMODE) == O_RDWR)) {
errno = EISDIR;
goto out;
}
@@ -2521,7 +2522,8 @@ op_over:
}
}
- if ((flags & O_TRUNC) && ((flags & O_RDWR) || (flags & O_WRONLY))) {
+ if ((flags & O_TRUNC) && (((flags & O_ACCMODE) == O_RDWR)
+ || ((flags & O_ACCMODE) == O_WRONLY))) {
inode_ctx = libgf_get_inode_ctx (fd->inode);
if (S_ISREG (inode_ctx->stbuf.st_mode)) {
inode_ctx->stbuf.st_size = 0;
@@ -5150,7 +5152,8 @@ libgf_client_ftruncate (libglusterfs_client_ctx_t *ctx, fd_t *fd,
int op_ret = -1;
libglusterfs_client_fd_ctx_t *fdctx = NULL;
- if (!(fd->flags & O_RDWR) && (!(fd->flags & O_WRONLY))) {
+ if ((!(fd->flags & O_ACCMODE) == O_RDWR)
+ && (!((fd->flags & O_ACCMODE) == O_WRONLY))) {
errno = EBADF;
goto out;
}