2009-10-25 18:12:12 +03:00
/*
Unix SMB / CIFS implementation .
2010-03-12 14:08:19 +03:00
global locks based on dbwrap and messaging
2009-10-25 18:12:12 +03:00
Copyright ( C ) 2009 by Volker Lendecke
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/>.
*/
# ifndef _G_LOCK_H_
# define _G_LOCK_H_
2011-07-07 19:42:08 +04:00
# include "dbwrap/dbwrap.h"
2009-10-25 18:12:12 +03:00
struct g_lock_ctx ;
2013-09-02 11:24:42 +04:00
struct messaging_context ;
2009-10-25 18:12:12 +03:00
enum g_lock_type {
G_LOCK_READ = 0 ,
G_LOCK_WRITE = 1 ,
} ;
2017-05-18 16:27:46 +03:00
struct g_lock_rec {
enum g_lock_type lock_type ;
struct server_id pid ;
} ;
2009-10-25 18:12:12 +03:00
struct g_lock_ctx * g_lock_ctx_init ( TALLOC_CTX * mem_ctx ,
struct messaging_context * msg ) ;
2012-05-03 20:30:38 +04:00
struct tevent_req * g_lock_lock_send ( TALLOC_CTX * mem_ctx ,
struct tevent_context * ev ,
struct g_lock_ctx * ctx ,
2017-12-03 22:47:02 +03:00
TDB_DATA key ,
2012-05-03 20:30:38 +04:00
enum g_lock_type type ) ;
NTSTATUS g_lock_lock_recv ( struct tevent_req * req ) ;
2017-12-03 22:47:02 +03:00
NTSTATUS g_lock_lock ( struct g_lock_ctx * ctx , TDB_DATA key ,
2009-10-25 18:12:12 +03:00
enum g_lock_type lock_type , struct timeval timeout ) ;
2017-12-03 22:47:02 +03:00
NTSTATUS g_lock_unlock ( struct g_lock_ctx * ctx , TDB_DATA key ) ;
2009-10-25 18:12:12 +03:00
2017-12-03 22:47:02 +03:00
NTSTATUS g_lock_write_data ( struct g_lock_ctx * ctx , TDB_DATA key ,
2017-05-23 13:32:24 +03:00
const uint8_t * buf , size_t buflen ) ;
2017-12-03 22:47:02 +03:00
NTSTATUS g_lock_do ( TDB_DATA key , enum g_lock_type lock_type ,
2011-12-12 17:55:54 +04:00
struct timeval timeout ,
2010-03-12 16:22:54 +03:00
void ( * fn ) ( void * private_data ) , void * private_data ) ;
2009-10-25 18:12:12 +03:00
int g_lock_locks ( struct g_lock_ctx * ctx ,
2017-12-03 22:47:02 +03:00
int ( * fn ) ( TDB_DATA key , void * private_data ) ,
2009-10-25 18:12:12 +03:00
void * private_data ) ;
2017-12-03 22:47:02 +03:00
NTSTATUS g_lock_dump ( struct g_lock_ctx * ctx , TDB_DATA key ,
2017-05-18 16:27:46 +03:00
void ( * fn ) ( const struct g_lock_rec * locks ,
size_t num_locks ,
const uint8_t * data ,
size_t datalen ,
void * private_data ) ,
2009-10-25 18:12:12 +03:00
void * private_data ) ;
# endif