1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

s3: smbd: Change open_streams_for_delete() to take a struct smb_filename *.

Prepare for changing vfs_streaminfo to do the same.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Mon Mar  7 21:12:56 CET 2016 on sn-devel-144
This commit is contained in:
Jeremy Allison 2016-03-04 14:16:13 -08:00 committed by Ralph Boehme
parent f67d11676f
commit f4b4872982
20 changed files with 128 additions and 96 deletions

View File

@ -579,7 +579,7 @@ static NTSTATUS skel_set_compression(struct vfs_handle_struct *handle,
static NTSTATUS skel_streaminfo(struct vfs_handle_struct *handle,
struct files_struct *fsp,
const char *fname,
const struct smb_filename *smb_fname,
TALLOC_CTX *mem_ctx,
unsigned int *num_streams,
struct stream_struct **streams)

View File

@ -699,14 +699,17 @@ static NTSTATUS skel_set_compression(struct vfs_handle_struct *handle,
static NTSTATUS skel_streaminfo(struct vfs_handle_struct *handle,
struct files_struct *fsp,
const char *fname,
const struct smb_filename *smb_fname,
TALLOC_CTX *mem_ctx,
unsigned int *num_streams,
struct stream_struct **streams)
{
return SMB_VFS_NEXT_STREAMINFO(handle,
fsp,
fname, mem_ctx, num_streams, streams);
fsp,
smb_fname,
mem_ctx,
num_streams,
streams);
}
static int skel_get_real_filename(struct vfs_handle_struct *handle,

View File

@ -188,6 +188,8 @@
const struct smb_filename * */
/* Version 35 - Change lchown from const char *, to
const struct smb_filename * */
/* Version 35 - Change streaminfo from const char *, to
const struct smb_filename * */
#define SMB_VFS_INTERFACE_VERSION 35
@ -721,7 +723,7 @@ struct vfs_fn_pointers {
NTSTATUS (*streaminfo_fn)(struct vfs_handle_struct *handle,
struct files_struct *fsp,
const char *fname,
const struct smb_filename *smb_fname,
TALLOC_CTX *mem_ctx,
unsigned int *num_streams,
struct stream_struct **streams);
@ -1153,7 +1155,7 @@ struct file_id smb_vfs_call_file_id_create(struct vfs_handle_struct *handle,
const SMB_STRUCT_STAT *sbuf);
NTSTATUS smb_vfs_call_streaminfo(struct vfs_handle_struct *handle,
struct files_struct *fsp,
const char *fname,
const struct smb_filename *smb_fname,
TALLOC_CTX *mem_ctx,
unsigned int *num_streams,
struct stream_struct **streams);

View File

@ -346,10 +346,10 @@
#define SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf) \
smb_vfs_call_file_id_create((handle)->next, (sbuf))
#define SMB_VFS_STREAMINFO(conn, fsp, fname, mem_ctx, num_streams, streams) \
smb_vfs_call_streaminfo((conn)->vfs_handles, (fsp), (fname), (mem_ctx), (num_streams), (streams))
#define SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx, num_streams, streams) \
smb_vfs_call_streaminfo((handle)->next, (fsp), (fname), (mem_ctx), (num_streams), (streams))
#define SMB_VFS_STREAMINFO(conn, fsp, smb_fname, mem_ctx, num_streams, streams) \
smb_vfs_call_streaminfo((conn)->vfs_handles, (fsp), (smb_fname), (mem_ctx), (num_streams), (streams))
#define SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname, mem_ctx, num_streams, streams) \
smb_vfs_call_streaminfo((handle)->next, (fsp), (smb_fname), (mem_ctx), (num_streams), (streams))
#define SMB_VFS_GET_REAL_FILENAME(conn, path, name, mem_ctx, found_name) \
smb_vfs_call_get_real_filename((conn)->vfs_handles, (path), (name), (mem_ctx), (found_name))

View File

@ -792,7 +792,7 @@ static int catia_chflags(struct vfs_handle_struct *handle,
static NTSTATUS
catia_streaminfo(struct vfs_handle_struct *handle,
struct files_struct *fsp,
const char *path,
const struct smb_filename *smb_fname,
TALLOC_CTX *mem_ctx,
unsigned int *_num_streams,
struct stream_struct **_streams)
@ -800,22 +800,35 @@ catia_streaminfo(struct vfs_handle_struct *handle,
char *mapped_name = NULL;
NTSTATUS status;
int i;
struct smb_filename *catia_smb_fname = NULL;
unsigned int num_streams = 0;
struct stream_struct *streams = NULL;
*_num_streams = 0;
*_streams = NULL;
status = catia_string_replace_allocate(handle->conn, path,
&mapped_name, vfs_translate_to_unix);
status = catia_string_replace_allocate(handle->conn,
smb_fname->base_name,
&mapped_name,
vfs_translate_to_unix);
if (!NT_STATUS_IS_OK(status)) {
errno = map_errno_from_nt_status(status);
return status;
}
status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, mapped_name,
catia_smb_fname = synthetic_smb_fname(talloc_tos(),
mapped_name,
NULL,
NULL);
if (catia_smb_fname == NULL) {
TALLOC_FREE(mapped_name);
return NT_STATUS_NO_MEMORY;
}
status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, catia_smb_fname,
mem_ctx, &num_streams, &streams);
TALLOC_FREE(mapped_name);
TALLOC_FREE(catia_smb_fname);
if (!NT_STATUS_IS_OK(status)) {
return status;
}

View File

@ -2186,7 +2186,7 @@ static struct file_id vfswrap_file_id_create(struct vfs_handle_struct *handle,
static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle,
struct files_struct *fsp,
const char *fname,
const struct smb_filename *smb_fname,
TALLOC_CTX *mem_ctx,
unsigned int *pnum_streams,
struct stream_struct **pstreams)
@ -2206,17 +2206,18 @@ static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle,
ret = SMB_VFS_FSTAT(fsp, &sbuf);
}
else {
struct smb_filename smb_fname;
struct smb_filename smb_fname_cp;
ZERO_STRUCT(smb_fname);
smb_fname.base_name = discard_const_p(char, fname);
ZERO_STRUCT(smb_fname_cp);
smb_fname_cp.base_name = discard_const_p(char,
smb_fname->base_name);
if (lp_posix_pathnames()) {
ret = SMB_VFS_LSTAT(handle->conn, &smb_fname);
ret = SMB_VFS_LSTAT(handle->conn, &smb_fname_cp);
} else {
ret = SMB_VFS_STAT(handle->conn, &smb_fname);
ret = SMB_VFS_STAT(handle->conn, &smb_fname_cp);
}
sbuf = smb_fname.st;
sbuf = smb_fname_cp.st;
}
if (ret == -1) {

View File

@ -3168,24 +3168,18 @@ exit:
static NTSTATUS fruit_streaminfo(vfs_handle_struct *handle,
struct files_struct *fsp,
const char *fname,
const struct smb_filename *smb_fname,
TALLOC_CTX *mem_ctx,
unsigned int *pnum_streams,
struct stream_struct **pstreams)
{
struct fruit_config_data *config = NULL;
struct smb_filename *smb_fname = NULL;
struct adouble *ad = NULL;
NTSTATUS status;
SMB_VFS_HANDLE_GET_DATA(handle, config, struct fruit_config_data,
return NT_STATUS_UNSUCCESSFUL);
DEBUG(10, ("fruit_streaminfo called for %s\n", fname));
smb_fname = synthetic_smb_fname(talloc_tos(), fname, NULL, NULL);
if (smb_fname == NULL) {
return NT_STATUS_NO_MEMORY;
}
DEBUG(10, ("fruit_streaminfo called for %s\n", smb_fname->base_name));
if (config->meta == FRUIT_META_NETATALK) {
ad = ad_get(talloc_tos(), handle,
@ -3197,7 +3191,6 @@ static NTSTATUS fruit_streaminfo(vfs_handle_struct *handle,
smb_roundup(handle->conn,
AFP_INFO_SIZE))) {
TALLOC_FREE(ad);
TALLOC_FREE(smb_fname);
return NT_STATUS_NO_MEMORY;
}
}
@ -3216,16 +3209,13 @@ static NTSTATUS fruit_streaminfo(vfs_handle_struct *handle,
ad_getentrylen(
ad, ADEID_RFORK)))) {
TALLOC_FREE(ad);
TALLOC_FREE(smb_fname);
return NT_STATUS_NO_MEMORY;
}
}
TALLOC_FREE(ad);
}
TALLOC_FREE(smb_fname);
status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname, mem_ctx,
pnum_streams, pstreams);
if (!NT_STATUS_IS_OK(status)) {
return status;
@ -3236,7 +3226,6 @@ static NTSTATUS fruit_streaminfo(vfs_handle_struct *handle,
if (!del_fruit_stream(mem_ctx, pnum_streams, pstreams,
":" NETATALK_META_XATTR ":$DATA")) {
TALLOC_FREE(ad);
TALLOC_FREE(smb_fname);
return NT_STATUS_NO_MEMORY;
}
}
@ -3792,7 +3781,7 @@ static void fruit_copy_chunk_done(struct tevent_req *subreq)
* because streams are few and small.
*/
status = vfs_streaminfo(state->handle->conn, state->src_fsp,
state->src_fsp->fsp_name->base_name,
state->src_fsp->fsp_name,
req, &num_streams, &streams);
if (tevent_req_nterror(req, status)) {
return;

View File

@ -1674,18 +1674,18 @@ static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *ha
static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
struct files_struct *fsp,
const char *fname,
const struct smb_filename *smb_fname,
TALLOC_CTX *mem_ctx,
unsigned int *pnum_streams,
struct stream_struct **pstreams)
{
NTSTATUS result;
result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname, mem_ctx,
pnum_streams, pstreams);
do_log(SMB_VFS_OP_STREAMINFO, NT_STATUS_IS_OK(result), handle,
"%s", fname);
"%s", smb_fname->base_name);
return result;
}

