diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/src/glfs-fops.c | 10 |
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; |