summaryrefslogtreecommitdiffstats
path: root/api/src
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2016-03-08 05:39:01 +0100
committerVijay Bellur <vbellur@redhat.com>2016-03-09 04:03:23 -0800
commitba1a401e142ad8884f9d3f13c51f7d5b17d008fc (patch)
treef82a51539b4329bcf4360df70d89addbe69bb0c6 /api/src
parentd6361f4d52251fe5f2e3af11e3a95fd0cf30a567 (diff)
gfapi: return EINVAL for unsupported lseek() operations
GlusterFS 3.8 contains support for SEEK_DATA/SEEK_HOLE. This protocol extension is not available in 3.7. libgfapi needs to handle unsupported SEEK_* operations correctly, by returning -1 and setting errno to EINVAL. This change is different from the patch in the master branch, it is only needed to do the improved error checking in this version. BUG: 1315557 Change-Id: I142dde11923244809b03fcca8cd4c2f7d5ff3929 Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/13631 Smoke: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'api/src')
-rw-r--r--api/src/glfs-fops.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index ff55bf3d673..ce0cebc20c1 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -525,6 +525,7 @@ pub_glfs_lseek (struct glfs_fd *glfd, off_t offset, int whence)
{
struct stat sb = {0, };
int ret = -1;
+ off_t off = -1;
DECLARE_OLD_THIS;
__GLFS_ENTRY_VALIDATE_FD (glfd, invalid_fs);
@@ -532,9 +533,11 @@ pub_glfs_lseek (struct glfs_fd *glfd, off_t offset, int whence)
switch (whence) {
case SEEK_SET:
glfd->offset = offset;
+ ret = 0;
break;
case SEEK_CUR:
glfd->offset += offset;
+ ret = 0;
break;
case SEEK_END:
ret = pub_glfs_fstat (glfd, &sb);
@@ -544,11 +547,16 @@ pub_glfs_lseek (struct glfs_fd *glfd, off_t offset, int whence)
}
glfd->offset = sb.st_size + offset;
break;
+ default:
+ errno = EINVAL;
}
__GLFS_EXIT_FS;
- return glfd->offset;
+ if (ret != -1)
+ off = glfd->offset;
+
+ return off;
invalid_fs:
return -1;