summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@zresearch.com>2009-04-20 12:30:15 -0700
committerAnand V. Avati <avati@amp.gluster.com>2009-04-21 12:48:28 +0530
commitd875df0c5c095488db29a202eac74d10d540aa3b (patch)
tree29eee8a84daead9d747fed2575df7dd559d27c8c /libglusterfsclient
parentbb2ca0ec0da700f600d1fa30d111c2aa42804f70 (diff)
libglusterfsclient: Add VMP-based open
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'libglusterfsclient')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c41
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.h7
2 files changed, 41 insertions, 7 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index f9472b68057..b7e278017d9 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -44,6 +44,7 @@
#include <utime.h>
#include <sys/param.h>
#include <list.h>
+#include <stdarg.h>
#define LIBGF_XL_NAME "libglusterfsclient"
#define LIBGLUSTERFS_INODE_TABLE_LRU_LIMIT 1000 //14057
@@ -1796,10 +1797,7 @@ out:
}
glusterfs_file_t
-glusterfs_open (glusterfs_handle_t handle,
- const char *path,
- int flags,
- mode_t mode)
+glusterfs_glh_open (glusterfs_handle_t handle, const char *path, int flags,...)
{
loc_t loc = {0, };
long op_ret = -1;
@@ -1808,6 +1806,8 @@ glusterfs_open (glusterfs_handle_t handle,
libglusterfs_client_ctx_t *ctx = handle;
char *name = NULL, *pathname = NULL;
libglusterfs_client_inode_ctx_t *inode_ctx = NULL;
+ mode_t mode = 0;
+ va_list ap;
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, ctx, out);
GF_VALIDATE_ABSOLUTE_PATH_OR_GOTO (LIBGF_XL_NAME, path, out);
@@ -1870,6 +1870,9 @@ glusterfs_open (glusterfs_handle_t handle,
op_ret = -1;
goto op_over;
}
+ va_start (ap, flags);
+ mode = va_arg (ap, mode_t);
+ va_end (ap);
op_ret = libgf_client_creat (ctx, &loc, fd, flags, mode);
} else {
if (S_ISDIR (loc.inode->st_mode))
@@ -1911,13 +1914,41 @@ out:
return fd;
}
+glusterfs_file_t
+glusterfs_open (const char *path, int flags, ...)
+{
+ struct vmp_entry *entry = NULL;
+ char *vpath = NULL;
+ glusterfs_file_t fh = NULL;
+ mode_t mode = 0;
+ va_list ap;
+
+ GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
+
+ entry = libgf_vmp_search_entry ((char *)path);
+ if (!entry) {
+ errno = ENODEV;
+ goto out;
+ }
+
+ vpath = libgf_vmp_virtual_path (entry, path);
+ if (flags & O_CREAT) {
+ va_start (ap, flags);
+ mode = va_arg (ap, mode_t);
+ va_end (ap);
+ fh = glusterfs_glh_open (entry->handle, vpath, flags, mode);
+ } else
+ fh = glusterfs_glh_open (entry->handle, vpath, flags);
+out:
+ return fh;
+}
glusterfs_file_t
glusterfs_creat (glusterfs_handle_t handle,
const char *path,
mode_t mode)
{
- return glusterfs_open (handle, path,
+ return glusterfs_glh_open (handle, path,
(O_CREAT | O_WRONLY | O_TRUNC), mode);
}
diff --git a/libglusterfsclient/src/libglusterfsclient.h b/libglusterfsclient/src/libglusterfsclient.h
index e611f056325..dabc288c139 100755
--- a/libglusterfsclient/src/libglusterfsclient.h
+++ b/libglusterfsclient/src/libglusterfsclient.h
@@ -102,8 +102,11 @@ glusterfs_get_async (glusterfs_handle_t handle, const char *path, size_t size,
glusterfs_get_cbk_t cbk, void *cbk_data);
glusterfs_file_t
-glusterfs_open (glusterfs_handle_t handle, const char *path, int flags,
- mode_t mode);
+glusterfs_glh_open (glusterfs_handle_t handle, const char *path, int flags,
+ ...);
+
+glusterfs_file_t
+glusterfs_open (const char *path, int flags, ...);
glusterfs_file_t
glusterfs_creat (glusterfs_handle_t handle, const char *path, mode_t mode);