summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2016-03-08 05:39:01 +0100
committerRaghavendra Bhat <raghavendra@redhat.com>2016-03-30 08:28:37 -0700
commitcaccd6c205cd324ef184ac6333fb05acd0cc5d4e (patch)
treef7a5066098bb7ccb04e423455dc18a159e4aed8e /api
parent52f6c664a27cddad37196c91fbb4c03d7da774b3 (diff)
gfapi: return EINVAL for unsupported lseek() operationsrelease-3.6
GlusterFS 3.8 contains support for SEEK_DATA/SEEK_HOLE. This protocol extension is not available in 3.6. 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: 1315558 Change-Id: I142dde11923244809b03fcca8cd4c2f7d5ff3929 Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/13633 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com> Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'api')
-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 722cd5e2736..5c15df0490b 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -446,15 +446,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);
@@ -464,9 +467,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);