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