[PATCH] vfs_fileid: fix fsname_norootdir algorithm

Ralph Wuerthner ralphw at de.ibm.com
Tue Jan 15 10:50:57 UTC 2019


Hi list!

Please see attached patchset to fix the fsname_norootdir algorithm in 
the VFS fileid module. I already opened Samba bugzilla 13744 because 
this is broken since Samba 4.8.

--

Regards

Ralph
-------------- next part --------------
From fcf3ba42e0fc95db6239bd8adb293b59a5611927 Mon Sep 17 00:00:00 2001
From: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
Date: Tue, 15 Jan 2019 09:55:50 +0100
Subject: [PATCH 1/2] vfs_fileid: fix fsname_norootdir algorithm

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13744

Signed-off-by: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
---
 source3/modules/vfs_fileid.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/source3/modules/vfs_fileid.c b/source3/modules/vfs_fileid.c
index cb77a2e..cd6f9c3 100644
--- a/source3/modules/vfs_fileid.c
+++ b/source3/modules/vfs_fileid.c
@@ -456,7 +456,8 @@ static struct file_id fileid_file_id_create(struct vfs_handle_struct *handle,
 				struct fileid_handle_data,
 				return id);
 
-	if ((data->nolockinode != 0) && (id.inode == data->nolockinode)) {
+	if ((data->nolockinode != 0) &&
+	    (sbuf->st_ex_ino == data->nolockinode)) {
 		devid = fileid_device_mapping_hostname(data, sbuf);
 	} else {
 		devid = data->device_mapping_fn(data, sbuf);
-- 
2.7.4


From de40b66d838f5a6d74a325c10080f636c1a4dece Mon Sep 17 00:00:00 2001
From: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
Date: Tue, 15 Jan 2019 10:14:30 +0100
Subject: [PATCH 2/2] vfs_fileid: add fileid_device_mapping_fsname_norootdir
 function

Signed-off-by: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
---
 source3/modules/vfs_fileid.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/source3/modules/vfs_fileid.c b/source3/modules/vfs_fileid.c
index cd6f9c3..67de48e 100644
--- a/source3/modules/vfs_fileid.c
+++ b/source3/modules/vfs_fileid.c
@@ -280,6 +280,23 @@ static uint64_t fileid_device_mapping_fsid(struct fileid_handle_data *data,
 	return m->devid;
 }
 
+/* a device mapping using a fsname for files and hostname for share root dir */
+static uint64_t fileid_device_mapping_fsname_norootdir(
+	struct fileid_handle_data *data,
+	const SMB_STRUCT_STAT *sbuf)
+{
+	uint64_t devid;
+
+	if ((data->nolockinode != 0) &&
+	    (sbuf->st_ex_ino == data->nolockinode)) {
+		devid = fileid_device_mapping_hostname(data, sbuf);
+	} else {
+		devid = fileid_device_mapping_fsname(data, sbuf);
+	}
+
+	return devid;
+}
+
 static int get_connectpath_ino(struct vfs_handle_struct *handle,
 			       ino_t *ino)
 {
@@ -355,7 +372,8 @@ static int fileid_connect(struct vfs_handle_struct *handle,
 	} else if (strcmp("hostname", algorithm) == 0) {
 		data->device_mapping_fn = fileid_device_mapping_hostname;
 	} else if (strcmp("fsname_norootdir", algorithm) == 0) {
-		data->device_mapping_fn	= fileid_device_mapping_fsname;
+		data->device_mapping_fn	=
+			fileid_device_mapping_fsname_norootdir;
 
 		ret = get_connectpath_ino(handle, &data->nolockinode);
 		if (ret != 0) {
@@ -448,7 +466,6 @@ static struct file_id fileid_file_id_create(struct vfs_handle_struct *handle,
 {
 	struct fileid_handle_data *data;
 	struct file_id id;
-	uint64_t devid;
 
 	ZERO_STRUCT(id);
 
@@ -456,15 +473,8 @@ static struct file_id fileid_file_id_create(struct vfs_handle_struct *handle,
 				struct fileid_handle_data,
 				return id);
 
-	if ((data->nolockinode != 0) &&
-	    (sbuf->st_ex_ino == data->nolockinode)) {
-		devid = fileid_device_mapping_hostname(data, sbuf);
-	} else {
-		devid = data->device_mapping_fn(data, sbuf);
-	}
-
 	id.inode	= sbuf->st_ex_ino;
-	id.devid        = devid;
+	id.devid        = data->device_mapping_fn(data, sbuf);
 
 	DBG_DEBUG("Returning dev [%jx] inode [%jx]\n",
 		  (uintmax_t)id.devid, (uintmax_t)id.inode);
-- 
2.7.4



More information about the samba-technical mailing list