summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/src/glfs-internal.h51
-rw-r--r--api/src/glfs.c37
2 files changed, 88 insertions, 0 deletions
diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h
index 6fdec961a1c..ff875280ce6 100644
--- a/api/src/glfs-internal.h
+++ b/api/src/glfs-internal.h
@@ -226,4 +226,55 @@ int glfs_getxattr_process (void *value, size_t size, dict_t *xattr,
/* Sends RPC call to glusterd to fetch required volume info */
int glfs_get_volume_info (struct glfs *fs);
+/*
+ SYNOPSIS
+
+ glfs_new_from_ctx: Creates a virtual mount object by taking a
+ glusterfs_ctx_t object.
+
+ DESCRIPTION
+
+ glfs_new_from_ctx() is not same as glfs_new(). It takes the
+ glusterfs_ctx_t object instead of creating one by glusterfs_ctx_new().
+ Again the usage is restricted to NFS MOUNT over UDP i.e. in
+ glfs_resolve_at() which would take fs object as input but never use
+ (purpose is not to change the ABI of glfs_resolve_at()).
+
+ PARAMETERS
+
+ @ctx: glusterfs_ctx_t object
+
+ RETURN VALUES
+
+ fs : Pointer to the newly created glfs_t object.
+ NULL : Otherwise.
+*/
+
+struct glfs *glfs_new_from_ctx (glusterfs_ctx_t *ctx);
+
+/*
+ SYNOPSIS
+
+ glfs_free_from_ctx: Free up the memory occupied by glfs_t object
+ created by glfs_new_from_ctx().
+
+ DESCRIPTION
+
+ The glfs_t object allocated by glfs_new_from_ctx() must be released
+ by the caller using this routine. The usage is restricted to NFS
+ MOUNT over UDP i.e.
+ __mnt3udp_get_export_subdir_inode ()
+ => glfs_resolve_at().
+
+ PARAMETERS
+
+ @fs: The glfs_t object to be deallocated.
+
+ RETURN VALUES
+
+ void
+*/
+
+void glfs_free_from_ctx (struct glfs *fs);
+
#endif /* !_GLFS_INTERNAL_H */
diff --git a/api/src/glfs.c b/api/src/glfs.c
index bcabb29f857..c7c4c00450a 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -554,6 +554,43 @@ glfs_new (const char *volname)
}
+struct glfs *
+glfs_new_from_ctx (glusterfs_ctx_t *ctx)
+{
+ struct glfs *fs = NULL;
+
+ if (!ctx)
+ return NULL;
+
+ fs = GF_CALLOC (1, sizeof (*fs), glfs_mt_glfs_t);
+ if (!fs)
+ return NULL;
+ fs->ctx = ctx;
+
+ (void) pthread_cond_init (&fs->cond, NULL);
+
+ (void) pthread_mutex_init (&fs->mutex, NULL);
+
+ INIT_LIST_HEAD (&fs->openfds);
+
+ return fs;
+}
+
+
+void
+glfs_free_from_ctx (struct glfs *fs)
+{
+ if (!fs)
+ return;
+
+ (void) pthread_cond_destroy (&fs->cond);
+
+ (void) pthread_mutex_destroy (&fs->mutex);
+
+ GF_FREE (fs);
+}
+
+
int
glfs_set_volfile (struct glfs *fs, const char *volfile)
{