mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
smbd: add need_fsa arg and logic to file_find_di_(first|next)
All callers except rename_open_files() can ignore non FSA fsps. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
24dd647c1c
commit
927c297bd6
@ -1235,8 +1235,8 @@ static int acl_common_remove_object(vfs_handle_struct *handle,
|
||||
|
||||
/* Ensure we have this file open with DELETE access. */
|
||||
id = vfs_file_id_from_sbuf(conn, &local_fname->st);
|
||||
for (fsp = file_find_di_first(conn->sconn, id); fsp;
|
||||
fsp = file_find_di_next(fsp)) {
|
||||
for (fsp = file_find_di_first(conn->sconn, id, true); fsp;
|
||||
fsp = file_find_di_next(fsp, true)) {
|
||||
if (fsp->access_mask & DELETE_ACCESS &&
|
||||
fsp->fsp_flags.delete_on_close)
|
||||
{
|
||||
|
@ -1377,9 +1377,9 @@ static NTSTATUS get_file_handle_for_metadata(connection_struct *conn,
|
||||
|
||||
file_id = vfs_file_id_from_sbuf(conn, &smb_fname->st);
|
||||
|
||||
for(fsp = file_find_di_first(conn->sconn, file_id);
|
||||
for(fsp = file_find_di_first(conn->sconn, file_id, true);
|
||||
fsp;
|
||||
fsp = file_find_di_next(fsp)) {
|
||||
fsp = file_find_di_next(fsp, true)) {
|
||||
if (fsp_get_io_fd(fsp) != -1) {
|
||||
*ret_fsp = fsp;
|
||||
return NT_STATUS_OK;
|
||||
|
@ -787,7 +787,8 @@ files_struct *file_find_dif(struct smbd_server_connection *sconn,
|
||||
****************************************************************************/
|
||||
|
||||
files_struct *file_find_di_first(struct smbd_server_connection *sconn,
|
||||
struct file_id id)
|
||||
struct file_id id,
|
||||
bool need_fsa)
|
||||
{
|
||||
files_struct *fsp;
|
||||
|
||||
@ -799,6 +800,9 @@ files_struct *file_find_di_first(struct smbd_server_connection *sconn,
|
||||
sconn->fsp_fi_cache.id = id;
|
||||
|
||||
for (fsp=sconn->files;fsp;fsp=fsp->next) {
|
||||
if (need_fsa && !fsp->fsp_flags.is_fsa) {
|
||||
continue;
|
||||
}
|
||||
if (file_id_equal(&fsp->file_id, &id)) {
|
||||
/* Setup positive cache. */
|
||||
sconn->fsp_fi_cache.fsp = fsp;
|
||||
@ -815,11 +819,15 @@ files_struct *file_find_di_first(struct smbd_server_connection *sconn,
|
||||
Find the next fsp having the same device and inode.
|
||||
****************************************************************************/
|
||||
|
||||
files_struct *file_find_di_next(files_struct *start_fsp)
|
||||
files_struct *file_find_di_next(files_struct *start_fsp,
|
||||
bool need_fsa)
|
||||
{
|
||||
files_struct *fsp;
|
||||
|
||||
for (fsp = start_fsp->next;fsp;fsp=fsp->next) {
|
||||
if (need_fsa && !fsp->fsp_flags.is_fsa) {
|
||||
continue;
|
||||
}
|
||||
if (file_id_equal(&fsp->file_id, &start_fsp->file_id)) {
|
||||
return fsp;
|
||||
}
|
||||
|
@ -2118,9 +2118,9 @@ struct fsp_lease *find_fsp_lease(struct files_struct *new_fsp,
|
||||
* handles...
|
||||
*/
|
||||
|
||||
for (fsp = file_find_di_first(new_fsp->conn->sconn, new_fsp->file_id);
|
||||
for (fsp = file_find_di_first(new_fsp->conn->sconn, new_fsp->file_id, true);
|
||||
fsp != NULL;
|
||||
fsp = file_find_di_next(fsp)) {
|
||||
fsp = file_find_di_next(fsp, true)) {
|
||||
|
||||
if (fsp == new_fsp) {
|
||||
continue;
|
||||
|
@ -419,8 +419,10 @@ files_struct *file_find_fd(struct smbd_server_connection *sconn, int fd);
|
||||
files_struct *file_find_dif(struct smbd_server_connection *sconn,
|
||||
struct file_id id, unsigned long gen_id);
|
||||
files_struct *file_find_di_first(struct smbd_server_connection *sconn,
|
||||
struct file_id id);
|
||||
files_struct *file_find_di_next(files_struct *start_fsp);
|
||||
struct file_id id,
|
||||
bool need_fsa);
|
||||
files_struct *file_find_di_next(files_struct *start_fsp,
|
||||
bool need_fsa);
|
||||
struct files_struct *file_find_one_fsp_from_lease_key(
|
||||
struct smbd_server_connection *sconn,
|
||||
const struct smb2_lease_key *lease_key);
|
||||
|
@ -7365,8 +7365,8 @@ static void rename_open_files(connection_struct *conn,
|
||||
NTSTATUS status;
|
||||
uint32_t new_name_hash = 0;
|
||||
|
||||
for(fsp = file_find_di_first(conn->sconn, id); fsp;
|
||||
fsp = file_find_di_next(fsp)) {
|
||||
for(fsp = file_find_di_first(conn->sconn, id, false); fsp;
|
||||
fsp = file_find_di_next(fsp, false)) {
|
||||
struct file_id_buf idbuf;
|
||||
/* fsp_name is a relative path under the fsp. To change this for other
|
||||
sharepaths we need to manipulate relative paths. */
|
||||
@ -7519,8 +7519,8 @@ static NTSTATUS parent_dirname_compatible_open(connection_struct *conn,
|
||||
*/
|
||||
|
||||
id = vfs_file_id_from_sbuf(conn, &smb_fname_parent->st);
|
||||
for (fsp = file_find_di_first(conn->sconn, id); fsp;
|
||||
fsp = file_find_di_next(fsp)) {
|
||||
for (fsp = file_find_di_first(conn->sconn, id, true); fsp;
|
||||
fsp = file_find_di_next(fsp, true)) {
|
||||
if (fsp->access_mask & DELETE_ACCESS) {
|
||||
return NT_STATUS_SHARING_VIOLATION;
|
||||
}
|
||||
@ -7718,7 +7718,7 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
|
||||
struct file_id fileid = vfs_file_id_from_sbuf(conn,
|
||||
&smb_fname_dst->st);
|
||||
files_struct *dst_fsp = file_find_di_first(conn->sconn,
|
||||
fileid);
|
||||
fileid, true);
|
||||
/* The file can be open when renaming a stream */
|
||||
if (dst_fsp && !new_is_stream) {
|
||||
DEBUG(3, ("rename_internals_fsp: Target file open\n"));
|
||||
|
@ -49,9 +49,9 @@ struct files_struct *fcb_or_dos_open(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(fsp = file_find_di_first(conn->sconn, id);
|
||||
for(fsp = file_find_di_first(conn->sconn, id, true);
|
||||
fsp != NULL;
|
||||
fsp = file_find_di_next(fsp)) {
|
||||
fsp = file_find_di_next(fsp, true)) {
|
||||
|
||||
DBG_DEBUG("Checking file %s, fd = %d, vuid = %"PRIu64", "
|
||||
"file_pid = %"PRIu16", "
|
||||
|
@ -5301,7 +5301,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
|
||||
/* Do we have this path open ? */
|
||||
files_struct *fsp1;
|
||||
struct file_id fileid = vfs_file_id_from_sbuf(conn, psbuf);
|
||||
fsp1 = file_find_di_first(conn->sconn, fileid);
|
||||
fsp1 = file_find_di_first(conn->sconn, fileid, true);
|
||||
if (fsp1 && fsp1->initial_allocation_size) {
|
||||
allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn, fsp1, psbuf);
|
||||
}
|
||||
@ -8383,8 +8383,8 @@ static NTSTATUS smb_set_file_unix_basic(connection_struct *conn,
|
||||
}
|
||||
|
||||
id = vfs_file_id_from_sbuf(conn, &sbuf);
|
||||
for(all_fsps = file_find_di_first(conn->sconn, id); all_fsps;
|
||||
all_fsps = file_find_di_next(all_fsps)) {
|
||||
for(all_fsps = file_find_di_first(conn->sconn, id, true); all_fsps;
|
||||
all_fsps = file_find_di_next(all_fsps, true)) {
|
||||
/*
|
||||
* We're setting the time explicitly for UNIX.
|
||||
* Cancel any pending changes over all handles.
|
||||
|
Loading…
Reference in New Issue
Block a user