From: Ralph Boehme Date: Thu, 2 Apr 2020 15:09:36 +0000 (+0200) Subject: smbd: move files_struct.can_lock to a bitfield X-Git-Tag: ldb-2.2.0~994 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d22096961be2dd8a41631484d87d3afadaec6ca0;p=thirdparty%2Fsamba.git smbd: move files_struct.can_lock to a bitfield Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/include/vfs.h b/source3/include/vfs.h index 23dbc7d2289..2600cc3b31d 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -362,6 +362,7 @@ typedef struct files_struct { bool update_write_time_triggered : 1; bool update_write_time_on_close : 1; bool write_time_forced : 1; + bool can_lock : 1; } fsp_flags; struct tevent_timer *update_write_time_event; @@ -382,7 +383,6 @@ typedef struct files_struct { struct lock_struct last_lock_failure; int current_lock_count; /* Count the number of outstanding locks and pending locks. */ - bool can_lock; bool can_read; bool can_write; bool modified; diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 1220cb3a2be..7d71e436f4a 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -178,7 +178,7 @@ NTSTATUS query_lock(files_struct *fsp, { struct byte_range_lock *br_lck = NULL; - if (!fsp->can_lock) { + if (!fsp->fsp_flags.can_lock) { return fsp->is_directory ? NT_STATUS_INVALID_DEVICE_REQUEST : NT_STATUS_INVALID_HANDLE; } @@ -306,7 +306,7 @@ NTSTATUS do_lock(files_struct *fsp, return NT_STATUS_OK; } - if (!fsp->can_lock) { + if (!fsp->fsp_flags.can_lock) { if (fsp->is_directory) { return NT_STATUS_INVALID_DEVICE_REQUEST; } @@ -362,7 +362,7 @@ NTSTATUS do_unlock(files_struct *fsp, bool ok = False; struct byte_range_lock *br_lck = NULL; - if (!fsp->can_lock) { + if (!fsp->fsp_flags.can_lock) { return fsp->is_directory ? NT_STATUS_INVALID_DEVICE_REQUEST : NT_STATUS_INVALID_HANDLE; } diff --git a/source3/printing/printspoolss.c b/source3/printing/printspoolss.c index 523e429b205..e3dbc2e7b8f 100644 --- a/source3/printing/printspoolss.c +++ b/source3/printing/printspoolss.c @@ -228,7 +228,7 @@ NTSTATUS print_spool_open(files_struct *fsp, fsp->fh->fd = fd; fsp->vuid = current_vuid; - fsp->can_lock = false; + fsp->fsp_flags.can_lock = false; fsp->can_read = false; fsp->access_mask = FILE_GENERIC_WRITE; fsp->can_write = true; diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index 1d482b377fd..0a38d5a5c55 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -699,7 +699,7 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn, /* * For normal files, can_lock == !is_directory */ - fsp->can_lock = true; + fsp->fsp_flags.can_lock = true; /* * We do not support aio write behind for smb2 */ diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index 81ccbde6aab..625c21ff8bd 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -166,7 +166,7 @@ NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn, fsp->fh->fd = -1; fsp->vuid = current_vuid; fsp->fh->pos = -1; - fsp->can_lock = False; /* Should this be true ? - No, JRA */ + fsp->fsp_flags.can_lock = false; /* Should this be true ? - No, JRA */ fsp->access_mask = access_mask; status = fsp_set_smb_fname(fsp, smb_fname); if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 433c9b00866..18b3d086a92 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -788,7 +788,7 @@ NTSTATUS dup_file_fsp( to->open_time = from->open_time; to->access_mask = access_mask; to->oplock_type = from->oplock_type; - to->can_lock = from->can_lock; + to->fsp_flags.can_lock = from->fsp_flags.can_lock; to->can_read = ((access_mask & FILE_READ_DATA) != 0); to->can_write = CAN_WRITE(from->conn) && diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 41f253c77e4..40f4b2be5d7 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1429,7 +1429,7 @@ static NTSTATUS open_file(files_struct *fsp, fsp->file_id = vfs_file_id_from_sbuf(conn, &smb_fname->st); fsp->vuid = req ? req->vuid : UID_FIELD_INVALID; fsp->file_pid = req ? req->smbpid : 0; - fsp->can_lock = True; + fsp->fsp_flags.can_lock = true; fsp->can_read = ((access_mask & FILE_READ_DATA) != 0); fsp->can_write = CAN_WRITE(conn) && @@ -4391,7 +4391,7 @@ static NTSTATUS open_directory(connection_struct *conn, fsp->file_id = vfs_file_id_from_sbuf(conn, &smb_dname->st); fsp->vuid = req ? req->vuid : UID_FIELD_INVALID; fsp->file_pid = req ? req->smbpid : 0; - fsp->can_lock = False; + fsp->fsp_flags.can_lock = false; fsp->can_read = False; fsp->can_write = False; diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c index dd72d163134..49802aed44e 100644 --- a/source3/smbd/pipes.c +++ b/source3/smbd/pipes.c @@ -48,7 +48,7 @@ NTSTATUS open_np_file(struct smb_request *smb_req, const char *name, fsp->conn = conn; fsp->fh->fd = -1; fsp->vuid = smb_req->vuid; - fsp->can_lock = false; + fsp->fsp_flags.can_lock = false; fsp->access_mask = FILE_READ_DATA | FILE_WRITE_DATA; smb_fname = synthetic_smb_fname(talloc_tos(), name, NULL, NULL, 0); diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c index 39fe875a385..85985539984 100644 --- a/source3/smbd/pysmbd.c +++ b/source3/smbd/pysmbd.c @@ -193,7 +193,7 @@ static NTSTATUS init_files_struct(TALLOC_CTX *mem_ctx, fsp->file_id = vfs_file_id_from_sbuf(conn, &smb_fname->st); fsp->vuid = UID_FIELD_INVALID; fsp->file_pid = 0; - fsp->can_lock = True; + fsp->fsp_flags.can_lock = true; fsp->can_read = True; fsp->can_write = True; fsp->print_file = NULL; diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index 1e12c5bba5d..3485ebb0fda 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -422,7 +422,7 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c fsp->file_id = vfs_file_id_from_sbuf(vfs->conn, &smb_fname->st); fsp->vuid = UID_FIELD_INVALID; fsp->file_pid = 0; - fsp->can_lock = True; + fsp->fsp_flags.can_lock = true; fsp->can_read = True; fsp->can_write = CAN_WRITE(vfs->conn); @@ -1651,7 +1651,7 @@ static NTSTATUS cmd_set_nt_acl(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int a fsp->file_id = vfs_file_id_from_sbuf(vfs->conn, &smb_fname->st); fsp->vuid = UID_FIELD_INVALID; fsp->file_pid = 0; - fsp->can_lock = True; + fsp->fsp_flags.can_lock = true; fsp->can_read = True; fsp->can_write = True; fsp->print_file = NULL;