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