View File

@ -1962,43 +1962,42 @@ out:
*/
static NTSTATUS mh_streaminfo(struct vfs_handle_struct *handle,
struct files_struct *fsp,
const char *fname,
const struct smb_filename *smb_fname,
TALLOC_CTX *ctx,
unsigned int *num_streams,
struct stream_struct **streams)
{
NTSTATUS status;
char *clientPath;
TALLOC_CTX *mem_ctx;
int ret;
struct smb_filename *clientFname = NULL;
DEBUG(MH_INFO_DEBUG, ("Entering mh_streaminfo\n"));
if (!is_in_media_files(fname))
{
status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname,
ctx, num_streams, streams);
if (!is_in_media_files(smb_fname->base_name)) {
status = SMB_VFS_NEXT_STREAMINFO(handle,
fsp,
smb_fname,
ctx,
num_streams,
streams);
goto out;
}
clientPath = NULL;
mem_ctx = talloc_tos();
if (alloc_get_client_path(handle, mem_ctx,
fname,
&clientPath))
{
status = map_nt_error_from_unix(errno);
ret = alloc_get_client_smb_fname(handle,
talloc_tos(),
smb_fname,
&clientFname);
if (ret != 0) {
status = NT_STATUS_NO_MEMORY;
goto err;
}
/* This only works on files, so we don't have to worry about
* our fake directory stat'ing here.
*/
// But what does this function do, exactly? Does it need
// extra modifications for the Avid stuff?
status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, clientPath,
status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, clientFname,
ctx, num_streams, streams);
err:
TALLOC_FREE(clientPath);
TALLOC_FREE(clientFname);
out:
return status;
}

