summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2021-07-19 14:52:32 -0700
committerJule Anger <janger@samba.org>2021-08-25 13:01:09 +0000
commit185f191bd43c9442e20b2e5f74171131f5e3fd57 (patch)
treeb68d24200e2673bfb35be4528c6ca29b18532fe0 /source3
parent6b5f770790ca8a1ef6ad89bc8db6e6f8a70fb58e (diff)
downloadsamba-185f191bd43c9442e20b2e5f74171131f5e3fd57.tar.gz
s3: VFS: vfs_streams_depot: Factor out the code that gets the absolute stream rootdir into a function.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14760 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Noel Power <noel.power@suse.com> (cherry picked from commit 1e3232006d688fa999fb8314ce948ffb45a50e71)
Diffstat (limited to 'source3')
-rw-r--r--source3/modules/vfs_streams_depot.c50
1 files changed, 36 insertions, 14 deletions
diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c
index d9abf1d71b9..d3b511d3132 100644
--- a/source3/modules/vfs_streams_depot.c
+++ b/source3/modules/vfs_streams_depot.c
@@ -129,6 +129,39 @@ static bool mark_file_valid(vfs_handle_struct *handle,
return true;
}
+/*
+ * Return the root of the stream directory. Can be
+ * external to the share definition but by default
+ * is "handle->conn->connectpath/.streams".
+ *
+ * Note that this is an *absolute* path, starting
+ * with '/', so the dirfsp being used in the
+ * calls below isn't looked at.
+ */
+
+static char *stream_rootdir(vfs_handle_struct *handle,
+ TALLOC_CTX *ctx)
+{
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
+ char *tmp;
+
+ tmp = talloc_asprintf(ctx,
+ "%s/.streams",
+ handle->conn->connectpath);
+ if (tmp == NULL) {
+ errno = ENOMEM;
+ return NULL;
+ }
+
+ return lp_parm_substituted_string(ctx,
+ lp_sub,
+ SNUM(handle->conn),
+ "streams_depot",
+ "directory",
+ tmp);
+}
+
/**
* Given an smb_filename, determine the stream directory using the file's
* base_name.
@@ -137,14 +170,12 @@ static char *stream_dir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
const SMB_STRUCT_STAT *base_sbuf, bool create_it)
{
- const struct loadparm_substitution *lp_sub =
- loadparm_s3_global_substitution();
uint32_t hash;
struct smb_filename *smb_fname_hash = NULL;
char *result = NULL;
SMB_STRUCT_STAT base_sbuf_tmp;
+ char *tmp = NULL;
uint8_t first, second;
- char *tmp;
char *id_hex;
struct file_id id;
uint8_t id_buf[16];
@@ -159,17 +190,8 @@ static char *stream_dir(vfs_handle_struct *handle,
check_valid = lp_parm_bool(SNUM(handle->conn),
"streams_depot", "check_valid", true);
- tmp = talloc_asprintf(talloc_tos(), "%s/.streams",
- handle->conn->connectpath);
-
- if (tmp == NULL) {
- errno = ENOMEM;
- goto fail;
- }
-
- rootdir = lp_parm_substituted_string(talloc_tos(), lp_sub,
- SNUM(handle->conn), "streams_depot", "directory",
- tmp);
+ rootdir = stream_rootdir(handle,
+ talloc_tos());
if (rootdir == NULL) {
errno = ENOMEM;
goto fail;