e7a346
From 9656e92cfcd3db351c149e78ca36a4f3cf4c37f3 Mon Sep 17 00:00:00 2001
e7a346
From: Amar Tumballi <amarts@redhat.com>
e7a346
Date: Fri, 10 Aug 2018 15:28:35 +0530
e7a346
Subject: [PATCH 338/351] posix: prevent crash when SEEK_DATA/HOLE is not
e7a346
 supported
e7a346
e7a346
Instead of not defining the 'seek' fop when it's not supported on the
e7a346
compilation platform, we simply return EINVAL when it's used.
e7a346
e7a346
Upstream reference:
e7a346
> URL: https://review.gluster.org/20625
e7a346
> Fixes: bz#1611834
e7a346
> Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
e7a346
e7a346
BUG: 1610825
e7a346
Change-Id: I253666d8910c5e2fffa3a3ba37085e5c1c058a8e
e7a346
Signed-off-by: Amar Tumballi <amarts@redhat.com>
e7a346
Reviewed-on: https://code.engineering.redhat.com/gerrit/146682
e7a346
Tested-by: RHGS Build Bot <nigelb@redhat.com>
e7a346
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
e7a346
---
e7a346
 xlators/storage/posix/src/posix.c | 8 ++++----
e7a346
 1 file changed, 4 insertions(+), 4 deletions(-)
e7a346
e7a346
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
e7a346
index c3b7120..5203068 100644
e7a346
--- a/xlators/storage/posix/src/posix.c
e7a346
+++ b/xlators/storage/posix/src/posix.c
e7a346
@@ -1184,11 +1184,11 @@ posix_ipc (call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata)
e7a346
 
e7a346
 }
e7a346
 
e7a346
-#ifdef HAVE_SEEK_HOLE
e7a346
 static int32_t
e7a346
 posix_seek (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
e7a346
             gf_seek_what_t what, dict_t *xdata)
e7a346
 {
e7a346
+#ifdef HAVE_SEEK_HOLE
e7a346
         struct posix_fd *pfd       = NULL;
e7a346
         off_t            ret       = -1;
e7a346
         int              err       = 0;
e7a346
@@ -1236,9 +1236,11 @@ out:
e7a346
 
e7a346
         STACK_UNWIND_STRICT (seek, frame, (ret == -1 ? -1 : 0), err,
e7a346
                              (ret == -1 ? -1 : ret), xdata);
e7a346
+#else
e7a346
+        STACK_UNWIND_STRICT (seek, frame, -1, EINVAL, 0, NULL);
e7a346
+#endif
e7a346
         return 0;
e7a346
 }
e7a346
-#endif
e7a346
 
e7a346
 int32_t
e7a346
 posix_opendir (call_frame_t *frame, xlator_t *this,
e7a346
@@ -8018,9 +8020,7 @@ struct xlator_fops fops = {
e7a346
 	.discard     = posix_discard,
e7a346
         .zerofill    = posix_zerofill,
e7a346
         .ipc         = posix_ipc,
e7a346
-#ifdef HAVE_SEEK_HOLE
e7a346
         .seek        = posix_seek,
e7a346
-#endif
e7a346
         .lease       = posix_lease,
e7a346
 };
e7a346
 
e7a346
-- 
e7a346
1.8.3.1
e7a346