2006-07-11 22:01:26 +04:00
/*
Unix SMB / CIFS implementation .
SMB parameters and setup , plus a whole lot more .
Copyright ( C ) Jeremy Allison 2006
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
2007-07-09 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
2006-07-11 22:01:26 +04:00
( 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
2007-07-10 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2006-07-11 22:01:26 +04:00
*/
# ifndef _LOCKING_H
# define _LOCKING_H
/* passed to br lock code - the UNLOCK_LOCK should never be stored into the tdb
2006-07-29 23:14:24 +04:00
and is used in calculating POSIX unlock ranges only . We differentiate between
PENDING read and write locks to allow posix lock downgrades to trigger a lock
re - evaluation . */
2006-07-11 22:01:26 +04:00
2006-07-29 23:14:24 +04:00
enum brl_type { READ_LOCK , WRITE_LOCK , PENDING_READ_LOCK , PENDING_WRITE_LOCK , UNLOCK_LOCK } ;
2006-07-11 22:01:26 +04:00
enum brl_flavour { WINDOWS_LOCK = 0 , POSIX_LOCK = 1 } ;
2006-07-29 23:14:24 +04:00
# define IS_PENDING_LOCK(type) ((type) == PENDING_READ_LOCK || (type) == PENDING_WRITE_LOCK)
2011-03-24 17:31:06 +03:00
# include "librpc/gen_ndr/server_id.h"
2006-07-11 22:01:26 +04:00
/* This contains elements that differentiate locks. The smbpid is a
client supplied pid , and is essentially the locking context for
this client */
struct lock_context {
2010-05-07 17:20:50 +04:00
uint64_t smblctx ;
2006-07-11 22:01:26 +04:00
uint16 tid ;
2007-05-07 13:35:35 +04:00
struct server_id pid ;
2006-07-11 22:01:26 +04:00
} ;
2007-05-29 13:30:34 +04:00
struct files_struct ;
2006-07-11 22:01:26 +04:00
2012-04-16 09:34:40 +04:00
# include "lib/file_id.h"
2006-07-11 22:01:26 +04:00
struct byte_range_lock {
2006-07-18 01:09:02 +04:00
struct files_struct * fsp ;
2006-07-11 22:01:26 +04:00
unsigned int num_locks ;
2007-10-19 04:40:25 +04:00
bool modified ;
bool read_only ;
2007-05-29 13:30:34 +04:00
struct file_id key ;
2007-05-06 00:43:06 +04:00
struct lock_struct * lock_data ;
2007-05-27 14:35:14 +04:00
struct db_record * record ;
2006-07-11 22:01:26 +04:00
} ;
/* Internal structure in brlock.tdb.
The data in brlock records is an unsorted linear array of these
records . It is unnecessary to store the count as tdb provides the
size of the record */
struct lock_struct {
struct lock_context context ;
br_off start ;
br_off size ;
uint16 fnum ;
enum brl_type lock_type ;
enum brl_flavour lock_flav ;
} ;
2009-02-10 08:51:29 +03:00
/****************************************************************************
This is the structure to queue to implement blocking locks .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
struct blocking_lock_record {
struct blocking_lock_record * next ;
struct blocking_lock_record * prev ;
struct files_struct * fsp ;
struct timeval expire_time ;
int lock_num ;
uint64_t offset ;
uint64_t count ;
2010-05-07 17:20:50 +04:00
uint64_t smblctx ;
uint64_t blocking_smblctx ; /* Context that blocks us. */
2009-02-10 08:51:29 +03:00
enum brl_flavour lock_flav ;
enum brl_type lock_type ;
struct smb_request * req ;
void * blr_private ; /* Implementation specific. */
} ;
2010-05-01 08:03:20 +04:00
struct smbd_lock_element {
2010-05-07 17:20:50 +04:00
uint64_t smblctx ;
2010-05-01 08:03:20 +04:00
enum brl_type brltype ;
uint64_t offset ;
uint64_t count ;
} ;
2006-07-11 22:01:26 +04:00
# endif /* _LOCKING_H_ */