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