diff options
author | Jeff Darcy <jdarcy@redhat.com> | 2014-04-22 15:37:09 +0000 |
---|---|---|
committer | Jeff Darcy <jdarcy@redhat.com> | 2014-04-22 15:37:09 +0000 |
commit | a827c5eab32a43ade5551259ea56a6a1af7e861b (patch) | |
tree | e6707df68f72baa8645210ba931272285116ad85 /api/src/glfs-handleops.c | |
parent | 46d333783a968ab39e0beade9c7a1eec8035f8b1 (diff) | |
parent | 99bfc2a2a1689da1e173cb2f8ef54d2b09ef3a5d (diff) |
Merge branch 'upstream'
Conflicts:
glusterfs.spec.in
xlators/mgmt/glusterd/src/Makefile.am
xlators/mgmt/glusterd/src/glusterd-utils.c
xlators/mgmt/glusterd/src/glusterd.h
Change-Id: I27bdcf42b003cfc42d6ad981bd2bf8180176806d
Diffstat (limited to 'api/src/glfs-handleops.c')
-rw-r--r-- | api/src/glfs-handleops.c | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c index 6564269..b975902 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_with_xdata (struct glfs *fs, struct glfs_object *object, int flags, dict_t * dict) { |