summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/src/glfs-handleops.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c
index 0188128f712..cefe6e3157b 100644
--- a/api/src/glfs-handleops.c
+++ b/api/src/glfs-handleops.c
@@ -490,6 +490,7 @@ glfs_h_open (struct glfs *fs, struct glfs_object *object, int flags)
glfd = glfs_fd_new (fs);
if (!glfd) {
+ ret = -1;
errno = ENOMEM;
goto out;
}
@@ -509,6 +510,10 @@ glfs_h_open (struct glfs *fs, struct glfs_object *object, int flags)
ret = syncop_open (subvol, &loc, flags, glfd->fd);
DECODE_SYNCOP_ERR (ret);
+ glfd->fd->flags = flags;
+ fd_bind (glfd->fd);
+ glfs_fd_bind (glfd);
+
out:
loc_wipe (&loc);
@@ -518,9 +523,6 @@ out:
if (ret && glfd) {
glfs_fd_destroy (glfd);
glfd = NULL;
- } else {
- fd_bind (glfd->fd);
- glfs_fd_bind (glfd);
}
glfs_subvol_done (fs, subvol);
@@ -583,8 +585,11 @@ glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path,
GLFS_LOC_FILL_PINODE (inode, loc, ret, errno, out, path);
glfd = glfs_fd_new (fs);
- if (!glfd)
- goto out;
+ if (!glfd) {
+ ret = -1;
+ errno = ENOMEM;
+ goto out;
+ }
glfd->fd = fd_create (loc.inode, getpid());
if (!glfd->fd) {
@@ -617,6 +622,10 @@ glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path,
ret = glfs_create_object (&loc, &object);
}
+ glfd->fd->flags = flags;
+ fd_bind (glfd->fd);
+ glfs_fd_bind (glfd);
+
out:
if (ret && object != NULL) {
glfs_h_close (object);
@@ -631,7 +640,7 @@ out:
if (xattr_req)
dict_unref (xattr_req);
- if (glfd) {
+ if (ret && glfd) {
glfs_fd_destroy (glfd);
glfd = NULL;
}