summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient/src
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@zresearch.com>2009-04-16 23:52:54 -0700
committerAnand V. Avati <avati@amp.gluster.com>2009-04-17 13:42:38 +0530
commit1873d0bdb53af0311e8ad344116c0923448a6ff5 (patch)
tree30496cb9f05a8c77781233db5c617d44bad816cc /libglusterfsclient/src
parent79215d4f2487e6db87e5fd637f0262037c1d230b (diff)
libglusterfsclient: Check for directory on O_CREAT
If we have received an O_CREAT for a name where that basename is a directory, and if we have successfully looked up the inode for this directory, then we can check for S_ISDIR in libglusterfsclient and prevent sending a message to the server through libgf_client_creat. See also the comment inline. Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'libglusterfsclient/src')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index d91b026a18c..fd1ce0fa518 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -1536,9 +1536,19 @@ glusterfs_open (glusterfs_handle_t handle,
fd = fd_create (loc.inode, 0);
fd->flags = flags;
- if ((flags & O_CREAT) == O_CREAT)
+ if ((flags & O_CREAT) == O_CREAT) {
+ /* If we have the st_mode for the basename, check if
+ * it is a directory here itself, rather than sending
+ * a network message through libgf_client_creat, and
+ * then receiving a EISDIR.
+ */
+ if (S_ISDIR (loc.inode->st_mode)) {
+ errno = EISDIR;
+ op_ret = -1;
+ goto op_over;
+ }
op_ret = libgf_client_creat (ctx, &loc, fd, flags, mode);
- else {
+ } else {
if (S_ISDIR (loc.inode->st_mode)) {
if (((flags & O_RDONLY) == O_RDONLY) &&
((flags & O_WRONLY) == 0) &&
@@ -1555,6 +1565,7 @@ glusterfs_open (glusterfs_handle_t handle,
}
}
+op_over:
if (op_ret == -1) {
fd_unref (fd);
fd = NULL;