From e1ae573f73d69fe1a244ed1493793961dd4cf811 Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Mon, 11 May 2009 18:23:14 +0530 Subject: libglusterfsclient: Add telldir API Signed-off-by: Anand V. Avati --- libglusterfsclient/src/libglusterfsclient.c | 22 ++++++++++++++++++++++ libglusterfsclient/src/libglusterfsclient.h | 13 +++++++++++++ 2 files changed, 35 insertions(+) (limited to 'libglusterfsclient') diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index b4a7e6e54..29ef163df 100755 --- a/libglusterfsclient/src/libglusterfsclient.c +++ b/libglusterfsclient/src/libglusterfsclient.c @@ -6468,6 +6468,28 @@ out: return; } +off_t +glusterfs_telldir (glusterfs_dir_t dirfd) +{ + libglusterfs_client_fd_ctx_t *fd_ctx = NULL; + off_t off = -1; + + fd_ctx = libgf_get_fd_ctx ((fd_t *)dirfd); + if (!fd_ctx) { + errno = EBADF; + goto out; + } + + pthread_mutex_lock (&fd_ctx->lock); + { + off = fd_ctx->offset; + } + pthread_mutex_unlock (&fd_ctx->lock); + +out: + return off; +} + static struct xlator_fops libgf_client_fops = { }; diff --git a/libglusterfsclient/src/libglusterfsclient.h b/libglusterfsclient/src/libglusterfsclient.h index 70c6669dc..a2c9a0fa5 100755 --- a/libglusterfsclient/src/libglusterfsclient.h +++ b/libglusterfsclient/src/libglusterfsclient.h @@ -1217,6 +1217,19 @@ glusterfs_rewinddir (glusterfs_dir_t dirfd); */ void glusterfs_seekdir (glusterfs_dir_t dirfd, off_t offset); + + + +/* Return the current offset in a directory stream. + * + * @dirfd : Directory handle returned by glusterfs_open on + * glusterfs_opendir. + * + * Returns the offset in the directory or -1 on error with errno set + * appropriately. + */ +off_t +glusterfs_telldir (glusterfs_dir_t dirfd); /* FIXME: review the need for these apis */ /* added for log related initialization in booster fork implementation */ void -- cgit