summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2016-03-08 05:39:01 +0100
committerNiels de Vos <ndevos@redhat.com>2016-03-08 21:21:29 -0800
commit206ccaa4f417da633af3860a3ffae896d517fdd0 (patch)
tree6375962c789e68aa35155927ad7dd85ce9d9e190
parent721b15a74d9e4ff8455744cfc8672bf007e33cf5 (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.5. 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: 1315559 Change-Id: I142dde11923244809b03fcca8cd4c2f7d5ff3929 Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/13634 NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
-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 66460e6..6726371 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -439,15 +439,18 @@ pub_glfs_lseek (struct glfs_fd *glfd, off_t offset, int whence)
{
struct stat sb = {0, };
int ret = -1;
+ off_t off = -1;
__glfs_entry_fd (glfd);
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);
@@ -457,9 +460,14 @@ pub_glfs_lseek (struct glfs_fd *glfd, off_t offset, int whence)
}
glfd->offset = sb.st_size + offset;
break;
+ default:
+ errno = EINVAL;
}
- return glfd->offset;
+ if (ret != -1)
+ off = glfd->offset;
+
+ return off;
}
GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_lseek, 3.4.0);