open_global_id is an uint32_t, share_file_id is an uint64_t.
For internal opens that don't have an smbXsrv_open_global.tdb entry, continue to
use a generation counter starting at UINT32_MAX + 1.
We don't expose internal opens via srvsrc, which imposes the requirement for
using an uint32_t, so we can use larger ids for the internal opens as srvsvc
never sees them (as they're not in smbXsrv_open_global.tdb and srvsvc as any
other component listing open files like smbstatus lists smbXsrv_open_global.tdb).
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Fri Oct 10 11:43:16 UTC 2025 on atb-devel-224
ok = reset_share_mode_entry(
lck,
messaging_server_id(fsp->conn->sconn->msg_ctx),
- fh_get_gen_id(fsp->fh),
+ fsp->op->global->open_persistent_id,
disconnected_pid,
UINT64_MAX,
fsp->op->global->open_persistent_id);
state.fsp->file_pid = smb1req->smbpid;
state.fsp->vuid = smb1req->vuid;
state.fsp->fnum = op->local_id;
- fsp_set_gen_id(state.fsp);
+ fh_set_gen_id(state.fsp->fh, op->global->open_global_id);
status = fsp_set_smb_fname(state.fsp, smb_fname);
if (!NT_STATUS_IS_OK(status)) {
void fsp_set_gen_id(files_struct *fsp)
{
- static uint64_t gen_id = 1;
+ static uint64_t gen_id = UINT32_MAX;
/*
- * A billion of 64-bit increments per second gives us
- * more than 500 years of runtime without wrap.
+ * These ids are only used for internal opens, which gives us 4 billion
+ * opens until we wrap.
*/
gen_id++;
+ if (gen_id == 0) {
+ gen_id = UINT32_MAX;
+ }
fh_set_gen_id(fsp->fh, gen_id);
}
NTTIME now;
NTSTATUS status;
- fsp_set_gen_id(fsp);
-
if (req == NULL) {
DBG_DEBUG("INTERNAL_OPEN_ONLY, skipping smbXsrv_open\n");
+ fsp_set_gen_id(fsp);
return NT_STATUS_OK;
}
}
fsp->op = op;
op->compat = fsp;
+ fh_set_gen_id(fsp->fh, fsp->op->global->open_global_id);
fsp->fnum = op->local_id;
fsp->mid = req->mid;