1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

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>
This commit is contained in:
Jeremy Allison 2021-07-19 14:52:32 -07:00
parent 5fdf4219c6
commit 1e3232006d

View File

@ -129,6 +129,39 @@ static bool mark_file_valid(vfs_handle_struct *handle,
return true; 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 * Given an smb_filename, determine the stream directory using the file's
* base_name. * base_name.
@ -137,14 +170,12 @@ static char *stream_dir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname, const struct smb_filename *smb_fname,
const SMB_STRUCT_STAT *base_sbuf, bool create_it) const SMB_STRUCT_STAT *base_sbuf, bool create_it)
{ {
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
uint32_t hash; uint32_t hash;
struct smb_filename *smb_fname_hash = NULL; struct smb_filename *smb_fname_hash = NULL;
char *result = NULL; char *result = NULL;
SMB_STRUCT_STAT base_sbuf_tmp; SMB_STRUCT_STAT base_sbuf_tmp;
char *tmp = NULL;
uint8_t first, second; uint8_t first, second;
char *tmp;
char *id_hex; char *id_hex;
struct file_id id; struct file_id id;
uint8_t id_buf[16]; 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), check_valid = lp_parm_bool(SNUM(handle->conn),
"streams_depot", "check_valid", true); "streams_depot", "check_valid", true);
tmp = talloc_asprintf(talloc_tos(), "%s/.streams", rootdir = stream_rootdir(handle,
handle->conn->connectpath); talloc_tos());
if (tmp == NULL) {
errno = ENOMEM;
goto fail;
}
rootdir = lp_parm_substituted_string(talloc_tos(), lp_sub,
SNUM(handle->conn), "streams_depot", "directory",
tmp);
if (rootdir == NULL) { if (rootdir == NULL) {
errno = ENOMEM; errno = ENOMEM;
goto fail; goto fail;