diff options
| author | Shehjar Tikoo <shehjart@zresearch.com> | 2009-04-16 23:53:12 -0700 | 
|---|---|---|
| committer | Anand V. Avati <avati@amp.gluster.com> | 2009-04-17 13:42:43 +0530 | 
| commit | 00968db3069e7b145f108d53a62d1899c9c1f3f9 (patch) | |
| tree | 110163a70c4364d2d624cb4fb3c30c75ee30543a /libglusterfsclient/src/libglusterfsclient.c | |
| parent | 1873d0bdb53af0311e8ad344116c0923448a6ff5 (diff) | |
libglusterfsclient: Generalize [RW] checks on dirs
This patch moves the read-write permission check on directory
inode into libgf_client_opendir, so that when I am next adding support
for the opendir syscall, I dont have to perform similar checks again,
outside this function.
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'libglusterfsclient/src/libglusterfsclient.c')
| -rwxr-xr-x | libglusterfsclient/src/libglusterfsclient.c | 27 | 
1 files changed, 11 insertions, 16 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index fd1ce0fa518..bd8dd6a9a6d 100755 --- a/libglusterfsclient/src/libglusterfsclient.c +++ b/libglusterfsclient/src/libglusterfsclient.c @@ -1459,16 +1459,21 @@ libgf_client_opendir (libglusterfs_client_ctx_t *ctx,                        fd_t *fd)  {          call_stub_t *stub = NULL; -        int32_t op_ret = 0; +        int32_t op_ret = -1;          libgf_client_local_t *local = NULL; +        if ((fd->flags & O_WRONLY) || (fd->flags & O_RDWR)) { +                errno = EISDIR; +                goto out; +        }          LIBGF_CLIENT_FOP (ctx, stub, opendir, local, loc, fd);          op_ret = stub->args.opendir_cbk.op_ret;          errno = stub->args.opendir_cbk.op_errno;  	call_stub_destroy (stub); -        return 0; +out: +        return op_ret;  }  glusterfs_file_t  @@ -1549,20 +1554,10 @@ glusterfs_open (glusterfs_handle_t handle,                  }                  op_ret = libgf_client_creat (ctx, &loc, fd, flags, mode);          } else { -                if (S_ISDIR (loc.inode->st_mode)) { -                        if (((flags & O_RDONLY) == O_RDONLY) &&  -                            ((flags & O_WRONLY) == 0) &&  -                            ((flags & O_RDWR) == 0)) {  -                                op_ret = libgf_client_opendir (ctx, -                                                               &loc, fd); -                        } else { -                                op_ret = -1; -                                errno = EISDIR; -                        } -                } else {   -                        op_ret = libgf_client_open (ctx, &loc, fd, -                                                    flags); -                } +                if (S_ISDIR (loc.inode->st_mode)) +                        op_ret = libgf_client_opendir (ctx, &loc, fd); +                else +                        op_ret = libgf_client_open (ctx, &loc, fd, flags);          }  op_over:  | 
