diff options
| -rw-r--r-- | api/src/Makefile.am | 2 | ||||
| -rw-r--r-- | api/src/gfapi.aliases | 2 | ||||
| -rw-r--r-- | api/src/gfapi.map | 2 | ||||
| -rw-r--r-- | api/src/glfs-handleops.c | 128 | ||||
| -rw-r--r-- | api/src/glfs-handles.h | 10 | ||||
| -rw-r--r-- | api/src/glfs-mem-types.h | 2 | ||||
| -rw-r--r-- | api/src/glfs.h | 7 | ||||
| -rw-r--r-- | glusterfs-api.pc.in | 4 | ||||
| -rw-r--r-- | heal/src/Makefile.am | 2 | 
9 files changed, 143 insertions, 16 deletions
diff --git a/api/src/Makefile.am b/api/src/Makefile.am index 5117428d4df..04246578ff6 100644 --- a/api/src/Makefile.am +++ b/api/src/Makefile.am @@ -18,7 +18,7 @@ libgfapi_la_CPPFLAGS = $(GF_CPPFLAGS) -D__USE_FILE_OFFSET64 \  	-I$(top_srcdir)/rpc/xdr/src  libgfapi_la_LDFLAGS = -version-info $(GFAPI_LT_VERSION) \ -	$(GFAPI_EXTRA_LDFLAGS) +	$(GFAPI_EXTRA_LDFLAGS) $(ACL_LIBS)  xlator_LTLIBRARIES = api.la  xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/mount diff --git a/api/src/gfapi.aliases b/api/src/gfapi.aliases index 6dfc1089d86..8c60373fd4b 100644 --- a/api/src/gfapi.aliases +++ b/api/src/gfapi.aliases @@ -127,6 +127,8 @@ _pub_glfs_h_access _glfs_h_access$GFAPI_3.6.0  _pub_glfs_ipc _glfs_ipc$GFAPI_3.7.0  _pub_glfs_h_poll_upcall _glfs_h_poll_upcall$GFAPI_3.7.0 +_pub_glfs_h_acl_set _glfs_h_acl_set$GFAPI_3.7.0 +_pub_glfs_h_acl_get _glfs_h_acl_get$GFAPI_3.7.0  _priv_glfs_free_from_ctx _glfs_free_from_ctx$GFAPI_PRIVATE_3.7.0  _priv_glfs_new_from_ctx _glfs_new_from_ctx$GFAPI_PRIVATE_3.7.0 diff --git a/api/src/gfapi.map b/api/src/gfapi.map index 4721efdff80..58ebdb5bc45 100644 --- a/api/src/gfapi.map +++ b/api/src/gfapi.map @@ -149,6 +149,8 @@ GFAPI_3.7.0 {  	global:  		glfs_ipc;                  glfs_h_poll_upcall; +                glfs_h_acl_set; +                glfs_h_acl_get;  } GFAPI_3.6.0;  GFAPI_PRIVATE_3.7.0 { diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c index 037315a518d..e60bb8e1317 100644 --- a/api/src/glfs-handleops.c +++ b/api/src/glfs-handleops.c @@ -231,14 +231,13 @@ GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_h_getattrs, 3.4.2);  int -pub_glfs_h_getxattrs (struct glfs *fs, struct glfs_object *object, -                      const char *name, void *value, size_t size) +glfs_h_getxattrs_common (struct glfs *fs, struct glfs_object *object, +                         dict_t **xattr, const char *name)  {          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)) { @@ -266,9 +265,35 @@ pub_glfs_h_getxattrs (struct glfs *fs, struct glfs_object *object,          /* populate loc */          GLFS_LOC_FILL_INODE (inode, loc, out); -        ret = syncop_getxattr (subvol, &loc, &xattr, name, NULL); +        ret = syncop_getxattr (subvol, &loc, xattr, name, NULL);          DECODE_SYNCOP_ERR (ret); +out: +        loc_wipe (&loc); + +        if (inode) +                inode_unref (inode); + +        glfs_subvol_done (fs, subvol); + +        return ret; +} + + +int +pub_glfs_h_getxattrs (struct glfs *fs, struct glfs_object *object, +                      const char *name, void *value, size_t size) +{ +        int                 ret = 0; +        dict_t                *xattr = NULL; + +        /* validate in args */ +        if ((fs == NULL) || (object == NULL)) { +                errno = EINVAL; +                return -1; +        } + +        ret = glfs_h_getxattrs_common (fs, object, &xattr, name);          if (ret)                  goto out; @@ -279,13 +304,8 @@ pub_glfs_h_getxattrs (struct glfs *fs, struct glfs_object *object,                  ret = glfs_listxattr_process (value, size, xattr);  out: -        loc_wipe (&loc); - -        if (inode) -                inode_unref (inode); - -        glfs_subvol_done (fs, subvol); - +        if (xattr) +                dict_unref (xattr);          return ret;  } @@ -1723,3 +1743,89 @@ err:  }  GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_h_poll_upcall, 3.7.0); + +#ifdef HAVE_ACL_LIBACL_H +#include "glusterfs-acl.h" +#include <acl/libacl.h> + +int +pub_glfs_h_acl_set (struct glfs *fs, struct glfs_object *object, +                    const acl_type_t type, const acl_t acl) +{ +        int ret = -1; +        char *acl_s = NULL; +        const char *acl_key = NULL; +        ssize_t acl_len = 0; + +        if (!fs || !object || !acl) { +                errno = EINVAL; +                return ret; +        } + +        acl_key = gf_posix_acl_get_key (type); +        if (!acl_key) +                return ret; + +        acl_s = acl_to_any_text (acl, NULL, ',', +                                 TEXT_ABBREVIATE | TEXT_NUMERIC_IDS); +        if (!acl_s) +                return ret; + +        ret = pub_glfs_h_setxattrs (fs, object, acl_key, acl_s, acl_len, 0); + +        acl_free (acl_s); +        return ret; +} + +acl_t +pub_glfs_h_acl_get (struct glfs *fs, struct glfs_object *object, +                    const acl_type_t type) +{ +        int                 ret = 0; +        acl_t acl = NULL; +        char *acl_s = NULL; +        dict_t *xattr = NULL; +        const char *acl_key = NULL; + +        if (!fs || !object) { +                errno = EINVAL; +                return NULL; +        } + +        acl_key = gf_posix_acl_get_key (type); +        if (!acl_key) +                return NULL; + +        ret = glfs_h_getxattrs_common (fs, object, &xattr, acl_key); +        if (ret) +                return NULL; + +        ret = dict_get_str (xattr, (char *)acl_key, &acl_s); +        if (ret == -1) +                goto out; + +        acl = acl_from_text (acl_s); + +out: +        GF_FREE (acl_s); +        return acl; +} +#else /* !HAVE_ACL_LIBACL_H */ +acl_t +pub_glfs_h_acl_get (struct glfs *fs, struct glfs_object *object, +                    const acl_type_t type) +{ +        errno = ENOTSUP; +        return NULL; +} + +int +pub_glfs_h_acl_set (struct glfs *fs, struct glfs_object *object, +                    const acl_type_t type, const acl_t acl) +{ +        errno = ENOTSUP; +        return -1; +} +#endif +GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_h_acl_set, 3.7.0); +GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_h_acl_get, 3.7.0); diff --git a/api/src/glfs-handles.h b/api/src/glfs-handles.h index c88f134b001..a939aa0df54 100644 --- a/api/src/glfs-handles.h +++ b/api/src/glfs-handles.h @@ -271,6 +271,16 @@ int  glfs_h_poll_upcall (struct glfs *fs, struct callback_arg *cbk) __THROW          GFAPI_PUBLIC(glfs_h_poll_upcall, 3.7.0); +int +glfs_h_acl_set (struct glfs *fs, struct glfs_object *object, +                const acl_type_t type, const acl_t acl) __THROW; +        GFAPI_PUBLIC(glfs_h_acl_set, 3.7.0); + +acl_t +glfs_h_acl_get (struct glfs *fs, struct glfs_object *object, +                const acl_type_t type) __THROW; +        GFAPI_PUBLIC(glfs_h_acl_get, 3.7.0); +  __END_DECLS  #endif /* !_GLFS_HANDLES_H */ diff --git a/api/src/glfs-mem-types.h b/api/src/glfs-mem-types.h index c1883f089fd..cad1ca95d4f 100644 --- a/api/src/glfs-mem-types.h +++ b/api/src/glfs-mem-types.h @@ -26,7 +26,7 @@ enum glfs_mem_types_ {  	glfs_mt_glfs_object_t,  	glfs_mt_readdirbuf_t,          glfs_mt_upcall_entry_t, +	glfs_mt_acl_t,  	glfs_mt_end -  };  #endif diff --git a/api/src/glfs.h b/api/src/glfs.h index 9ee772741e6..b073d8d1b17 100644 --- a/api/src/glfs.h +++ b/api/src/glfs.h @@ -42,6 +42,13 @@  #include <dirent.h>  #include <sys/statvfs.h> +#if defined(HAVE_SYS_ACL_H) || (defined(USE_POSIX_ACLS) && USE_POSIX_ACLS) +#include <sys/acl.h> +#else +typedef void *acl_t; +typedef int acl_type_t; +#endif +  /* Portability non glibc c++ build systems */  #ifndef __THROW  # if defined __cplusplus diff --git a/glusterfs-api.pc.in b/glusterfs-api.pc.in index e88e70369ff..a8bc8ebda99 100644 --- a/glusterfs-api.pc.in +++ b/glusterfs-api.pc.in @@ -7,5 +7,5 @@ Name: glusterfs-api  Description: GlusterFS API  /* This is the API version, NOT package version */  Version: @GFAPI_VERSION@ -Libs: -L${libdir} -lgfapi -lglusterfs -lgfrpc -lgfxdr -Cflags: -I${includedir}/glusterfs -D_FILE_OFFSET_BITS=64 -D__USE_FILE_OFFSET64 +Libs: -L${libdir} @GFAPI_LIBS@ -lgfapi -lglusterfs -lgfrpc -lgfxdr +Cflags: -I${includedir}/glusterfs -D_FILE_OFFSET_BITS=64 -D__USE_FILE_OFFSET64 -DUSE_POSIX_ACLS=@USE_POSIX_ACLS@ diff --git a/heal/src/Makefile.am b/heal/src/Makefile.am index 80be3d443cf..acde4b15a88 100644 --- a/heal/src/Makefile.am +++ b/heal/src/Makefile.am @@ -6,7 +6,7 @@ glfsheal_LDADD = $(top_builddir)/libglusterfs/src/libglusterfs.la $(GF_LDADD)\  		$(RLLIBS) $(top_builddir)/rpc/xdr/src/libgfxdr.la \  		$(top_builddir)/rpc/rpc-lib/src/libgfrpc.la \  		$(top_builddir)/api/src/libgfapi.la \ -		$(GF_GLUSTERFS_LIBS) $(XML_LIBS) +		$(GF_GLUSTERFS_LIBS) $(XML_LIBS) $(GFAPI_LIBS)  glfsheal_LDFLAGS = $(GF_LDFLAGS)  | 
