9f5ccc
From 955fea10809861aa9b3da85d386c2cc92b319cdb Mon Sep 17 00:00:00 2001
9f5ccc
From: Barak Sason Rofman <bsasonro@redhat.com>
9f5ccc
Date: Thu, 7 May 2020 18:57:37 +0300
9f5ccc
Subject: [PATCH 372/375] posix - fix seek functionality
9f5ccc
9f5ccc
A wrong pointer check causes the offset returned by seek to be always
9f5ccc
wrong
9f5ccc
9f5ccc
backport of https://review.gluster.org/#/c/glusterfs/+/24412/
9f5ccc
>fixes: #1228
9f5ccc
>Change-Id: Iac4c6a163175617ac4f14544fc6b7c6fb4041cd6
9f5ccc
>Signed-off-by: Barak Sason Rofman <bsasonro@redhat.com>
9f5ccc
9f5ccc
BUG: 1833017
9f5ccc
Change-Id: Iac4c6a163175617ac4f14544fc6b7c6fb4041cd6
9f5ccc
Signed-off-by: Barak Sason Rofman <bsasonro@redhat.com>
9f5ccc
Reviewed-on: https://code.engineering.redhat.com/gerrit/199761
9f5ccc
Tested-by: RHGS Build Bot <nigelb@redhat.com>
9f5ccc
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
9f5ccc
---
9f5ccc
 libglusterfs/src/syncop.c | 11 ++++++-----
9f5ccc
 1 file changed, 6 insertions(+), 5 deletions(-)
9f5ccc
9f5ccc
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
9f5ccc
index 0de53c6..693970f 100644
9f5ccc
--- a/libglusterfs/src/syncop.c
9f5ccc
+++ b/libglusterfs/src/syncop.c
9f5ccc
@@ -2881,12 +2881,13 @@ syncop_seek(xlator_t *subvol, fd_t *fd, off_t offset, gf_seek_what_t what,
9f5ccc
     SYNCOP(subvol, (&args), syncop_seek_cbk, subvol->fops->seek, fd, offset,
9f5ccc
            what, xdata_in);
9f5ccc
 
9f5ccc
-    if (*off)
9f5ccc
-        *off = args.offset;
9f5ccc
-
9f5ccc
-    if (args.op_ret == -1)
9f5ccc
+    if (args.op_ret < 0) {
9f5ccc
         return -args.op_errno;
9f5ccc
-    return args.op_ret;
9f5ccc
+    } else {
9f5ccc
+        if (off)
9f5ccc
+            *off = args.offset;
9f5ccc
+        return args.op_ret;
9f5ccc
+    }
9f5ccc
 }
9f5ccc
 
9f5ccc
 int
9f5ccc
-- 
9f5ccc
1.8.3.1
9f5ccc