From 45b6cd3852949e74ea4a26e5d5e9c0eee97c3b27 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pavel=20Filipensk=C3=BD?= Date: Tue, 7 Apr 2026 16:28:05 +0200 Subject: [PATCH] smbdotconf: Add "automount fs types" to smb.conf MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This adds a new global parameter "automount fs types" that allows administrators to configure additional filesystem types that should trigger automounting, beyond the always-supported autofs filesystem. To enable 'samba unaware FS' automounting, add: automount fs types = 0x12345678 This allows e.g. ZFS snapshots in /.zfs/snapshot to be mounted. To find out the magic number that is not listed in /usr/include/linux/magic.h, run: stat -f -c '0x%t' /path/to/mountpoint BUG: https://bugzilla.samba.org/show_bug.cgi?id=15991 Signed-off-by: Pavel Filipenský Reviewed-by: Samuel Cabrero Autobuild-User(master): Pavel Filipensky Autobuild-Date(master): Mon Apr 20 19:57:42 UTC 2026 on atb-devel-224 --- docs-xml/smbdotconf/misc/automountfstypes.xml | 24 ++++++++++++++ source3/smbd/open.c | 31 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 docs-xml/smbdotconf/misc/automountfstypes.xml diff --git a/docs-xml/smbdotconf/misc/automountfstypes.xml b/docs-xml/smbdotconf/misc/automountfstypes.xml new file mode 100644 index 00000000000..4c5bc510520 --- /dev/null +++ b/docs-xml/smbdotconf/misc/automountfstypes.xml @@ -0,0 +1,24 @@ + + + This parameter specifies a list of additional filesystem magic numbers + that should trigger automounting when accessed. + + The values should be specified as hexadecimal numbers (with or without + 0x prefix), separated by spaces or commas. + + Note: This parameter is only available on Linux systems. + + To find the filesystem magic number for a mounted filesystem, + consult /usr/include/linux/magic.h or call: + stat -f -c '0x%t' /path/to/mountpoint + + Note: autofs (0x187) is always checked and does not need to be included + in this list. + + + +0xA0B0C0D0 0x12345678 + diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 8a52cbd6850..c8c2a520aa4 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -42,6 +42,7 @@ #include "locking/leases_db.h" #include "librpc/gen_ndr/ndr_leases_db.h" #include "lib/util/time_basic.h" +#include "lib/util/smb_strtox.h" #include "source3/smbd/dir.h" #if defined(HAVE_LINUX_MAGIC_H) @@ -877,6 +878,8 @@ static bool fsp_is_automount_mountpoint(struct files_struct *fsp, int old_fd) #if defined(HAVE_FSTATFS) && defined(HAVE_LINUX_MAGIC_H) struct statfs sbuf = {}; int ret; + const char **fs_types_list = NULL; + int i; if (!S_ISDIR(fsp->fsp_name->st.st_ex_mode)) { return false; @@ -890,6 +893,34 @@ static bool fsp_is_automount_mountpoint(struct files_struct *fsp, int old_fd) if (sbuf.f_type == AUTOFS_SUPER_MAGIC) { return true; } + + /* Check for additional filesystem types from configuration */ + fs_types_list = lp_automount_fs_types(); + if (fs_types_list == NULL) { + return false; + } + + for (i = 0; fs_types_list[i] != NULL; i++) { + unsigned long long fs_type_val; + int error = 0; + + fs_type_val = smb_strtoull(fs_types_list[i], + NULL, + 0, + &error, + SMB_STR_FULL_STR_CONV); + if (error != 0) { + DBG_WARNING( + "Invalid value in 'automount fs types': %s\n", + fs_types_list[i]); + continue; + } + + if (sbuf.f_type == fs_type_val) { + return true; + } + } + return false; #else return false; -- 2.47.3