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