summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient/src/libglusterfsclient.c
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfsclient/src/libglusterfsclient.c')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c50
1 files changed, 34 insertions, 16 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index 85c9e3c9ef1..456323778fa 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -3628,19 +3628,16 @@ libgf_client_readv_cbk (call_frame_t *frame,
return 0;
}
-int
-libgf_client_read (libglusterfs_client_ctx_t *ctx,
- fd_t *fd,
- void *buf,
- size_t size,
- off_t offset)
+int
+libgf_client_iobuf_read (libglusterfs_client_ctx_t *ctx, fd_t *fd, void *buf,
+ size_t size, off_t offset)
{
- call_stub_t *stub;
- struct iovec *vector;
- int32_t op_ret = -1;
- int count = 0;
+ call_stub_t *stub = NULL;
+ struct iovec *vector = NULL;
+ int32_t op_ret = -1;
+ int count = 0;
libgf_client_local_t *local = NULL;
- struct stat *stbuf = NULL;
+ struct stat *stbuf = NULL;
local = CALLOC (1, sizeof (*local));
ERR_ABORT (local);
@@ -3655,7 +3652,7 @@ libgf_client_read (libglusterfs_client_ctx_t *ctx,
int i = 0;
op_ret = 0;
while (size && (i < count)) {
- int len = (size < vector[i].iov_len) ?
+ int len = (size < vector[i].iov_len) ?
size : vector[i].iov_len;
memcpy (buf, vector[i++].iov_base, len);
buf += len;
@@ -3673,10 +3670,31 @@ libgf_client_read (libglusterfs_client_ctx_t *ctx,
return op_ret;
}
-ssize_t
-glusterfs_read (glusterfs_file_t fd,
- void *buf,
- size_t nbytes)
+int
+libgf_client_read (libglusterfs_client_ctx_t *ctx, fd_t *fd, void *buf,
+ size_t size, off_t offset)
+{
+ int32_t op_ret = -1;
+ size_t tmp = 0;
+
+ while (size != 0) {
+ tmp = ((size > LIBGF_IOBUF_SIZE) ? LIBGF_IOBUF_SIZE :
+ size);
+ op_ret = libgf_client_iobuf_read (ctx, fd, buf, tmp, offset);
+ if (op_ret <= 0) {
+ break;
+ }
+
+ size -= op_ret;
+ offset += op_ret;
+ buf = (char *)buf + op_ret;
+ }
+
+ return op_ret;
+}
+
+ssize_t
+glusterfs_read (glusterfs_file_t fd, void *buf, size_t nbytes)
{
int32_t op_ret = -1;
off_t offset = 0;