]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbdotconf: Add "automount fs types" to smb.conf master
authorPavel Filipenský <pfilipensky@samba.org>
Tue, 7 Apr 2026 14:28:05 +0000 (16:28 +0200)
committerPavel Filipensky <pfilipensky@samba.org>
Mon, 20 Apr 2026 19:57:42 +0000 (19:57 +0000)
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 <dataset root>/.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ý <pfilipensky@samba.org>
Reviewed-by: Samuel Cabrero <scabrero@samba.org>
Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Mon Apr 20 19:57:42 UTC 2026 on atb-devel-224

docs-xml/smbdotconf/misc/automountfstypes.xml [new file with mode: 0644]
source3/smbd/open.c

diff --git a/docs-xml/smbdotconf/misc/automountfstypes.xml b/docs-xml/smbdotconf/misc/automountfstypes.xml
new file mode 100644 (file)
index 0000000..4c5bc51
--- /dev/null
@@ -0,0 +1,24 @@
+<samba:parameter name="automount fs types"
+                 context="G"
+                 type="cmdlist"
+                 xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+       <para>This parameter specifies a list of additional filesystem magic numbers
+       that should trigger automounting when accessed.</para>
+
+       <para>The values should be specified as hexadecimal numbers (with or without
+       0x prefix), separated by spaces or commas.</para>
+
+       <para>Note: This parameter is only available on Linux systems.</para>
+
+       <para>To find the filesystem magic number for a mounted filesystem,
+       consult /usr/include/linux/magic.h or call:
+       <command>stat -f -c '0x%t' /path/to/mountpoint</command></para>
+
+       <para>Note: autofs (0x187) is always checked and does not need to be included
+       in this list.</para>
+</description>
+
+<value type="default"></value>
+<value type="example">0xA0B0C0D0 0x12345678</value>
+</samba:parameter>
index 8a52cbd6850ebb230b8e97690d195ec44d576292..c8c2a520aa4f59f07cc59543a4aae7de9da62d22 100644 (file)
@@ -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;