]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: add C bindings for UserPerm constructor and destructor
authorJeff Layton <jlayton@redhat.com>
Mon, 24 Oct 2016 14:02:58 +0000 (10:02 -0400)
committerJeff Layton <jlayton@redhat.com>
Tue, 25 Oct 2016 17:05:16 +0000 (13:05 -0400)
Signed-off-by: Jeff Layton <jlayton@redhat.com>
src/include/cephfs/libcephfs.h
src/libcephfs.cc

index 117e7368a254af97c896dfded82db095b8216978..f333937423e37e54eaa9851010e48f6849f56282 100644 (file)
@@ -97,6 +97,9 @@ typedef struct vinodeno_t vinodeno;
 
 #endif /* ! __cplusplus */
 
+struct UserPerm;
+typedef struct UserPerm UserPerm;
+
 struct Inode;
 typedef struct Inode Inode;
 
@@ -121,6 +124,34 @@ struct CephContext;
 # define CEPHFS_ERROR_NEW_CLIENT 1002
 # define CEPHFS_ERROR_MESSENGER_START 1003
 
+/**
+ * Create a UserPerm credential object.
+ *
+ * Some calls (most notably, the ceph_ll_* ones), take a credential object
+ * that represents the credentials that the calling program is using. This
+ * function creates a new credential object for this purpose. Returns a
+ * pointer to the object, or NULL if it can't be allocated.
+ *
+ * Note that the gidlist array is used directly and is not copied. It must
+ * remain valid over the lifetime of the created UserPerm object.
+ *
+ * @param uid uid to be used
+ * @param gid gid to be used
+ * @param ngids number of gids in supplemental grouplist
+ * @param gidlist array of gid_t's in the list of groups
+ */
+UserPerm *ceph_userperm_new(uid_t uid, gid_t gid, int ngids, gid_t *gidlist);
+
+/**
+ * Destroy a UserPerm credential object.
+ *
+ * @param perm pointer to object to be destroyed
+ *
+ * Currently this just frees the object. Note that the gidlist array is not
+ * freed. The caller must do so if it's necessary.
+ */
+void ceph_userperm_destroy(UserPerm *perm);
+
 /**
  * @defgroup libcephfs_h_init Setup and Teardown
  * These are the first and last functions that should be called
index f5e31c9ccbdd101861f2b28527a8d5bb7bdc88f0..8b33968346c90e671d19bfd7ad83f166eda49f9d 100644 (file)
@@ -284,6 +284,17 @@ static void do_out_buffer(string& outbl, char **outbuf, size_t *outbuflen)
     *outbuflen = outbl.length();
 }
 
+extern "C" UserPerm *ceph_userperm_new(uid_t uid, gid_t gid, int ngids,
+                                      gid_t *gidlist)
+{
+  return new (std::nothrow) UserPerm(uid, gid, ngids, gidlist);
+}
+
+extern "C" void ceph_userperm_destroy(UserPerm *perm)
+{
+  delete perm;
+}
+
 extern "C" const char *ceph_version(int *pmajor, int *pminor, int *ppatch)
 {
   int major, minor, patch;