From 957ae7ba2ba7b8276dab963b7af7dbf16eeb5888 Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Tue, 7 Apr 2009 05:36:57 -0700 Subject: 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 --- libglusterfsclient/src/libglusterfsclient.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libglusterfsclient/src') 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) { -- cgit