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