summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2013-04-23 14:20:13 -0700
committerVijay Bellur <vbellur@redhat.com>2013-06-08 14:46:51 -0700
commit5b20fac94cd928747854c7170e368c6c864dff24 (patch)
treea6d8904ad0b959f8a8417cb7c3573af535b15ee5 /api
parent0a2f71d2fc8987e7226ae3ef7bc0cb05b5c53188 (diff)
gfapi: implement readdirplus_r support
This call is used by Samba VFS. Change-Id: Ib371502ad5a71b3b0e993f6b30e3dfb1f839c020 BUG: 953694 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.org/5154 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'api')
-rw-r--r--api/src/glfs-fops.c31
-rw-r--r--api/src/glfs.h3
2 files changed, 26 insertions, 8 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index 74d0daf99ae..3ce930f2745 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -1421,7 +1421,7 @@ gf_dirent_to_dirent (gf_dirent_t *gf_dirent, struct dirent *dirent)
int
-glfd_entry_refresh (struct glfs_fd *glfd)
+glfd_entry_refresh (struct glfs_fd *glfd, int plus)
{
xlator_t *subvol = NULL;
gf_dirent_t entries;
@@ -1437,8 +1437,12 @@ glfd_entry_refresh (struct glfs_fd *glfd)
INIT_LIST_HEAD (&entries.list);
INIT_LIST_HEAD (&old.list);
- ret = syncop_readdir (subvol, glfd->fd, 131072, glfd->offset,
- &entries);
+ if (plus)
+ ret = syncop_readdirp (subvol, glfd->fd, 131072, glfd->offset,
+ NULL, &entries);
+ else
+ ret = syncop_readdir (subvol, glfd->fd, 131072, glfd->offset,
+ &entries);
if (ret >= 0) {
/* spurious errno is dangerous for glfd_entry_next() */
errno = 0;
@@ -1457,13 +1461,13 @@ glfd_entry_refresh (struct glfs_fd *glfd)
gf_dirent_t *
-glfd_entry_next (struct glfs_fd *glfd)
+glfd_entry_next (struct glfs_fd *glfd, int plus)
{
gf_dirent_t *entry = NULL;
int ret = -1;
if (!glfd->offset || !glfd->next) {
- ret = glfd_entry_refresh (glfd);
+ ret = glfd_entry_refresh (glfd, plus);
if (ret < 0)
return NULL;
}
@@ -1484,7 +1488,8 @@ glfd_entry_next (struct glfs_fd *glfd)
int
-glfs_readdir_r (struct glfs_fd *glfd, struct dirent *buf, struct dirent **res)
+glfs_readdirplus_r (struct glfs_fd *glfd, struct stat *stat, struct dirent *buf,
+ struct dirent **res)
{
int ret = 0;
gf_dirent_t *entry = NULL;
@@ -1498,7 +1503,7 @@ glfs_readdir_r (struct glfs_fd *glfd, struct dirent *buf, struct dirent **res)
}
errno = 0;
- entry = glfd_entry_next (glfd);
+ entry = glfd_entry_next (glfd, !!stat);
if (errno)
ret = -1;
@@ -1509,14 +1514,24 @@ glfs_readdir_r (struct glfs_fd *glfd, struct dirent *buf, struct dirent **res)
*res = NULL;
}
- if (entry)
+ if (entry) {
gf_dirent_to_dirent (entry, buf);
+ if (stat)
+ iatt_to_stat (&entry->d_stat, stat);
+ }
out:
return ret;
}
int
+glfs_readdir_r (struct glfs_fd *glfd, struct dirent *buf, struct dirent **res)
+{
+ return glfs_readdirplus_r (glfd, 0, buf, res);
+}
+
+
+int
glfs_statvfs (struct glfs *fs, const char *path, struct statvfs *buf)
{
int ret = -1;
diff --git a/api/src/glfs.h b/api/src/glfs.h
index 7ff31dd62e3..06849d0c731 100644
--- a/api/src/glfs.h
+++ b/api/src/glfs.h
@@ -387,6 +387,9 @@ glfs_fd_t *glfs_opendir (glfs_t *fs, const char *path);
int glfs_readdir_r (glfs_fd_t *fd, struct dirent *dirent,
struct dirent **result);
+int glfs_readdirplus_r (glfs_fd_t *fd, struct stat *stat, struct dirent *dirent,
+ struct dirent **result);
+
long glfs_telldir (glfs_fd_t *fd);
void glfs_seekdir (glfs_fd_t *fd, long offset);