vfs_fruit: Add Time Machine support
authorKevin Anderson <andersonkw2@gmail.com>
Mon, 14 Nov 2016 18:14:44 +0000 (19:14 +0100)
committerRalph Boehme <slow@samba.org>
Wed, 4 Oct 2017 08:06:15 +0000 (10:06 +0200)
Add a configuration option to disable/enable Time Machine support via
the FULLSYNC AAPL flag.

Signed-off-by: Kevin Anderson <andersonkw2@gmail.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
libcli/smb/smb2_create_ctx.h
source3/modules/vfs_fruit.c

index cb194f5c536134199cec538d8b45f53259c1a1b3..0e0b713e55cf7a8dcbae5069098ba4bbefa476e4 100644 (file)
@@ -42,5 +42,6 @@
 /* "AAPL" Volume Capabilities bitmap */
 #define SMB2_CRTCTX_AAPL_SUPPORT_RESOLVE_ID 1
 #define SMB2_CRTCTX_AAPL_CASE_SENSITIVE     2
+#define SMB2_CRTCTX_AAPL_FULL_SYNC          4
 
 #endif
index 3ba59967482ba2686ae513e3256d7e2e22c7e167..5c9e680d299b4a7b8d2bfae9e549033441c2a802 100644 (file)
@@ -139,6 +139,7 @@ struct fruit_config_data {
        bool posix_rename;
        bool aapl_zero_file_id;
        const char *model;
+       bool time_machine;
 
        /*
         * Additional options, all enabled by default,
@@ -1549,6 +1550,9 @@ static int init_fruit_config(vfs_handle_struct *handle)
        config->use_aapl = lp_parm_bool(
                -1, FRUIT_PARAM_TYPE_NAME, "aapl", true);
 
+       config->time_machine = lp_parm_bool(
+               SNUM(handle->conn), FRUIT_PARAM_TYPE_NAME, "time machine", false);
+
        config->unix_info_enabled = lp_parm_bool(
                -1, FRUIT_PARAM_TYPE_NAME, "nfs_aces", true);
 
@@ -2206,6 +2210,10 @@ static NTSTATUS check_aapl(vfs_handle_struct *handle,
                        break;
                }
 
+               if (config->time_machine) {
+                       caps |= SMB2_CRTCTX_AAPL_FULL_SYNC;
+               }
+
                SBVAL(p, 0, caps);
 
                ok = data_blob_append(req, &blob, p, 8);
@@ -2637,6 +2645,19 @@ static int fruit_connect(vfs_handle_struct *handle,
                        "0x0d:0xf00d");
        }
 
+       if (config->time_machine) {
+               DBG_NOTICE("Enabling durable handles for Time Machine "
+                          "support on [%s]\n", service);
+               lp_do_parameter(SNUM(handle->conn), "durable handles", "yes");
+               lp_do_parameter(SNUM(handle->conn), "kernel oplocks", "no");
+               lp_do_parameter(SNUM(handle->conn), "kernel share modes", "no");
+               if (!lp_strict_sync(SNUM(handle->conn))) {
+                       DBG_WARNING("Time Machine without strict sync is not "
+                                   "recommended!\n");
+               }
+               lp_do_parameter(SNUM(handle->conn), "posix locking", "no");
+       }
+
        return rc;
 }