View File

@ -911,17 +911,20 @@ static bool collect_one_stream(const char *dirname,
static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle,
struct files_struct *fsp,
const char *fname,
const struct smb_filename *smb_fname,
TALLOC_CTX *mem_ctx,
unsigned int *pnum_streams,
struct stream_struct **pstreams)
{
struct smb_filename *smb_fname_base;
struct smb_filename *smb_fname_base = NULL;
int ret;
NTSTATUS status;
struct streaminfo_state state;
smb_fname_base = synthetic_smb_fname(talloc_tos(), fname, NULL, NULL);
smb_fname_base = synthetic_smb_fname(talloc_tos(),
smb_fname->base_name,
NULL,
NULL);
if (smb_fname_base == NULL) {
return NT_STATUS_NO_MEMORY;
}
@ -975,7 +978,12 @@ static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle,
*pnum_streams = state.num_streams;
*pstreams = state.streams;
status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx, pnum_streams, pstreams);
status = SMB_VFS_NEXT_STREAMINFO(handle,
fsp,
smb_fname_base,
mem_ctx,
pnum_streams,
pstreams);
out:
TALLOC_FREE(smb_fname_base);

View File

@ -811,7 +811,7 @@ static bool collect_one_stream(struct ea_struct *ea, void *private_data)
static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle,
struct files_struct *fsp,
const char *fname,
const struct smb_filename *smb_fname,
TALLOC_CTX *mem_ctx,
unsigned int *pnum_streams,
struct stream_struct **pstreams)
@ -825,19 +825,21 @@ static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle,
ret = SMB_VFS_FSTAT(fsp, &sbuf);
}
else {
struct smb_filename *smb_fname = NULL;
smb_fname = synthetic_smb_fname(talloc_tos(), fname, NULL,
NULL);
if (smb_fname == NULL) {
struct smb_filename *smb_fname_base = NULL;
smb_fname_base = synthetic_smb_fname(talloc_tos(),
smb_fname->base_name,
NULL,
NULL);
if (smb_fname_base == NULL) {
return NT_STATUS_NO_MEMORY;
}
if (lp_posix_pathnames()) {
ret = SMB_VFS_LSTAT(handle->conn, smb_fname);
ret = SMB_VFS_LSTAT(handle->conn, smb_fname_base);
} else {
ret = SMB_VFS_STAT(handle->conn, smb_fname);
ret = SMB_VFS_STAT(handle->conn, smb_fname_base);
}
sbuf = smb_fname->st;
TALLOC_FREE(smb_fname);
sbuf = smb_fname_base->st;
TALLOC_FREE(smb_fname_base);
}
if (ret == -1) {
@ -860,7 +862,7 @@ static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle,
*/
status = NT_STATUS_OK;
} else {
status = walk_xattr_streams(handle, fsp, fname,
status = walk_xattr_streams(handle, fsp, smb_fname->base_name,
collect_one_stream, &state);
}
@ -877,7 +879,12 @@ static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle,
*pnum_streams = state.num_streams;
*pstreams = state.streams;
return SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx, pnum_streams, pstreams);
return SMB_VFS_NEXT_STREAMINFO(handle,
fsp,
smb_fname,
mem_ctx,
pnum_streams,
pstreams);
}
static uint32_t streams_xattr_fs_capabilities(struct vfs_handle_struct *handle,

View File

@ -1533,7 +1533,7 @@ static struct file_id smb_time_audit_file_id_create(struct vfs_handle_struct *ha
static NTSTATUS smb_time_audit_streaminfo(vfs_handle_struct *handle,
struct files_struct *fsp,
const char *fname,
const struct smb_filename *smb_fname,
TALLOC_CTX *mem_ctx,
unsigned int *pnum_streams,
struct stream_struct **pstreams)
@ -1543,7 +1543,7 @@ static NTSTATUS smb_time_audit_streaminfo(vfs_handle_struct *handle,
double timediff;
clock_gettime_mono(&ts1);
result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname, mem_ctx,
pnum_streams, pstreams);
clock_gettime_mono(&ts2);
timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;

View File

@ -1489,26 +1489,27 @@ err:
static NTSTATUS um_streaminfo(struct vfs_handle_struct *handle,
struct files_struct *fsp,
const char *fname,
const struct smb_filename *smb_fname,
TALLOC_CTX *ctx,
unsigned int *num_streams,
struct stream_struct **streams)
{
NTSTATUS status;
char *client_path = NULL;
int ret;
struct smb_filename *client_fname = NULL;
DEBUG(10, ("Entering um_streaminfo\n"));
if (!is_in_media_files(fname)) {
return SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname,
if (!is_in_media_files(smb_fname->base_name)) {
return SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname,
ctx, num_streams, streams);
}
ret = alloc_get_client_path(handle, talloc_tos(),
fname, &client_path);
ret = alloc_get_client_smb_fname(handle,
talloc_tos(),
smb_fname,
&client_fname);
if (ret != 0) {
status = map_nt_error_from_unix(errno);
goto err;
}
@ -1518,10 +1519,10 @@ static NTSTATUS um_streaminfo(struct vfs_handle_struct *handle,
* function do, exactly? Does it need extra modifications for
* the Avid stuff?
*/
status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, client_path,
status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, client_fname,
ctx, num_streams, streams);
err:
TALLOC_FREE(client_path);
TALLOC_FREE(client_fname);
return status;
}

View File

@ -170,7 +170,7 @@ NTSTATUS delete_all_streams(connection_struct *conn,
TALLOC_CTX *frame = talloc_stackframe();
NTSTATUS status;
status = vfs_streaminfo(conn, NULL, smb_fname->base_name, talloc_tos(),
status = vfs_streaminfo(conn, NULL, smb_fname, talloc_tos(),
&num_streams, &stream_info);
if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)) {

View File

@ -1315,7 +1315,7 @@ static NTSTATUS build_stream_path(TALLOC_CTX *mem_ctx,
}
/* Fall back to a case-insensitive scan of all streams on the file. */
status = vfs_streaminfo(conn, NULL, smb_fname->base_name, mem_ctx,
status = vfs_streaminfo(conn, NULL, smb_fname, mem_ctx,
&num_streams, &streams);
if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {

View File

@ -698,7 +698,7 @@ void reply_ntcreate_and_X(struct smb_request *req)
if (NT_STATUS_IS_OK(status) && num_names) {
file_status &= ~NO_EAS;
}
status = vfs_streaminfo(conn, NULL, smb_fname->base_name, ctx,
status = vfs_streaminfo(conn, NULL, smb_fname, ctx,
&num_streams, &streams);
/* There is always one stream, ::$DATA. */
if (NT_STATUS_IS_OK(status) && num_streams > 1) {
@ -1337,7 +1337,7 @@ static void call_nt_transact_create(connection_struct *conn,
if (NT_STATUS_IS_OK(status) && num_names) {
file_status &= ~NO_EAS;
}
status = vfs_streaminfo(conn, NULL, smb_fname->base_name, ctx,
status = vfs_streaminfo(conn, NULL, smb_fname, ctx,
&num_streams, &streams);
/* There is always one stream, ::$DATA. */
if (NT_STATUS_IS_OK(status) && num_streams > 1) {

View File

@ -3859,7 +3859,7 @@ static NTSTATUS open_streams_for_delete(connection_struct *conn,
TALLOC_CTX *frame = talloc_stackframe();
NTSTATUS status;
status = vfs_streaminfo(conn, NULL, smb_fname->base_name, talloc_tos(),
status = vfs_streaminfo(conn, NULL, smb_fname, talloc_tos(),
&num_streams, &stream_info);
if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)

View File

@ -1215,7 +1215,7 @@ NTSTATUS vfs_stat_fsp(files_struct *fsp);
NTSTATUS vfs_chown_fsp(files_struct *fsp, uid_t uid, gid_t gid);
NTSTATUS vfs_streaminfo(connection_struct *conn,
struct files_struct *fsp,
const char *fname,
const struct smb_filename *smb_fname,
TALLOC_CTX *mem_ctx,
unsigned int *num_streams,
struct stream_struct **streams);

View File

@ -5180,8 +5180,12 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
return NT_STATUS_INVALID_PARAMETER;
}
status = vfs_streaminfo(conn, fsp, smb_fname->base_name,
talloc_tos(), &num_streams, &streams);
status = vfs_streaminfo(conn,
fsp,
smb_fname,
talloc_tos(),
&num_streams,
&streams);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("could not get stream info: %s\n",

View File

@ -1365,14 +1365,19 @@ NTSTATUS vfs_stat_fsp(files_struct *fsp)
*/
NTSTATUS vfs_streaminfo(connection_struct *conn,
struct files_struct *fsp,
const char *fname,
const struct smb_filename *smb_fname,
TALLOC_CTX *mem_ctx,
unsigned int *num_streams,
struct stream_struct **streams)
{
*num_streams = 0;
*streams = NULL;
return SMB_VFS_STREAMINFO(conn, fsp, fname, mem_ctx, num_streams, streams);
return SMB_VFS_STREAMINFO(conn,
fsp,
smb_fname,
mem_ctx,
num_streams,
streams);
}
/*
@ -2124,13 +2129,13 @@ struct file_id smb_vfs_call_file_id_create(struct vfs_handle_struct *handle,
NTSTATUS smb_vfs_call_streaminfo(struct vfs_handle_struct *handle,
struct files_struct *fsp,
const char *fname,
const struct smb_filename *smb_fname,
TALLOC_CTX *mem_ctx,
unsigned int *num_streams,
struct stream_struct **streams)
{
VFS_FIND(streaminfo);
return handle->fns->streaminfo_fn(handle, fsp, fname, mem_ctx,
return handle->fns->streaminfo_fn(handle, fsp, smb_fname, mem_ctx,
num_streams, streams);
}