summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient/src/libglusterfsclient.c
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:48 -0700
commitcf87dfa3f44172635b9d071c83cd2fcd2479c668 (patch)
tree5a3e21786741d7cc856519bf68ef9360c2a74201 /libglusterfsclient/src/libglusterfsclient.c
parent13fd1ec05715b97f91b91f3954bd9f87e86ae33d (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/src/libglusterfsclient.c')
-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 576fef7..7246c91 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;
}