2003-08-13 05:53:07 +04:00
/*
Unix SMB / CIFS implementation .
NTVFS structures and defines
Copyright ( C ) Andrew Tridgell 2003
2004-09-29 17:17:09 +04:00
Copyright ( C ) Stefan Metzmacher 2004
2003-08-13 05:53:07 +04:00
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-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2003-08-13 05:53:07 +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 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2003-08-13 05:53:07 +04:00
*/
2007-01-19 15:12:53 +03:00
# ifndef _NTVFS_H_
# define _NTVFS_H_
2006-03-26 05:23:40 +04:00
# include "libcli/raw/interfaces.h"
2006-07-23 22:43:07 +04:00
# include "param/share.h"
2008-10-15 04:52:10 +04:00
# include "librpc/gen_ndr/security.h"
2011-05-02 04:55:20 +04:00
# include "librpc/gen_ndr/server_id.h"
2006-03-26 05:23:40 +04:00
2003-08-13 05:53:07 +04:00
/* modules can use the following to determine if the interface has changed */
2004-09-29 17:17:09 +04:00
/* version 1 -> 0 - make module stacking easier -- metze */
# define NTVFS_INTERFACE_VERSION 0
2003-08-13 05:53:07 +04:00
2004-09-29 17:17:09 +04:00
struct ntvfs_module_context ;
2006-03-18 14:10:21 +03:00
struct ntvfs_request ;
2006-03-10 17:31:17 +03:00
2004-09-29 17:17:09 +04:00
/* each backend has to be one one of the following 3 basic types. In
2008-02-13 02:13:28 +03:00
earlier versions of Samba backends needed to handle all types , now
we implement them separately .
The values 1. .3 match the SMB2 SMB2_SHARE_TYPE_ * values
*/
enum ntvfs_type { NTVFS_DISK = 1 , NTVFS_IPC = 2 , NTVFS_PRINT = 3 } ;
2003-08-13 05:53:07 +04:00
/* the ntvfs operations structure - contains function pointers to
the backend implementations of each operation */
struct ntvfs_ops {
2003-11-25 06:15:26 +03:00
const char * name ;
enum ntvfs_type type ;
2006-03-10 17:31:17 +03:00
2003-08-13 05:53:07 +04:00
/* initial setup */
2012-06-13 11:11:42 +04:00
NTSTATUS ( * connect_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
2009-05-14 11:58:50 +04:00
union smb_tcon * tcon ) ;
2012-06-13 11:11:42 +04:00
NTSTATUS ( * disconnect_fn ) ( struct ntvfs_module_context * ntvfs ) ;
2006-03-10 17:31:17 +03:00
/* async_setup - called when a backend is processing a async request */
2012-06-13 11:11:42 +04:00
NTSTATUS ( * async_setup_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
2009-02-02 10:29:13 +03:00
void * private_data ) ;
2006-03-10 17:31:17 +03:00
/* filesystem operations */
2012-06-13 11:11:42 +04:00
NTSTATUS ( * fsinfo_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
union smb_fsinfo * fs ) ;
2003-08-13 05:53:07 +04:00
/* path operations */
2012-06-13 11:11:42 +04:00
NTSTATUS ( * unlink_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
2006-03-10 23:49:20 +03:00
union smb_unlink * unl ) ;
2012-06-13 11:11:42 +04:00
NTSTATUS ( * chkpath_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
2006-03-10 23:49:20 +03:00
union smb_chkpath * cp ) ;
2012-06-13 11:11:42 +04:00
NTSTATUS ( * qpathinfo_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
union smb_fileinfo * st ) ;
2012-06-13 11:11:42 +04:00
NTSTATUS ( * setpathinfo_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
union smb_setfileinfo * st ) ;
2012-06-13 11:11:42 +04:00
NTSTATUS ( * mkdir_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
union smb_mkdir * md ) ;
2012-06-13 11:11:42 +04:00
NTSTATUS ( * rmdir_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
struct smb_rmdir * rd ) ;
2012-06-13 11:11:42 +04:00
NTSTATUS ( * rename_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
union smb_rename * ren ) ;
2012-06-13 11:11:42 +04:00
NTSTATUS ( * copy_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
struct smb_copy * cp ) ;
2012-06-13 11:11:42 +04:00
NTSTATUS ( * open_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
union smb_open * oi ) ;
2003-08-13 05:53:07 +04:00
/* directory search */
2012-06-13 11:11:42 +04:00
NTSTATUS ( * search_first_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
2009-02-02 10:29:13 +03:00
union smb_search_first * io , void * private_data ,
2012-06-13 11:11:42 +04:00
bool ( * callback_fn ) ( void * private_data , const union smb_search_data * file ) ) ;
NTSTATUS ( * search_next_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
2009-02-02 10:29:13 +03:00
union smb_search_next * io , void * private_data ,
2012-06-13 11:11:42 +04:00
bool ( * callback_fn ) ( void * private_data , const union smb_search_data * file ) ) ;
NTSTATUS ( * search_close_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
union smb_search_close * io ) ;
2003-08-13 05:53:07 +04:00
/* operations on open files */
2012-06-13 11:11:42 +04:00
NTSTATUS ( * ioctl_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
union smb_ioctl * io ) ;
2012-06-13 11:11:42 +04:00
NTSTATUS ( * read_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
union smb_read * io ) ;
2012-06-13 11:11:42 +04:00
NTSTATUS ( * write_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
union smb_write * io ) ;
2012-06-13 11:11:42 +04:00
NTSTATUS ( * seek_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
2006-03-10 23:49:20 +03:00
union smb_seek * io ) ;
2012-06-13 11:11:42 +04:00
NTSTATUS ( * flush_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
2006-03-10 23:49:20 +03:00
union smb_flush * flush ) ;
2012-06-13 11:11:42 +04:00
NTSTATUS ( * lock_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
union smb_lock * lck ) ;
2012-06-13 11:11:42 +04:00
NTSTATUS ( * qfileinfo_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
union smb_fileinfo * info ) ;
2012-06-13 11:11:42 +04:00
NTSTATUS ( * setfileinfo_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
union smb_setfileinfo * info ) ;
2012-06-13 11:11:42 +04:00
NTSTATUS ( * close_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
union smb_close * io ) ;
2003-12-11 12:07:45 +03:00
/* trans interface - used by IPC backend for pipes and RAP calls */
2012-06-13 11:11:42 +04:00
NTSTATUS ( * trans_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
struct smb_trans2 * trans ) ;
2004-09-26 15:30:20 +04:00
2006-03-10 17:31:17 +03:00
/* trans2 interface - only used by CIFS backend to prover complete passthru for testing */
2012-06-13 11:11:42 +04:00
NTSTATUS ( * trans2_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
struct smb_trans2 * trans2 ) ;
2004-10-18 17:27:22 +04:00
2006-03-10 17:31:17 +03:00
/* change notify request */
2012-06-13 11:11:42 +04:00
NTSTATUS ( * notify_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
2006-07-12 18:25:50 +04:00
union smb_notify * info ) ;
2004-11-04 14:28:38 +03:00
/* cancel - cancels any pending async request */
2012-06-13 11:11:42 +04:00
NTSTATUS ( * cancel_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ) ;
2006-03-08 06:54:24 +03:00
2006-03-10 17:31:17 +03:00
/* printing specific operations */
2012-06-13 11:11:42 +04:00
NTSTATUS ( * lpq_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ,
union smb_lpq * lpq ) ;
/* logoff - called when a vuid is closed */
2012-06-13 11:11:42 +04:00
NTSTATUS ( * logoff_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ) ;
2012-06-13 11:11:42 +04:00
NTSTATUS ( * exit_fn ) ( struct ntvfs_module_context * ntvfs ,
2006-03-10 17:31:17 +03:00
struct ntvfs_request * req ) ;
2003-08-13 05:53:07 +04:00
} ;
2004-09-29 17:17:09 +04:00
struct ntvfs_module_context {
struct ntvfs_module_context * prev , * next ;
2006-03-15 20:28:46 +03:00
struct ntvfs_context * ctx ;
2004-09-29 17:17:09 +04:00
int depth ;
2006-03-15 20:28:46 +03:00
const struct ntvfs_ops * ops ;
void * private_data ;
2004-09-29 17:17:09 +04:00
} ;
struct ntvfs_context {
enum ntvfs_type type ;
2006-03-15 20:28:46 +03:00
/* the reported filesystem type */
char * fs_type ;
/* the reported device type */
char * dev_type ;
enum protocol_types protocol ;
2008-03-06 17:14:08 +03:00
/*
* client capabilities
* this field doesn ' t use protocol specific
* values !
*/
# define NTVFS_CLIENT_CAP_LEVEL_II_OPLOCKS 0x0000000000000001LLU
uint64_t client_caps ;
2004-09-29 17:17:09 +04:00
/*
* linked list of module contexts
*/
struct ntvfs_module_context * modules ;
2006-03-15 20:28:46 +03:00
2006-07-23 22:43:07 +04:00
struct share_config * config ;
2006-03-15 20:28:46 +03:00
2007-01-10 13:52:09 +03:00
struct server_id server_id ;
2007-12-09 01:32:43 +03:00
struct loadparm_context * lp_ctx ;
2008-12-29 22:24:57 +03:00
struct tevent_context * event_ctx ;
2011-05-03 04:40:33 +04:00
struct imessaging_context * msg_ctx ;
2006-03-15 20:28:46 +03:00
struct {
void * private_data ;
2006-05-20 12:15:22 +04:00
NTSTATUS ( * handler ) ( void * private_data , struct ntvfs_handle * handle , uint8_t level ) ;
2006-03-15 20:28:46 +03:00
} oplock ;
2006-03-16 21:54:19 +03:00
struct {
2010-04-26 15:40:15 +04:00
const struct tsocket_address * local_address ;
const struct tsocket_address * remote_address ;
2006-03-16 21:54:19 +03:00
} client ;
2003-08-13 05:53:07 +04:00
2006-05-20 12:15:22 +04:00
struct {
void * private_data ;
NTSTATUS ( * create_new ) ( void * private_data , struct ntvfs_request * req , struct ntvfs_handle * * h ) ;
NTSTATUS ( * make_valid ) ( void * private_data , struct ntvfs_handle * h ) ;
void ( * destroy ) ( void * private_data , struct ntvfs_handle * h ) ;
struct ntvfs_handle * ( * search_by_wire_key ) ( void * private_data , struct ntvfs_request * req , const DATA_BLOB * key ) ;
DATA_BLOB ( * get_wire_key ) ( void * private_data , struct ntvfs_handle * handle , TALLOC_CTX * mem_ctx ) ;
} handles ;
} ;
2004-10-29 01:48:53 +04:00
/* a set of flags to control handling of request structures */
# define NTVFS_ASYNC_STATE_ASYNC (1<<1) /* the backend will answer this one later */
# define NTVFS_ASYNC_STATE_MAY_ASYNC (1<<2) /* the backend is allowed to answer async */
2008-12-05 12:04:55 +03:00
# define NTVFS_ASYNC_STATE_CLOSE (1<<3) /* the backend session should be closed */
2004-10-29 01:48:53 +04:00
/* the ntvfs_async_state structure allows backend functions to
delay replying to requests . To use this , the front end must
set send_fn to a function to be called by the backend
when the reply is finally ready to be sent . The backend
must set status to the status it wants in the
reply . The backend must set the NTVFS_ASYNC_STATE_ASYNC
control_flag on the request to indicate that it wishes to
delay the reply
If NTVFS_ASYNC_STATE_MAY_ASYNC is not set then the backend cannot
ask for a delayed reply for this request
note that the private_data pointer is private to the layer which alloced this struct
*/
struct ntvfs_async_state {
struct ntvfs_async_state * prev , * next ;
/* the async handling infos */
2006-05-02 03:03:32 +04:00
unsigned int state ;
2004-10-29 01:48:53 +04:00
void * private_data ;
2006-03-10 17:31:17 +03:00
void ( * send_fn ) ( struct ntvfs_request * ) ;
2004-10-29 01:48:53 +04:00
NTSTATUS status ;
/* the passthru module's per session private data */
struct ntvfs_module_context * ntvfs ;
} ;
2006-03-18 14:10:21 +03:00
struct ntvfs_request {
/* the ntvfs_context this requests belongs to */
struct ntvfs_context * ctx ;
/* ntvfs per request async states */
struct ntvfs_async_state * async_states ;
/* the session_info, with security_token and maybe delegated credentials */
struct auth_session_info * session_info ;
/* the smb pid is needed for locking contexts */
2008-06-02 05:04:13 +04:00
uint32_t smbpid ;
2006-03-18 14:10:21 +03:00
2008-03-06 17:14:08 +03:00
/*
* client capabilities
* this field doesn ' t use protocol specific
* values !
* see NTVFS_CLIENT_CAP_ *
*/
uint64_t client_caps ;
2023-08-03 15:40:03 +03:00
/* some statistics for the management tools */
2006-03-18 14:10:21 +03:00
struct {
/* the system time when the request arrived */
struct timeval request_time ;
} statistics ;
2006-05-20 12:15:22 +04:00
struct {
void * private_data ;
} frontend_data ;
} ;
struct ntvfs_handle {
struct ntvfs_context * ctx ;
struct auth_session_info * session_info ;
uint16_t smbpid ;
struct ntvfs_handle_data {
struct ntvfs_handle_data * prev , * next ;
struct ntvfs_module_context * owner ;
void * private_data ; /* this must be a valid talloc pointer */
} * backend_data ;
struct {
void * private_data ;
} frontend_data ;
2006-03-18 14:10:21 +03:00
} ;
2003-08-13 05:53:07 +04:00
/* this structure is used by backends to determine the size of some critical types */
struct ntvfs_critical_sizes {
2003-12-02 12:16:53 +03:00
int interface_version ;
2004-10-29 01:48:53 +04:00
int sizeof_ntvfs_critical_sizes ;
2004-09-29 17:17:09 +04:00
int sizeof_ntvfs_context ;
int sizeof_ntvfs_module_context ;
2003-08-13 05:53:07 +04:00
int sizeof_ntvfs_ops ;
2004-10-29 01:48:53 +04:00
int sizeof_ntvfs_async_state ;
2006-03-10 17:31:17 +03:00
int sizeof_ntvfs_request ;
2006-05-20 12:15:22 +04:00
int sizeof_ntvfs_handle ;
int sizeof_ntvfs_handle_data ;
2003-08-13 05:53:07 +04:00
} ;
2005-12-28 01:51:30 +03:00
2006-04-24 05:26:31 +04:00
# define NTVFS_CURRENT_CRITICAL_SIZES(c) \
struct ntvfs_critical_sizes c = { \
. interface_version = NTVFS_INTERFACE_VERSION , \
. sizeof_ntvfs_critical_sizes = sizeof ( struct ntvfs_critical_sizes ) , \
. sizeof_ntvfs_context = sizeof ( struct ntvfs_context ) , \
. sizeof_ntvfs_module_context = sizeof ( struct ntvfs_module_context ) , \
. sizeof_ntvfs_ops = sizeof ( struct ntvfs_ops ) , \
. sizeof_ntvfs_async_state = sizeof ( struct ntvfs_async_state ) , \
. sizeof_ntvfs_request = sizeof ( struct ntvfs_request ) , \
2006-05-20 12:15:22 +04:00
. sizeof_ntvfs_handle = sizeof ( struct ntvfs_handle ) , \
. sizeof_ntvfs_handle_data = sizeof ( struct ntvfs_handle_data ) , \
2006-04-24 05:26:31 +04:00
}
2011-05-03 04:40:33 +04:00
struct imessaging_context ;
2006-03-18 18:42:57 +03:00
# include "librpc/gen_ndr/security.h"
2011-05-02 05:10:12 +04:00
# include "librpc/gen_ndr/notify.h"
2005-12-28 01:51:30 +03:00
# include "ntvfs/ntvfs_proto.h"
2007-01-19 15:12:53 +03:00
# endif /* _NTVFS_H_ */