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