mirror of
https://github.com/samba-team/samba.git
synced 2025-03-03 12:58:35 +03:00
smbd: Use share_mode_do_locked() in smbd_do_unlocking()
We don't really need the share mode data here Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
39f9618316
commit
18d7bb0698
@ -8362,20 +8362,24 @@ uint64_t get_lock_offset(const uint8_t *data, int data_offset,
|
|||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS smbd_do_unlocking(struct smb_request *req,
|
struct smbd_do_unlocking_state {
|
||||||
files_struct *fsp,
|
struct files_struct *fsp;
|
||||||
uint16_t num_ulocks,
|
uint16_t num_ulocks;
|
||||||
struct smbd_lock_element *ulocks,
|
struct smbd_lock_element *ulocks;
|
||||||
enum brl_flavour lock_flav)
|
enum brl_flavour lock_flav;
|
||||||
|
NTSTATUS status;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void smbd_do_unlocking_fn(
|
||||||
|
TDB_DATA value, bool *pmodified_dependent, void *private_data)
|
||||||
{
|
{
|
||||||
struct share_mode_lock *lck;
|
struct smbd_do_unlocking_state *state = private_data;
|
||||||
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
|
struct files_struct *fsp = state->fsp;
|
||||||
|
enum brl_flavour lock_flav = state->lock_flav;
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
|
|
||||||
lck = get_existing_share_mode_lock(talloc_tos(), fsp->file_id);
|
for (i = 0; i < state->num_ulocks; i++) {
|
||||||
|
struct smbd_lock_element *e = &state->ulocks[i];
|
||||||
for(i = 0; i < num_ulocks; i++) {
|
|
||||||
struct smbd_lock_element *e = &ulocks[i];
|
|
||||||
|
|
||||||
DBG_DEBUG("unlock start=%"PRIu64", len=%"PRIu64" for "
|
DBG_DEBUG("unlock start=%"PRIu64", len=%"PRIu64" for "
|
||||||
"pid %"PRIu64", file %s\n",
|
"pid %"PRIu64", file %s\n",
|
||||||
@ -8386,36 +8390,56 @@ NTSTATUS smbd_do_unlocking(struct smb_request *req,
|
|||||||
|
|
||||||
if (e->brltype != UNLOCK_LOCK) {
|
if (e->brltype != UNLOCK_LOCK) {
|
||||||
/* this can only happen with SMB2 */
|
/* this can only happen with SMB2 */
|
||||||
status = NT_STATUS_INVALID_PARAMETER;
|
state->status = NT_STATUS_INVALID_PARAMETER;
|
||||||
goto done;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = do_unlock(
|
state->status = do_unlock(
|
||||||
fsp,
|
fsp, e->smblctx, e->count, e->offset, lock_flav);
|
||||||
e->smblctx,
|
|
||||||
e->count,
|
|
||||||
e->offset,
|
|
||||||
lock_flav);
|
|
||||||
|
|
||||||
DEBUG(10, ("%s: unlock returned %s\n", __func__,
|
DBG_DEBUG("do_unlock returned %s\n",
|
||||||
nt_errstr(status)));
|
nt_errstr(state->status));
|
||||||
|
|
||||||
|
if (!NT_STATUS_IS_OK(state->status)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*pmodified_dependent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS smbd_do_unlocking(struct smb_request *req,
|
||||||
|
files_struct *fsp,
|
||||||
|
uint16_t num_ulocks,
|
||||||
|
struct smbd_lock_element *ulocks,
|
||||||
|
enum brl_flavour lock_flav)
|
||||||
|
{
|
||||||
|
struct smbd_do_unlocking_state state = {
|
||||||
|
.fsp = fsp,
|
||||||
|
.num_ulocks = num_ulocks,
|
||||||
|
.ulocks = ulocks,
|
||||||
|
.lock_flav = lock_flav,
|
||||||
|
};
|
||||||
|
NTSTATUS status;
|
||||||
|
|
||||||
|
DBG_NOTICE("%s num_ulocks=%"PRIu16"\n", fsp_fnum_dbg(fsp), num_ulocks);
|
||||||
|
|
||||||
|
status = share_mode_do_locked(
|
||||||
|
fsp->file_id, smbd_do_unlocking_fn, &state);
|
||||||
|
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
goto done;
|
DBG_DEBUG("share_mode_do_locked failed: %s\n",
|
||||||
}
|
nt_errstr(status));
|
||||||
}
|
|
||||||
|
|
||||||
DEBUG(3, ("%s: %s num_ulocks=%d\n", __func__, fsp_fnum_dbg(fsp),
|
|
||||||
num_ulocks));
|
|
||||||
|
|
||||||
done:
|
|
||||||
if (NT_STATUS_IS_OK(status) && (lck != NULL)) {
|
|
||||||
lck->data->modified = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
TALLOC_FREE(lck);
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
if (!NT_STATUS_IS_OK(state.status)) {
|
||||||
|
DBG_DEBUG("smbd_do_unlocking_fn failed: %s\n",
|
||||||
|
nt_errstr(status));
|
||||||
|
return state.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NT_STATUS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Reply to a lockingX request.
|
Reply to a lockingX request.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user