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>
This commit is contained in:
Shehjar Tikoo 2009-04-16 23:53:12 -07:00 committed by Anand V. Avati
parent 1873d0bdb5
commit 00968db306

View File

@ -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: