summaryrefslogtreecommitdiffstats
path: root/api/src/glfs-handleops.c
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/glfs-handleops.c')
-rw-r--r--api/src/glfs-handleops.c193
1 files changed, 127 insertions, 66 deletions
diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c
index 5bba38b5f..14d6c1b2c 100644
--- a/api/src/glfs-handleops.c
+++ b/api/src/glfs-handleops.c
@@ -272,7 +272,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;
@@ -281,7 +281,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;
}
@@ -332,7 +332,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:
@@ -355,9 +355,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;
@@ -365,12 +372,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;
}
@@ -392,14 +397,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;
@@ -468,20 +465,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;
}
@@ -503,14 +514,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;
@@ -557,20 +560,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;
}
@@ -592,14 +611,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;
@@ -644,8 +655,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;
@@ -681,13 +710,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;
@@ -708,8 +737,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;
@@ -762,7 +797,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:
@@ -784,6 +819,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)
@@ -962,21 +1003,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;
}
@@ -998,14 +1037,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;
@@ -1056,6 +1087,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)
@@ -1114,8 +1162,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;
@@ -1178,7 +1226,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)
@@ -1200,8 +1248,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;
@@ -1269,7 +1323,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)
@@ -1291,3 +1345,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));
+}