mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
smbd: Introduce fsp_is_alternate_stream()
To me this is more descriptive than "fsp->base_fsp != NULL". If this turns out to be a performance problem, I would go and make this a static inline in smbd/proto.h. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
29f11005f5
commit
21b380ca13
@ -2290,7 +2290,7 @@ NTSTATUS adouble_open_from_base_fsp(const struct files_struct *dirfsp,
|
||||
*_ad_fsp = NULL;
|
||||
|
||||
SMB_ASSERT(base_fsp != NULL);
|
||||
SMB_ASSERT(base_fsp->base_fsp == NULL);
|
||||
SMB_ASSERT(!fsp_is_alternate_stream(base_fsp));
|
||||
|
||||
switch (type) {
|
||||
case ADOUBLE_META:
|
||||
@ -2590,7 +2590,7 @@ static struct adouble *ad_get_internal(TALLOC_CTX *ctx,
|
||||
int mode;
|
||||
|
||||
if (fsp != NULL) {
|
||||
if (fsp->base_fsp != NULL) {
|
||||
if (fsp_is_alternate_stream(fsp)) {
|
||||
smb_fname = fsp->base_fsp->fsp_name;
|
||||
} else {
|
||||
smb_fname = fsp->fsp_name;
|
||||
|
@ -286,7 +286,7 @@ static struct catia_cache *catia_validate_and_apply_cc(
|
||||
|
||||
if ((cc->fname != fsp->fsp_name->base_name)
|
||||
||
|
||||
((fsp->base_fsp != NULL) &&
|
||||
(fsp_is_alternate_stream(fsp) &&
|
||||
(cc->base_fname != fsp->base_fsp->fsp_name->base_name)))
|
||||
{
|
||||
CATIA_DEBUG_CC(10, cc, fsp);
|
||||
@ -312,7 +312,7 @@ static struct catia_cache *catia_validate_and_apply_cc(
|
||||
|
||||
if ((cc->orig_fname != fsp->fsp_name->base_name)
|
||||
||
|
||||
((fsp->base_fsp != NULL) &&
|
||||
(fsp_is_alternate_stream(fsp) &&
|
||||
(cc->orig_base_fname != fsp->base_fsp->fsp_name->base_name)))
|
||||
{
|
||||
/*
|
||||
@ -331,7 +331,7 @@ static struct catia_cache *catia_validate_and_apply_cc(
|
||||
* names from the cache and mark the cc as busy.
|
||||
*/
|
||||
fsp->fsp_name->base_name = cc->fname;
|
||||
if (fsp->base_fsp != NULL) {
|
||||
if (fsp_is_alternate_stream(fsp)) {
|
||||
fsp->base_fsp->fsp_name->base_name = cc->base_fname;
|
||||
}
|
||||
|
||||
@ -407,7 +407,7 @@ static int catia_fetch_fsp_pre_next(TALLOC_CTX *mem_ctx,
|
||||
}
|
||||
talloc_steal(mem_ctx, cc->fname);
|
||||
|
||||
if (fsp->base_fsp != NULL) {
|
||||
if (fsp_is_alternate_stream(fsp)) {
|
||||
status = catia_string_replace_allocate(
|
||||
handle->conn,
|
||||
fsp->base_fsp->fsp_name->base_name,
|
||||
@ -424,7 +424,7 @@ static int catia_fetch_fsp_pre_next(TALLOC_CTX *mem_ctx,
|
||||
cc->orig_fname = fsp->fsp_name->base_name;
|
||||
fsp->fsp_name->base_name = cc->fname;
|
||||
|
||||
if (fsp->base_fsp != NULL) {
|
||||
if (fsp_is_alternate_stream(fsp)) {
|
||||
cc->orig_base_fname = fsp->base_fsp->fsp_name->base_name;
|
||||
fsp->base_fsp->fsp_name->base_name = cc->base_fname;
|
||||
}
|
||||
@ -472,7 +472,7 @@ static void catia_fetch_fsp_post_next(struct catia_cache **_cc,
|
||||
*_cc = NULL;
|
||||
|
||||
fsp->fsp_name->base_name = cc->orig_fname;
|
||||
if (fsp->base_fsp != NULL) {
|
||||
if (fsp_is_alternate_stream(fsp)) {
|
||||
fsp->base_fsp->fsp_name->base_name = cc->orig_base_fname;
|
||||
}
|
||||
|
||||
|
@ -1473,7 +1473,7 @@ static int fruit_open_meta_netatalk(vfs_handle_struct *handle,
|
||||
* We know this is a stream open, so fsp->base_fsp must
|
||||
* already be open.
|
||||
*/
|
||||
SMB_ASSERT(fsp->base_fsp != NULL);
|
||||
SMB_ASSERT(fsp_is_alternate_stream(fsp));
|
||||
SMB_ASSERT(fsp->base_fsp->fsp_name->fsp == fsp->base_fsp);
|
||||
|
||||
ad = ad_get(talloc_tos(), handle, fsp->base_fsp->fsp_name, ADOUBLE_META);
|
||||
@ -1963,7 +1963,7 @@ static int fruit_unlink_meta_netatalk(vfs_handle_struct *handle,
|
||||
const struct smb_filename *smb_fname)
|
||||
{
|
||||
SMB_ASSERT(smb_fname->fsp != NULL);
|
||||
SMB_ASSERT(smb_fname->fsp->base_fsp != NULL);
|
||||
SMB_ASSERT(fsp_is_alternate_stream(smb_fname->fsp));
|
||||
return SMB_VFS_FREMOVEXATTR(smb_fname->fsp->base_fsp,
|
||||
AFPINFO_EA_NETATALK);
|
||||
}
|
||||
|
@ -1382,7 +1382,7 @@ static int shadow_copy2_fstat(vfs_handle_struct *handle, files_struct *fsp,
|
||||
orig_smb_fname = fsp->fsp_name;
|
||||
fsp->fsp_name = &vss_smb_fname;
|
||||
|
||||
if (fsp->base_fsp != NULL) {
|
||||
if (fsp_is_alternate_stream(fsp)) {
|
||||
vss_base_smb_fname = *fsp->base_fsp->fsp_name;
|
||||
vss_base_smb_fname.base_name = vss_smb_fname.base_name;
|
||||
orig_base_smb_fname = fsp->base_fsp->fsp_name;
|
||||
@ -1407,7 +1407,7 @@ static int shadow_copy2_fstat(vfs_handle_struct *handle, files_struct *fsp,
|
||||
|
||||
out:
|
||||
fsp->fsp_name = orig_smb_fname;
|
||||
if (fsp->base_fsp != NULL) {
|
||||
if (fsp_is_alternate_stream(fsp)) {
|
||||
fsp->base_fsp->fsp_name = orig_base_smb_fname;
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp,
|
||||
struct stream_io *io = (struct stream_io *)
|
||||
VFS_FETCH_FSP_EXTENSION(handle, fsp);
|
||||
|
||||
if (io == NULL || fsp->base_fsp == NULL) {
|
||||
if (io == NULL || !fsp_is_alternate_stream(fsp)) {
|
||||
return SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
|
||||
}
|
||||
|
||||
@ -498,7 +498,7 @@ static int streams_xattr_unlink_internal(vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
SMB_ASSERT(smb_fname->fsp != NULL);
|
||||
SMB_ASSERT(smb_fname->fsp->base_fsp != NULL);
|
||||
SMB_ASSERT(fsp_is_alternate_stream(smb_fname->fsp));
|
||||
|
||||
ret = SMB_VFS_FREMOVEXATTR(smb_fname->fsp->base_fsp, xattr_name);
|
||||
|
||||
|
@ -171,8 +171,7 @@ NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
|
||||
return NT_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (fsp->base_fsp != NULL) {
|
||||
/* No AIO on streams yet */
|
||||
if (fsp_is_alternate_stream(fsp)) {
|
||||
DEBUG(10, ("AIO on streams not yet supported\n"));
|
||||
return NT_STATUS_RETRY;
|
||||
}
|
||||
@ -443,8 +442,7 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
|
||||
size_t min_aio_write_size = lp_aio_write_size(SNUM(conn));
|
||||
struct tevent_req *req;
|
||||
|
||||
if (fsp->base_fsp != NULL) {
|
||||
/* No AIO on streams yet */
|
||||
if (fsp_is_alternate_stream(fsp)) {
|
||||
DEBUG(10, ("AIO on streams not yet supported\n"));
|
||||
return NT_STATUS_RETRY;
|
||||
}
|
||||
@ -693,8 +691,7 @@ NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
|
||||
return NT_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (fsp->base_fsp != NULL) {
|
||||
/* No AIO on streams yet */
|
||||
if (fsp_is_alternate_stream(fsp)) {
|
||||
DEBUG(10, ("AIO on streams not yet supported\n"));
|
||||
return NT_STATUS_RETRY;
|
||||
}
|
||||
@ -833,7 +830,7 @@ NTSTATUS schedule_aio_smb2_write(connection_struct *conn,
|
||||
size_t min_aio_write_size = lp_aio_write_size(SNUM(conn));
|
||||
struct tevent_req *req;
|
||||
|
||||
if (fsp->base_fsp != NULL) {
|
||||
if (fsp_is_alternate_stream(fsp)) {
|
||||
/* No AIO on streams yet */
|
||||
DEBUG(10, ("AIO on streams not yet supported\n"));
|
||||
return NT_STATUS_RETRY;
|
||||
|
@ -1520,12 +1520,12 @@ NTSTATUS close_file_smb(struct smb_request *req,
|
||||
status = close_normal_file(req, fsp, close_type);
|
||||
}
|
||||
|
||||
if (fsp->base_fsp != NULL) {
|
||||
if (fsp_is_alternate_stream(fsp)) {
|
||||
/*
|
||||
* fsp was a stream, its base_fsp can't be a stream
|
||||
* as well
|
||||
*/
|
||||
SMB_ASSERT(fsp->base_fsp->base_fsp == NULL);
|
||||
SMB_ASSERT(!fsp_is_alternate_stream(fsp->base_fsp));
|
||||
|
||||
/*
|
||||
* There's a 1:1 relationship between fsp and a base_fsp
|
||||
|
@ -368,7 +368,7 @@ static int smb_fname_fsp_destructor(struct smb_filename *smb_fname)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fsp->base_fsp != NULL) {
|
||||
if (fsp_is_alternate_stream(fsp)) {
|
||||
struct files_struct *tmp_base_fsp = fsp->base_fsp;
|
||||
|
||||
fsp_set_base_fsp(fsp, NULL);
|
||||
@ -583,7 +583,7 @@ fail:
|
||||
if (fsp == NULL) {
|
||||
return status;
|
||||
}
|
||||
if (fsp->base_fsp != NULL) {
|
||||
if (fsp_is_alternate_stream(fsp)) {
|
||||
struct files_struct *tmp_base_fsp = fsp->base_fsp;
|
||||
|
||||
fsp_set_base_fsp(fsp, NULL);
|
||||
@ -761,7 +761,7 @@ NTSTATUS parent_pathref(TALLOC_CTX *mem_ctx,
|
||||
|
||||
static bool close_file_in_loop(struct files_struct *fsp)
|
||||
{
|
||||
if (fsp->base_fsp != NULL) {
|
||||
if (fsp_is_alternate_stream(fsp)) {
|
||||
/*
|
||||
* This is a stream, it can't be a base
|
||||
*/
|
||||
@ -1601,3 +1601,8 @@ void fsp_set_base_fsp(struct files_struct *fsp, struct files_struct *base_fsp)
|
||||
fsp->base_fsp->stream_fsp = fsp;
|
||||
}
|
||||
}
|
||||
|
||||
bool fsp_is_alternate_stream(const struct files_struct *fsp)
|
||||
{
|
||||
return (fsp->base_fsp != NULL);
|
||||
}
|
||||
|
@ -5802,7 +5802,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (fsp->base_fsp != NULL) {
|
||||
if (fsp_is_alternate_stream(fsp)) {
|
||||
struct files_struct *tmp_base_fsp = fsp->base_fsp;
|
||||
|
||||
fsp_set_base_fsp(fsp, NULL);
|
||||
@ -5988,8 +5988,9 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
|
||||
fsp->initial_allocation_size = 0;
|
||||
}
|
||||
|
||||
if ((info == FILE_WAS_CREATED) && lp_nt_acl_support(SNUM(conn)) &&
|
||||
fsp->base_fsp == NULL) {
|
||||
if ((info == FILE_WAS_CREATED) &&
|
||||
lp_nt_acl_support(SNUM(conn)) &&
|
||||
!fsp_is_alternate_stream(fsp)) {
|
||||
if (sd != NULL) {
|
||||
/*
|
||||
* According to the MS documentation, the only time the security
|
||||
|
@ -436,6 +436,7 @@ NTSTATUS fsp_set_smb_fname(struct files_struct *fsp,
|
||||
const struct smb_filename *smb_fname_in);
|
||||
size_t fsp_fullbasepath(struct files_struct *fsp, char *buf, size_t buflen);
|
||||
void fsp_set_base_fsp(struct files_struct *fsp, struct files_struct *base_fsp);
|
||||
bool fsp_is_alternate_stream(const struct files_struct *fsp);
|
||||
|
||||
NTSTATUS create_internal_fsp(connection_struct *conn,
|
||||
const struct smb_filename *smb_fname,
|
||||
|
@ -3480,8 +3480,10 @@ static void send_file_readbraw(connection_struct *conn,
|
||||
* reply_readbraw has already checked the length.
|
||||
*/
|
||||
|
||||
if ( !req_is_in_chain(req) && (nread > 0) && (fsp->base_fsp == NULL) &&
|
||||
lp_use_sendfile(SNUM(conn), xconn->smb1.signing_state) ) {
|
||||
if ( !req_is_in_chain(req) &&
|
||||
(nread > 0) &&
|
||||
!fsp_is_alternate_stream(fsp) &&
|
||||
lp_use_sendfile(SNUM(conn), xconn->smb1.signing_state) ) {
|
||||
ssize_t sendfile_read = -1;
|
||||
char header[4];
|
||||
DATA_BLOB header_blob;
|
||||
@ -4065,7 +4067,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
|
||||
|
||||
if (!req_is_in_chain(req) &&
|
||||
!req->encrypted &&
|
||||
(fsp->base_fsp == NULL) &&
|
||||
!fsp_is_alternate_stream(fsp) &&
|
||||
lp_use_sendfile(SNUM(conn), xconn->smb1.signing_state) ) {
|
||||
uint8_t headerbuf[smb_size + 12 * 2 + 1 /* padding byte */];
|
||||
DATA_BLOB header;
|
||||
@ -5062,7 +5064,7 @@ bool is_valid_writeX_buffer(struct smbXsrv_connection *xconn,
|
||||
DEBUG(10,("is_valid_writeX_buffer: printing tid\n"));
|
||||
return false;
|
||||
}
|
||||
if (fsp->base_fsp != NULL) {
|
||||
if (fsp_is_alternate_stream(fsp)) {
|
||||
DEBUG(10,("is_valid_writeX_buffer: stream fsp\n"));
|
||||
return false;
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ static NTSTATUS schedule_smb2_sendfile_read(struct smbd_smb2_request *smb2req,
|
||||
smb2req->do_signing ||
|
||||
smb2req->do_encryption ||
|
||||
smbd_smb2_is_compound(smb2req) ||
|
||||
(fsp->base_fsp != NULL) ||
|
||||
fsp_is_alternate_stream(fsp) ||
|
||||
(!S_ISREG(fsp->fsp_name->st.st_ex_mode)) ||
|
||||
(state->in_offset >= fsp->fsp_name->st.st_ex_size) ||
|
||||
(fsp->fsp_name->st.st_ex_size < state->in_offset + state->in_length))
|
||||
|
@ -4461,7 +4461,7 @@ static bool is_smb2_recvfile_write(struct smbd_smb2_request_read_state *state)
|
||||
if (IS_PRINT(fsp->conn)) {
|
||||
return false;
|
||||
}
|
||||
if (fsp->base_fsp != NULL) {
|
||||
if (fsp_is_alternate_stream(fsp)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -755,7 +755,7 @@ int vfs_fill_sparse(files_struct *fsp, off_t len)
|
||||
num_to_write = len - fsp->fsp_name->st.st_ex_size;
|
||||
|
||||
/* Only do this on non-stream file handles. */
|
||||
if (fsp->base_fsp == NULL) {
|
||||
if (!fsp_is_alternate_stream(fsp)) {
|
||||
/* for allocation try fallocate first. This can fail on some
|
||||
* platforms e.g. when the filesystem doesn't support it and no
|
||||
* emulation is being done by the libc (like on AIX with JFS1). In that
|
||||
|
Loading…
x
Reference in New Issue
Block a user