summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient/src
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@zresearch.com>2009-04-07 05:36:57 -0700
committerAnand V. Avati <avati@amp.gluster.com>2009-04-08 15:05:55 +0530
commit957ae7ba2ba7b8276dab963b7af7dbf16eeb5888 (patch)
treeebfeb22b18aa80429d1f73ad05318373a279c40d /libglusterfsclient/src
parentd4ab91b1f254a21cac538fdffa7ff37db10ae83c (diff)
libglusterfsclient: Perform explicit create
We must create the file based on the O_CREATE in the flags instead of depending on the return status of the lookup. This works because we've already handled O_EXCL earlier and also handled a missing file(ENOENT) in case this was actually an open and not create. Adapted from Raghu's original patch. Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'libglusterfsclient/src')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index 99129fc250a..9602492a625 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -1574,7 +1574,9 @@ glusterfs_open (glusterfs_handle_t handle,
fd = fd_create (loc.inode, 0);
fd->flags = flags;
- if (!op_ret) {
+ if ((flags & O_CREAT) == O_CREAT)
+ 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) &&
@@ -1589,9 +1591,6 @@ glusterfs_open (glusterfs_handle_t handle,
op_ret = libgf_client_open (ctx, &loc, fd,
flags);
}
- } else {
- op_ret = libgf_client_creat (ctx, &loc, fd, flags,
- mode);
}
if (op_ret == -1) {