summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/src/glfs-handleops.c160
-rw-r--r--api/src/glfs-handles.h11
-rw-r--r--api/src/glfs-internal.h3
3 files changed, 174 insertions, 0 deletions
diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c
index 49e0600156d..7fb202973d1 100644
--- a/api/src/glfs-handleops.c
+++ b/api/src/glfs-handleops.c
@@ -218,6 +218,59 @@ out:
}
int
+glfs_h_getxattrs (struct glfs *fs, struct glfs_object *object, const char *name,
+ void *value, size_t size)
+{
+ int ret = 0;
+ xlator_t *subvol = NULL;
+ inode_t *inode = NULL;
+ loc_t loc = {0, };
+ dict_t *xattr = NULL;
+
+ /* validate in args */
+ if ((fs == NULL) || (object == NULL)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ __glfs_entry_fs (fs);
+
+ /* get the active volume */
+ subvol = glfs_active_subvol (fs);
+ if (!subvol) {
+ ret = -1;
+ errno = EIO;
+ goto out;
+ }
+
+ /* get/refresh the in arg objects inode in correlation to the xlator */
+ inode = glfs_resolve_inode (fs, subvol, object);
+ if (!inode) {
+ errno = ESTALE;
+ goto out;
+ }
+
+ /* populate loc */
+ GLFS_LOC_FILL_INODE (inode, loc, out);
+
+ ret = syncop_getxattr (subvol, &loc, &xattr, name);
+ DECODE_SYNCOP_ERR (ret);
+
+ if (ret)
+ goto out;
+
+ ret = glfs_getxattr_process (value, size, xattr, name);
+
+out:
+ if (inode)
+ inode_unref (inode);
+
+ glfs_subvol_done (fs, subvol);
+
+ return ret;
+}
+
+int
glfs_h_setattrs (struct glfs *fs, struct glfs_object *object, struct stat *stat,
int valid)
{
@@ -271,6 +324,113 @@ out:
return ret;
}
+int
+glfs_h_setxattrs (struct glfs *fs, struct glfs_object *object, const char *name,
+ const void *value, size_t size, int flags)
+{
+ int ret = -1;
+ xlator_t *subvol = NULL;
+ inode_t *inode = NULL;
+ loc_t loc = {0, };
+ dict_t *xattr = NULL;
+
+ /* validate in args */
+ if ((fs == NULL) || (object == NULL) || (stat == NULL)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ __glfs_entry_fs (fs);
+
+ /* get the active volume */
+ subvol = glfs_active_subvol (fs);
+ if (!subvol) {
+ ret = -1;
+ errno = EIO;
+ goto out;
+ }
+
+ /* get/refresh the in arg objects inode in correlation to the xlator */
+ inode = glfs_resolve_inode (fs, subvol, object);
+ if (!inode) {
+ errno = ESTALE;
+ goto out;
+ }
+
+ xattr = dict_for_key_value (name, value, size);
+ if (!xattr) {
+ ret = -1;
+ errno = ENOMEM;
+ goto out;
+ }
+
+ /* populate loc */
+ GLFS_LOC_FILL_INODE (inode, loc, out);
+
+ /* fop/op */
+ ret = syncop_setxattr (subvol, &loc, xattr, flags);
+ DECODE_SYNCOP_ERR (ret);
+
+out:
+ loc_wipe (&loc);
+
+ if (inode)
+ inode_unref (inode);
+
+ glfs_subvol_done (fs, subvol);
+
+ return ret;
+}
+
+int
+glfs_h_removexattrs (struct glfs *fs, struct glfs_object *object, const char *name)
+{
+ int ret = -1;
+ xlator_t *subvol = NULL;
+ inode_t *inode = NULL;
+ loc_t loc = {0, };
+
+ /* validate in args */
+ if ((fs == NULL) || (object == NULL) || (stat == NULL)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ __glfs_entry_fs (fs);
+
+ /* get the active volume */
+ subvol = glfs_active_subvol (fs);
+ if (!subvol) {
+ ret = -1;
+ errno = EIO;
+ goto out;
+ }
+
+ /* get/refresh the in arg objects inode in correlation to the xlator */
+ inode = glfs_resolve_inode (fs, subvol, object);
+ if (!inode) {
+ errno = ESTALE;
+ goto out;
+ }
+
+ /* populate loc */
+ GLFS_LOC_FILL_INODE (inode, loc, out);
+
+ /* fop/op */
+ ret = syncop_removexattr (subvol, &loc, name, 0);
+ DECODE_SYNCOP_ERR (ret);
+
+out:
+ loc_wipe (&loc);
+
+ if (inode)
+ inode_unref (inode);
+
+ glfs_subvol_done (fs, subvol);
+
+ return ret;
+}
+
struct glfs_fd *
glfs_h_open (struct glfs *fs, struct glfs_object *object, int flags)
{
diff --git a/api/src/glfs-handles.h b/api/src/glfs-handles.h
index bc26618c4ee..0270897604e 100644
--- a/api/src/glfs-handles.h
+++ b/api/src/glfs-handles.h
@@ -114,9 +114,17 @@ int glfs_h_stat(struct glfs *fs, struct glfs_object *object,
int glfs_h_getattrs (struct glfs *fs, struct glfs_object *object,
struct stat *stat) __THROW;
+int glfs_h_getxattrs (struct glfs *fs, struct glfs_object *object,
+ const char *name, void *value,
+ size_t size) __THROW;
+
int glfs_h_setattrs (struct glfs *fs, struct glfs_object *object,
struct stat *sb, int valid) __THROW;
+int glfs_h_setxattrs (struct glfs *fs, struct glfs_object *object,
+ const char *name, const void *value,
+ size_t size, int flags) __THROW;
+
int glfs_h_readlink (struct glfs *fs, struct glfs_object *object, char *buf,
size_t bufsiz) __THROW;
@@ -127,6 +135,9 @@ int glfs_h_rename (struct glfs *fs, struct glfs_object *olddir,
const char *oldname, struct glfs_object *newdir,
const char *newname) __THROW;
+int glfs_h_removexattrs (struct glfs *fs, struct glfs_object *object,
+ const char *name) __THROW;
+
/* Operations enabling opaque invariant handle to object transitions */
ssize_t glfs_h_extract_handle (struct glfs_object *object,
unsigned char *handle, int len) __THROW;
diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h
index f04557323a0..d7d675e81b1 100644
--- a/api/src/glfs-internal.h
+++ b/api/src/glfs-internal.h
@@ -216,5 +216,8 @@ int glfs_loc_touchup (loc_t *loc);
void glfs_iatt_to_stat (struct glfs *fs, struct iatt *iatt, struct stat *stat);
int glfs_loc_link (loc_t *loc, struct iatt *iatt);
int glfs_loc_unlink (loc_t *loc);
+dict_t * dict_for_key_value (const char *name, const char *value, size_t size);
+int glfs_getxattr_process (void *value, size_t size, dict_t *xattr,
+ const char *name);
#endif /* !_GLFS_INTERNAL_H */