[PATCHES] vfs_gpfs: Check for GPFS file system on connect

Christof Schmitt cs at samba.org
Tue Sep 18 17:48:14 UTC 2018


From 0e8b8d261005be87d80e471e5e77c8175d6b5a15 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Mon, 17 Sep 2018 17:09:16 -0700
Subject: [PATCH 1/2] vfs_gpfs: Check for GPFS file system on connect

The vfs_gpfs modules uses GPFS API calls that only succeed when using
the module with the GPFS file system. Add an explicit statfs check for
the file system type on connect, to make it obvious when the file system
is missing or not mounted. The check can be skipped by setting
gpfs:check_fstype to 'no'.

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/vfs_gpfs.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 982dc19e785..3a75efdf5e6 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -2078,6 +2078,7 @@ static int vfs_gpfs_connect(struct vfs_handle_struct *handle,
 {
 	struct gpfs_config_data *config;
 	int ret;
+	bool check_fstype;
 
 	gpfswrap_lib_init(0);
 
@@ -2094,6 +2095,31 @@ static int vfs_gpfs_connect(struct vfs_handle_struct *handle,
 		return ret;
 	}
 
+	check_fstype = lp_parm_bool(SNUM(handle->conn), "gpfs",
+				    "check_fstype", true);
+
+	if (check_fstype && !IS_IPC(handle->conn)) {
+		const char *connectpath = handle->conn->connectpath;
+		struct statfs buf = { 0 };
+
+		ret = statfs(connectpath, &buf);
+		if (ret != 0) {
+			DBG_ERR("statfs failed for share %s at path %s: %s\n",
+				service, connectpath, strerror(errno));
+			TALLOC_FREE(config);
+			return ret;
+		}
+
+		if (buf.f_type != GPFS_SUPER_MAGIC) {
+			DBG_ERR("SMB share %s, path %s not in GPFS file system."
+				" statfs magic: 0x%lx\n",
+				service, connectpath, buf.f_type);
+			errno = EINVAL;
+			TALLOC_FREE(config);
+			return -1;
+		}
+	}
+
 	ret = smbacl4_get_vfs_params(handle->conn, &config->nfs4_params);
 	if (ret < 0) {
 		TALLOC_FREE(config);
-- 
2.17.0


From 7a32b816a0931acc7db6297faf5f3c481b092010 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Mon, 17 Sep 2018 17:16:56 -0700
Subject: [PATCH 2/2] docs: Add gpfs:check_fstype to vfs_gpfs manpage

Signed-off-by; Christof Schmit <cs at samba.org>
---
 docs-xml/manpages/vfs_gpfs.8.xml | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/docs-xml/manpages/vfs_gpfs.8.xml b/docs-xml/manpages/vfs_gpfs.8.xml
index 428f48a6bf0..15e7bcf9d77 100644
--- a/docs-xml/manpages/vfs_gpfs.8.xml
+++ b/docs-xml/manpages/vfs_gpfs.8.xml
@@ -244,6 +244,28 @@
 		</varlistentry>
 		<varlistentry>
 
+		<term>gpfs:check_fstype = [ yes | no ]</term>
+		<listitem>
+		<para>
+		Check for a mounted GPFS file system on access to a SMB share.
+		</para>
+
+		<itemizedlist>
+		<listitem><para>
+		<command>yes(default)</command> - Check that the SMB share path
+		is on a GPFS file system. Share access will be denied when a
+		different file system is found.
+		</para></listitem>
+		<listitem><para>
+		<command>no</command> - skip check for GPFS file system on SMB
+		share path.
+		</para></listitem>
+		</itemizedlist>
+		</listitem>
+
+		</varlistentry>
+		<varlistentry>
+
 		<term>gpfs:refuse_dacl_protected = [ yes | no ]</term>
 		<listitem>
 		<para>
-- 
2.17.0



More information about the samba-technical mailing list