1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

VFS: NULL dirfsp for openat on stream opens

The main optimization is to avoid non_widelink_open() for streams
opens based on the fact that all streams opens are relative to
fsp->base_fsp, which is a pathref fsp already.

Neither streams_xattr nor streams_depot referenced dirfsp for the
streams case. Make this more obvious in the callers by passing NULL
and asserting this: non-streams opens and streams opens are just
different things, streams-opens can and do reference a base fsp and
don't need the non_widelink_open logic.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Volker Lendecke 2022-06-14 16:33:57 +02:00 committed by Ralph Boehme
parent 0c8d55ed89
commit c267c9839e
6 changed files with 35 additions and 2 deletions

View File

@ -2666,7 +2666,7 @@ static ssize_t fruit_pwrite_meta_stream(vfs_handle_struct *handle,
}
fd = SMB_VFS_NEXT_OPENAT(handle,
fsp->conn->cwd_fsp,
NULL, /* opening a stream */
fsp->fsp_name,
fsp,
fio->flags,

View File

@ -684,6 +684,7 @@ static int streams_depot_openat(struct vfs_handle_struct *handle,
}
SMB_ASSERT(fsp_is_alternate_stream(fsp));
SMB_ASSERT(dirfsp == NULL);
SMB_ASSERT(VALID_STAT(fsp->base_fsp->fsp_name->st));
create_it = (mode & O_CREAT);

View File

@ -344,6 +344,7 @@ static int streams_xattr_openat(struct vfs_handle_struct *handle,
}
SMB_ASSERT(fsp_is_alternate_stream(fsp));
SMB_ASSERT(dirfsp == NULL);
status = streams_xattr_get_name(handle, talloc_tos(),
smb_fname->stream_name, &xattr_name);

View File

@ -667,7 +667,7 @@ NTSTATUS open_stream_pathref_fsp(
fd = SMB_VFS_OPENAT(
conn,
dirfsp,
NULL, /* stream open is relative to fsp->base_fsp */
smb_fname,
fsp,
O_RDONLY|O_NONBLOCK|O_NOFOLLOW,

View File

@ -937,6 +937,35 @@ NTSTATUS fd_openat(const struct files_struct *dirfsp,
flags |= O_NOFOLLOW;
}
if (fsp_is_alternate_stream(fsp)) {
int fd;
SMB_ASSERT(is_named_stream(smb_fname));
fd = SMB_VFS_OPENAT(
conn,
NULL, /* stream open is relative to fsp->base_fsp */
smb_fname,
fsp,
flags,
mode);
if (fd == -1) {
status = map_nt_error_from_unix(errno);
}
fsp_set_fd(fsp, fd);
if (fd != -1) {
status = vfs_stat_fsp(fsp);
if (!NT_STATUS_IS_OK(status)) {
DBG_DEBUG("vfs_stat_fsp failed: %s\n",
nt_errstr(status));
fd_close(fsp);
}
}
return status;
}
/*
* Only follow symlinks within a share
* definition.

View File

@ -418,6 +418,8 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
goto fail;
}
TALLOC_FREE(fspcwd);
fsp->base_fsp = base_name->fsp;
}