a3470f
From d542543faf4eca04737ddfe215e8988a700caf42 Mon Sep 17 00:00:00 2001
a3470f
From: Amar Tumballi <amarts@redhat.com>
a3470f
Date: Thu, 9 Aug 2018 10:17:56 +0530
a3470f
Subject: [PATCH 348/351] posix: disable block and character files
a3470f
a3470f
The special files (block and character) needn't be supported on
a3470f
n/w filesystem. As each of these files are used closely with the
a3470f
host machine, instead of client data, we would be tied to server.
a3470f
a3470f
BUG: 1610966
a3470f
Change-Id: Id65f1a6c51876a84c56cf691bb44a3e85ae73d70
a3470f
Signed-off-by: Amar Tumballi <amarts@redhat.com>
a3470f
Reviewed-on: https://code.engineering.redhat.com/gerrit/146526
a3470f
Reviewed-by: FNU Raghavendra Manjunath <raghavendra@redhat.com>
a3470f
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
a3470f
---
a3470f
 xlators/storage/posix/src/posix.c | 17 +++++++++++++++++
a3470f
 1 file changed, 17 insertions(+)
a3470f
a3470f
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
a3470f
index 49b272f..28d2e6f 100644
a3470f
--- a/xlators/storage/posix/src/posix.c
a3470f
+++ b/xlators/storage/posix/src/posix.c
a3470f
@@ -1452,6 +1452,23 @@ posix_mknod (call_frame_t *frame, xlator_t *this,
a3470f
         }
a3470f
 
a3470f
 
a3470f
+        if (((mode & S_IFMT) == S_IFBLK) || ((mode & S_IFMT) == S_IFCHR)) {
a3470f
+                /* Man page 'man 2 mknod':
a3470f
+                    EPERM  mode  requested  creation  of something other than
a3470f
+                    a regular file, FIFO (named pipe), or UNIX domain socket,
a3470f
+                    and the caller is not privileged (Linux: does not have the
a3470f
+                    CAP_MKNOD capability); also returned  if  the  filesystem
a3470f
+                    containing pathname does not support the type of node
a3470f
+                    requested.
a3470f
+                */
a3470f
+                op_ret = -1;
a3470f
+                op_errno = EPERM;
a3470f
+                gf_msg (this->name, GF_LOG_ERROR, op_errno, P_MSG_MKNOD_FAILED,
a3470f
+                        "%s: mknod failed as Block and Character devices "
a3470f
+                        "are not supported on GlusterFS", real_path);
a3470f
+                goto out;
a3470f
+        }
a3470f
+
a3470f
         op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
a3470f
         if (op_ret == -1) {
a3470f
                 op_errno = errno;
a3470f
-- 
a3470f
1.8.3.1
a3470f