blob: af1e8374128580b568ea3d4e57f9789df41418fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/*
Unix SMB/CIFS implementation.
Lease utility functions
Copyright (C) Jeremy Allison 2017.
Copyright (C) Stefan (metze) Metzmacher 2017.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define DBGC_CLASS DBGC_LOCKING
#include "includes.h"
#include "../librpc/gen_ndr/open_files.h"
#include "locking/proto.h"
uint32_t map_oplock_to_lease_type(uint16_t op_type)
{
uint32_t ret;
switch(op_type) {
case BATCH_OPLOCK:
case BATCH_OPLOCK|EXCLUSIVE_OPLOCK:
ret = SMB2_LEASE_READ|SMB2_LEASE_WRITE|SMB2_LEASE_HANDLE;
break;
case EXCLUSIVE_OPLOCK:
ret = SMB2_LEASE_READ|SMB2_LEASE_WRITE;
break;
case LEVEL_II_OPLOCK:
ret = SMB2_LEASE_READ;
break;
default:
ret = SMB2_LEASE_NONE;
break;
}
return ret;
}
uint32_t fsp_lease_type(const struct files_struct *fsp)
{
if (fsp->oplock_type == LEASE_OPLOCK) {
return fsp->lease->lease.lease_state;
}
return map_oplock_to_lease_type(fsp->oplock_type);
}
uint32_t lease_type_is_exclusive(uint32_t lease_type)
{
if ((lease_type & (SMB2_LEASE_READ | SMB2_LEASE_WRITE)) ==
(SMB2_LEASE_READ | SMB2_LEASE_WRITE)) {
return true;
}
return false;
}
bool fsp_lease_type_is_exclusive(const struct files_struct *fsp)
{
uint32_t lease_type = fsp_lease_type(fsp);
return lease_type_is_exclusive(lease_type);
}
|