From 9ab89371c8eddad2f274736b508866e2a92b74a3 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 23 May 2013 16:23:03 +0200 Subject: shadow_copy2: fix shadow_copy2_convert() in the classical case. I.e. the non-snapdirseverywhere case. This in particular fixes the case of a snapdir hierarchy that is parallel to the share or mountpoint and not subordinate. Signed-off-by: Michael Adam Reviewed-by: Andrew Bartlett --- source3/modules/vfs_shadow_copy2.c | 47 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 95249b2eac..cdab21e892 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -490,6 +490,51 @@ static char *shadow_copy2_convert(TALLOC_CTX *mem_ctx, SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config, return NULL); + DEBUG(10, ("converting '%s'\n", name)); + + if (!config->snapdirseverywhere) { + int ret; + char *snapshot_path; + + snapshot_path = shadow_copy2_snapshot_path(talloc_tos(), + handle, + timestamp); + if (snapshot_path == NULL) { + goto fail; + } + + if (config->rel_connectpath == NULL) { + converted = talloc_asprintf(mem_ctx, "%s/%s", + snapshot_path, name); + } else { + converted = talloc_asprintf(mem_ctx, "%s/%s/%s", + snapshot_path, + config->rel_connectpath, + name); + } + if (converted == NULL) { + goto fail; + } + + ZERO_STRUCT(converted_fname); + converted_fname.base_name = converted; + + ret = SMB_VFS_NEXT_LSTAT(handle, &converted_fname); + DEBUG(10, ("Trying[not snapdirseverywhere] %s: %d (%s)\n", + converted, + ret, ret == 0 ? "ok" : strerror(errno))); + if (ret == 0) { + DEBUG(10, ("Found %s\n", converted)); + result = converted; + converted = NULL; + goto fail; + } else { + errno = ENOENT; + goto fail; + } + /* never reached ... */ + } + path = talloc_asprintf(mem_ctx, "%s/%s", handle->conn->connectpath, name); if (path == NULL) { @@ -498,8 +543,6 @@ static char *shadow_copy2_convert(TALLOC_CTX *mem_ctx, } pathlen = talloc_get_size(path)-1; - DEBUG(10, ("converting %s\n", path)); - if (!shadow_copy2_find_slashes(talloc_tos(), path, &slashes, &num_slashes)) { goto fail; -- cgit