diff options
Diffstat (limited to 'api/src/glfs-handleops.c')
-rw-r--r-- | api/src/glfs-handleops.c | 193 |
1 files changed, 127 insertions, 66 deletions
diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c index 7fb202973..b97590239 100644 --- a/api/src/glfs-handleops.c +++ b/api/src/glfs-handleops.c @@ -432,7 +432,7 @@ out: } struct glfs_fd * -glfs_h_open (struct glfs *fs, struct glfs_object *object, int flags) +glfs_h_open_with_xdata (struct glfs *fs, struct glfs_object *object, int flags, dict_t * dict) { int ret = -1; struct glfs_fd *glfd = NULL; @@ -441,7 +441,7 @@ glfs_h_open (struct glfs *fs, struct glfs_object *object, int flags) loc_t loc = {0, }; /* validate in args */ - if ((fs == NULL) || (object == NULL)) { + if ((fs == NULL) || (object == NULL) || (dict == NULL)) { errno = EINVAL; return NULL; } @@ -492,7 +492,7 @@ glfs_h_open (struct glfs *fs, struct glfs_object *object, int flags) GLFS_LOC_FILL_INODE (inode, loc, out); /* fop/op */ - ret = syncop_open (subvol, &loc, flags, glfd->fd); + ret = syncop_open_with_xdata (subvol, &loc, flags, glfd->fd, dict); DECODE_SYNCOP_ERR (ret); out: @@ -515,9 +515,16 @@ out: return glfd; } +struct glfs_fd * +glfs_h_open (struct glfs *fs, struct glfs_object *object, int flags) +{ + return(glfs_h_open_with_xdata(fs, object, flags, NULL)); +} + struct glfs_object * -glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path, - int flags, mode_t mode, struct stat *stat) +glfs_h_creat_with_xdata (struct glfs *fs, struct glfs_object *parent, const char *path, + int flags, mode_t mode, struct stat *stat, + uuid_t gfid, dict_t * xattr_req) { int ret = -1; struct glfs_fd *glfd = NULL; @@ -525,12 +532,10 @@ glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path, inode_t *inode = NULL; loc_t loc = {0, }; struct iatt iatt = {0, }; - uuid_t gfid; - dict_t *xattr_req = NULL; struct glfs_object *object = NULL; /* validate in args */ - if ((fs == NULL) || (parent == NULL) || (path == NULL)) { + if ((fs == NULL) || (parent == NULL) || (path == NULL) || (xattr_req == NULL)) { errno = EINVAL; return NULL; } @@ -552,14 +557,6 @@ glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path, goto out; } - xattr_req = dict_new (); - if (!xattr_req) { - ret = -1; - errno = ENOMEM; - goto out; - } - - uuid_generate (gfid); ret = dict_set_static_bin (xattr_req, "gfid-req", gfid, 16); if (ret) { ret = -1; @@ -628,20 +625,34 @@ out: } struct glfs_object * -glfs_h_mkdir (struct glfs *fs, struct glfs_object *parent, const char *path, - mode_t mode, struct stat *stat) +glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path, + int flags, mode_t mode, struct stat *stat) +{ + uuid_t gfid; + dict_t *xattr_req = NULL; + + xattr_req = dict_new (); + if (!xattr_req) { + errno = ENOMEM; + return NULL; + } + uuid_generate (gfid); + return(glfs_h_creat_with_xdata(fs, parent, path, flags, mode, stat, gfid, xattr_req)); +} + +struct glfs_object * +glfs_h_mkdir_with_xdata (struct glfs *fs, struct glfs_object *parent, const char *path, + mode_t mode, struct stat *stat, uuid_t gfid, dict_t *xattr_req) { int ret = -1; xlator_t *subvol = NULL; inode_t *inode = NULL; loc_t loc = {0, }; struct iatt iatt = {0, }; - uuid_t gfid; - dict_t *xattr_req = NULL; struct glfs_object *object = NULL; /* validate in args */ - if ((fs == NULL) || (parent == NULL) || (path == NULL)) { + if ((fs == NULL) || (parent == NULL) || (path == NULL) || (xattr_req == NULL)) { errno = EINVAL; return NULL; } @@ -663,14 +674,6 @@ glfs_h_mkdir (struct glfs *fs, struct glfs_object *parent, const char *path, goto out; } - xattr_req = dict_new (); - if (!xattr_req) { - ret = -1; - errno = ENOMEM; - goto out; - } - - uuid_generate (gfid); ret = dict_set_static_bin (xattr_req, "gfid-req", gfid, 16); if (ret) { ret = -1; @@ -717,20 +720,36 @@ out: } struct glfs_object * -glfs_h_mknod (struct glfs *fs, struct glfs_object *parent, const char *path, - mode_t mode, dev_t dev, struct stat *stat) +glfs_h_mkdir (struct glfs *fs, struct glfs_object *parent, const char *path, + mode_t mode, struct stat *stat) +{ + uuid_t gfid; + dict_t *xattr_req = NULL; + + xattr_req = dict_new (); + if (!xattr_req) { + errno = ENOMEM; + return NULL; + } + + uuid_generate (gfid); + return(glfs_h_mkdir_with_xdata(fs, parent, path, mode, stat, gfid, xattr_req)); +} + +struct glfs_object * +glfs_h_mknod_with_xdata (struct glfs *fs, struct glfs_object *parent, const char *path, + mode_t mode, dev_t dev, struct stat *stat, + uuid_t gfid, dict_t * xattr_req) { int ret = -1; xlator_t *subvol = NULL; inode_t *inode = NULL; loc_t loc = {0, }; struct iatt iatt = {0, }; - uuid_t gfid; - dict_t *xattr_req = NULL; struct glfs_object *object = NULL; /* validate in args */ - if ((fs == NULL) || (parent == NULL) || (path == NULL)) { + if ((fs == NULL) || (parent == NULL) || (path == NULL) || (xattr_req == NULL)) { errno = EINVAL; return NULL; } @@ -752,14 +771,6 @@ glfs_h_mknod (struct glfs *fs, struct glfs_object *parent, const char *path, goto out; } - xattr_req = dict_new (); - if (!xattr_req) { - ret = -1; - errno = ENOMEM; - goto out; - } - - uuid_generate (gfid); ret = dict_set_static_bin (xattr_req, "gfid-req", gfid, 16); if (ret) { ret = -1; @@ -804,8 +815,26 @@ out: return object; } +struct glfs_object * +glfs_h_mknod (struct glfs *fs, struct glfs_object *parent, const char *path, + mode_t mode, dev_t dev, struct stat *stat) +{ + uuid_t gfid; + dict_t *xattr_req = NULL; + + xattr_req = dict_new (); + if (!xattr_req) { + errno = ENOMEM; + return NULL; + } + + uuid_generate (gfid); + + return(glfs_h_mknod_with_xdata(fs, parent, path, mode, dev, stat, gfid, xattr_req)); +} + int -glfs_h_unlink (struct glfs *fs, struct glfs_object *parent, const char *path) +glfs_h_unlink_with_xdata (struct glfs *fs, struct glfs_object *parent, const char *path, dict_t *dict) { int ret = -1; xlator_t *subvol = NULL; @@ -841,13 +870,13 @@ glfs_h_unlink (struct glfs *fs, struct glfs_object *parent, const char *path) } if (!IA_ISDIR(loc.inode->ia_type)) { - ret = syncop_unlink (subvol, &loc); + ret = syncop_unlink_with_xdata (subvol, &loc, dict); DECODE_SYNCOP_ERR (ret); if (ret != 0) { goto out; } } else { - ret = syncop_rmdir (subvol, &loc, 0); + ret = syncop_rmdir_with_xdata (subvol, &loc, 0, dict); DECODE_SYNCOP_ERR (ret); if (ret != 0) { goto out; @@ -868,8 +897,14 @@ out: return ret; } +int +glfs_h_unlink (struct glfs *fs, struct glfs_object *parent, const char *path) +{ + return(glfs_h_unlink_with_xdata(fs, parent, path, NULL)); +} + struct glfs_fd * -glfs_h_opendir (struct glfs *fs, struct glfs_object *object) +glfs_h_opendir_with_xdata (struct glfs *fs, struct glfs_object *object, dict_t *dict) { int ret = -1; struct glfs_fd *glfd = NULL; @@ -922,7 +957,7 @@ glfs_h_opendir (struct glfs *fs, struct glfs_object *object) GLFS_LOC_FILL_INODE (inode, loc, out); /* fop/op */ - ret = syncop_opendir (subvol, &loc, glfd->fd); + ret = syncop_opendir_with_xdata (subvol, &loc, glfd->fd, dict); DECODE_SYNCOP_ERR (ret); out: @@ -944,6 +979,12 @@ out: return glfd; } +struct glfs_fd * +glfs_h_opendir (struct glfs *fs, struct glfs_object *object) +{ + return(glfs_h_opendir_with_xdata(fs, object, NULL)); +} + ssize_t glfs_h_extract_handle (struct glfs_object *object, unsigned char *handle, int len) @@ -1122,21 +1163,19 @@ out: } struct glfs_object * -glfs_h_symlink (struct glfs *fs, struct glfs_object *parent, const char *name, - const char *data, struct stat *stat) +glfs_h_symlink_with_xdata (struct glfs *fs, struct glfs_object *parent, const char *name, + const char *data, struct stat *stat, uuid_t gfid, dict_t * xattr_req) { int ret = -1; xlator_t *subvol = NULL; inode_t *inode = NULL; loc_t loc = {0, }; struct iatt iatt = {0, }; - uuid_t gfid; - dict_t *xattr_req = NULL; struct glfs_object *object = NULL; /* validate in args */ if ((fs == NULL) || (parent == NULL) || (name == NULL) || - (data == NULL)) { + (data == NULL) || (xattr_req == NULL)) { errno = EINVAL; return NULL; } @@ -1158,14 +1197,6 @@ glfs_h_symlink (struct glfs *fs, struct glfs_object *parent, const char *name, goto out; } - xattr_req = dict_new (); - if (!xattr_req) { - ret = -1; - errno = ENOMEM; - goto out; - } - - uuid_generate (gfid); ret = dict_set_static_bin (xattr_req, "gfid-req", gfid, 16); if (ret) { ret = -1; @@ -1216,6 +1247,23 @@ out: return object; } +struct glfs_object * +glfs_h_symlink (struct glfs *fs, struct glfs_object *parent, const char *name, + const char *data, struct stat *stat) +{ + uuid_t gfid; + dict_t *xattr_req = NULL; + + xattr_req = dict_new (); + if (!xattr_req) { + errno = ENOMEM; + return NULL; + } + + uuid_generate (gfid); + return(glfs_h_symlink_with_xdata(fs, parent, name, data, stat, gfid, xattr_req)); +} + int glfs_h_readlink (struct glfs *fs, struct glfs_object *object, char *buf, size_t bufsiz) @@ -1274,8 +1322,8 @@ out: } int -glfs_h_link (struct glfs *fs, struct glfs_object *linksrc, - struct glfs_object *parent, const char *name) +glfs_h_link_with_xdata (struct glfs *fs, struct glfs_object *linksrc, + struct glfs_object *parent, const char *name, dict_t *dict) { int ret = -1; xlator_t *subvol = NULL; @@ -1338,7 +1386,7 @@ glfs_h_link (struct glfs *fs, struct glfs_object *linksrc, newloc.inode = inode_ref (inode); /* fop/op */ - ret = syncop_link (subvol, &oldloc, &newloc); + ret = syncop_link_with_xdata (subvol, &oldloc, &newloc, dict); DECODE_SYNCOP_ERR (ret); if (ret == 0) @@ -1360,8 +1408,14 @@ out: } int -glfs_h_rename (struct glfs *fs, struct glfs_object *olddir, const char *oldname, - struct glfs_object *newdir, const char *newname) +glfs_h_link (struct glfs *fs, struct glfs_object *linksrc, + struct glfs_object *parent, const char *name) +{ + return(glfs_h_link_with_xdata(fs, linksrc, parent, name, NULL)); +} +int +glfs_h_rename_with_xdata (struct glfs *fs, struct glfs_object *olddir, const char *oldname, + struct glfs_object *newdir, const char *newname, dict_t *dict) { int ret = -1; xlator_t *subvol = NULL; @@ -1429,7 +1483,7 @@ glfs_h_rename (struct glfs *fs, struct glfs_object *olddir, const char *oldname, /* TODO: check if new or old is a prefix of the other, and fail EINVAL */ - ret = syncop_rename (subvol, &oldloc, &newloc); + ret = syncop_rename_with_xdata (subvol, &oldloc, &newloc, dict); DECODE_SYNCOP_ERR (ret); if (ret == 0) @@ -1451,3 +1505,10 @@ out: return ret; } + +int +glfs_h_rename (struct glfs *fs, struct glfs_object *olddir, const char *oldname, + struct glfs_object *newdir, const char *newname) +{ + return(glfs_h_rename_with_xdata(fs, olddir, oldname, newdir, newname, NULL)); +} |