From 84333884ff34a75ceec8f966c1f7e6ad5566a4d2 Mon Sep 17 00:00:00 2001 From: Uri Simchoni Date: Tue, 3 Nov 2015 10:57:13 +0200 Subject: [PATCH] vfs_shadow_copy2: add snapsharepath parameter This new parameter defines how to get from the snapshot's root directory to the share's root directory. It is an alternative to the "basedir" parameter, but functionally is a superset of basedir. Signed-off-by: Uri Simchoni Reviewed-by: Michael Adam --- source3/modules/vfs_shadow_copy2.c | 37 +++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 27dbe519725..6e6b0871d90 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -1873,6 +1873,7 @@ static int shadow_copy2_connect(struct vfs_handle_struct *handle, const char *gmt_format; const char *sort_order; const char *basedir = NULL; + const char *snapsharepath = NULL; const char *mount_point; DEBUG(10, (__location__ ": cnum[%u], connectpath[%s]\n", @@ -2016,11 +2017,45 @@ static int shadow_copy2_connect(struct vfs_handle_struct *handle, basedir = NULL; } + snapsharepath = lp_parm_const_string(SNUM(handle->conn), "shadow", + "snapsharepath", NULL); + if (snapsharepath != NULL) { + if (snapsharepath[0] == '/') { + DBG_WARNING("Warning: 'snapsharepath' is " + "absolute ('%s'), but it has to be a " + "relative path. Disabling snapsharepath.\n", + snapsharepath); + snapsharepath = NULL; + } + if (config->snapdirseverywhere && snapsharepath != NULL) { + DBG_WARNING("Warning: 'snapsharepath' is incompatible " + "with 'snapdirseverywhere'. Disabling " + "snapsharepath.\n"); + snapsharepath = NULL; + } + } + + if (basedir != NULL && snapsharepath != NULL) { + DBG_WARNING("Warning: 'snapsharepath' is incompatible with " + "'basedir'. Disabling snapsharepath\n"); + snapsharepath = NULL; + } + + if (snapsharepath != NULL) { + config->rel_connectpath = talloc_strdup(config, snapsharepath); + if (config->rel_connectpath == NULL) { + DBG_ERR("talloc_strdup() failed\n"); + errno = ENOMEM; + return -1; + } + } + if (basedir == NULL) { basedir = config->mount_point; } - if (strlen(basedir) != strlen(handle->conn->connectpath)) { + if (config->rel_connectpath == NULL && + strlen(basedir) != strlen(handle->conn->connectpath)) { config->rel_connectpath = talloc_strdup(config, handle->conn->connectpath + strlen(basedir)); if (config->rel_connectpath == NULL) { -- 2.34.1