2003-08-13 01:53:07 +00:00
/*
Unix SMB / CIFS implementation .
NTVFS structures and defines
Copyright ( C ) Andrew Tridgell 2003
2004-09-29 13:17:09 +00:00
Copyright ( C ) Stefan Metzmacher 2004
2003-08-13 01:53:07 +00: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 02:07:03 +00:00
the Free Software Foundation ; either version 3 of the License , or
2003-08-13 01:53:07 +00: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 02:07:03 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2003-08-13 01:53:07 +00:00
*/
2007-01-19 12:12:53 +00:00
# ifndef _NTVFS_H_
# define _NTVFS_H_
2006-03-26 01:23:40 +00:00
# include "libcli/raw/interfaces.h"
2006-07-23 18:43:07 +00:00
# include "param/share.h"
2006-03-26 01:23:40 +00:00
2003-08-13 01:53:07 +00:00
/* modules can use the following to determine if the interface has changed */
2004-09-29 13:17:09 +00:00
/* version 1 -> 0 - make module stacking easier -- metze */
# define NTVFS_INTERFACE_VERSION 0
2003-08-13 01:53:07 +00:00
2004-09-29 13:17:09 +00:00
struct ntvfs_module_context ;
2006-03-18 11:10:21 +00:00
struct ntvfs_request ;
2006-03-10 14:31:17 +00:00
2004-09-29 13:17:09 +00:00
/* each backend has to be one one of the following 3 basic types. In
* earlier versions of Samba backends needed to handle all types , now
* we implement them separately . */
enum ntvfs_type { NTVFS_DISK , NTVFS_PRINT , NTVFS_IPC } ;
2003-08-13 01:53:07 +00:00
/* the ntvfs operations structure - contains function pointers to
the backend implementations of each operation */
struct ntvfs_ops {
2003-11-25 03:15:26 +00:00
const char * name ;
enum ntvfs_type type ;
2006-03-10 14:31:17 +00:00
2003-08-13 01:53:07 +00:00
/* initial setup */
2006-03-10 14:31:17 +00:00
NTSTATUS ( * connect ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
const char * sharename ) ;
NTSTATUS ( * disconnect ) ( struct ntvfs_module_context * ntvfs ) ;
/* async_setup - called when a backend is processing a async request */
NTSTATUS ( * async_setup ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
void * private ) ;
/* filesystem operations */
NTSTATUS ( * fsinfo ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
union smb_fsinfo * fs ) ;
2003-08-13 01:53:07 +00:00
/* path operations */
2006-03-10 14:31:17 +00:00
NTSTATUS ( * unlink ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
2006-03-10 20:49:20 +00:00
union smb_unlink * unl ) ;
2006-03-10 14:31:17 +00:00
NTSTATUS ( * chkpath ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
2006-03-10 20:49:20 +00:00
union smb_chkpath * cp ) ;
2006-03-10 14:31:17 +00:00
NTSTATUS ( * qpathinfo ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
union smb_fileinfo * st ) ;
NTSTATUS ( * setpathinfo ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
union smb_setfileinfo * st ) ;
NTSTATUS ( * mkdir ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
union smb_mkdir * md ) ;
NTSTATUS ( * rmdir ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
struct smb_rmdir * rd ) ;
NTSTATUS ( * rename ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
union smb_rename * ren ) ;
NTSTATUS ( * copy ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
struct smb_copy * cp ) ;
NTSTATUS ( * open ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
union smb_open * oi ) ;
2003-08-13 01:53:07 +00:00
/* directory search */
2006-03-10 14:31:17 +00:00
NTSTATUS ( * search_first ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
union smb_search_first * io , void * private ,
2007-05-22 09:25:58 +00:00
BOOL ( * callback ) ( void * private , const union smb_search_data * file ) ) ;
2006-03-10 14:31:17 +00:00
NTSTATUS ( * search_next ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
union smb_search_next * io , void * private ,
2007-05-22 09:25:58 +00:00
BOOL ( * callback ) ( void * private , const union smb_search_data * file ) ) ;
2006-03-10 14:31:17 +00:00
NTSTATUS ( * search_close ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
union smb_search_close * io ) ;
2003-08-13 01:53:07 +00:00
/* operations on open files */
2006-03-10 14:31:17 +00:00
NTSTATUS ( * ioctl ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
union smb_ioctl * io ) ;
NTSTATUS ( * read ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
union smb_read * io ) ;
NTSTATUS ( * write ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
union smb_write * io ) ;
NTSTATUS ( * seek ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
2006-03-10 20:49:20 +00:00
union smb_seek * io ) ;
2006-03-10 14:31:17 +00:00
NTSTATUS ( * flush ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
2006-03-10 20:49:20 +00:00
union smb_flush * flush ) ;
2006-03-10 14:31:17 +00:00
NTSTATUS ( * lock ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
union smb_lock * lck ) ;
NTSTATUS ( * qfileinfo ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
union smb_fileinfo * info ) ;
NTSTATUS ( * setfileinfo ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
union smb_setfileinfo * info ) ;
NTSTATUS ( * close ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
union smb_close * io ) ;
2003-12-11 09:07:45 +00:00
/* trans interface - used by IPC backend for pipes and RAP calls */
2006-03-10 14:31:17 +00:00
NTSTATUS ( * trans ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
struct smb_trans2 * trans ) ;
2004-09-26 11:30:20 +00:00
2006-03-10 14:31:17 +00:00
/* trans2 interface - only used by CIFS backend to prover complete passthru for testing */
NTSTATUS ( * trans2 ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
struct smb_trans2 * trans2 ) ;
2004-10-18 13:27:22 +00:00
2006-03-10 14:31:17 +00:00
/* change notify request */
NTSTATUS ( * notify ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
2006-07-12 14:25:50 +00:00
union smb_notify * info ) ;
2004-11-04 11:28:38 +00:00
/* cancel - cancels any pending async request */
2006-03-10 14:31:17 +00:00
NTSTATUS ( * cancel ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ) ;
2006-03-08 03:54:24 +00:00
2006-03-10 14:31:17 +00:00
/* printing specific operations */
NTSTATUS ( * lpq ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ,
union smb_lpq * lpq ) ;
/* logoff - called when a vuid is closed */
NTSTATUS ( * logoff ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ) ;
NTSTATUS ( * exit ) ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req ) ;
2003-08-13 01:53:07 +00:00
} ;
2004-09-29 13:17:09 +00:00
struct ntvfs_module_context {
struct ntvfs_module_context * prev , * next ;
2006-03-15 17:28:46 +00:00
struct ntvfs_context * ctx ;
2004-09-29 13:17:09 +00:00
int depth ;
2006-03-15 17:28:46 +00:00
const struct ntvfs_ops * ops ;
void * private_data ;
2004-09-29 13:17:09 +00:00
} ;
struct ntvfs_context {
enum ntvfs_type type ;
2006-03-15 17:28:46 +00:00
/* the reported filesystem type */
char * fs_type ;
/* the reported device type */
char * dev_type ;
enum protocol_types protocol ;
2004-09-29 13:17:09 +00:00
/*
* linked list of module contexts
*/
struct ntvfs_module_context * modules ;
2006-03-15 17:28:46 +00:00
2006-07-23 18:43:07 +00:00
struct share_config * config ;
2006-03-15 17:28:46 +00:00
2007-01-10 10:52:09 +00:00
struct server_id server_id ;
2006-03-15 17:28:46 +00:00
struct event_context * event_ctx ;
struct messaging_context * msg_ctx ;
struct {
void * private_data ;
2006-05-20 08:15:22 +00:00
NTSTATUS ( * handler ) ( void * private_data , struct ntvfs_handle * handle , uint8_t level ) ;
2006-03-15 17:28:46 +00:00
} oplock ;
2006-03-16 18:54:19 +00:00
struct {
void * private_data ;
struct socket_address * ( * get_my_addr ) ( void * private_data , TALLOC_CTX * mem_ctx ) ;
struct socket_address * ( * get_peer_addr ) ( void * private_data , TALLOC_CTX * mem_ctx ) ;
} client ;
2003-08-13 01:53:07 +00:00
2006-05-20 08:15:22 +00: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-28 21:48:53 +00: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 */
/* 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-01 23:03:32 +00:00
unsigned int state ;
2004-10-28 21:48:53 +00:00
void * private_data ;
2006-03-10 14:31:17 +00:00
void ( * send_fn ) ( struct ntvfs_request * ) ;
2004-10-28 21:48:53 +00:00
NTSTATUS status ;
/* the passthru module's per session private data */
struct ntvfs_module_context * ntvfs ;
} ;
2006-03-18 11:10:21 +00: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 */
uint16_t smbpid ;
/* some statictics for the management tools */
struct {
/* the system time when the request arrived */
struct timeval request_time ;
} statistics ;
2006-05-20 08:15:22 +00: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 11:10:21 +00:00
} ;
2003-08-13 01:53:07 +00:00
/* this structure is used by backends to determine the size of some critical types */
struct ntvfs_critical_sizes {
2003-12-02 09:16:53 +00:00
int interface_version ;
2004-10-28 21:48:53 +00:00
int sizeof_ntvfs_critical_sizes ;
2004-09-29 13:17:09 +00:00
int sizeof_ntvfs_context ;
int sizeof_ntvfs_module_context ;
2003-08-13 01:53:07 +00:00
int sizeof_ntvfs_ops ;
2004-10-28 21:48:53 +00:00
int sizeof_ntvfs_async_state ;
2006-03-10 14:31:17 +00:00
int sizeof_ntvfs_request ;
2006-05-20 08:15:22 +00:00
int sizeof_ntvfs_handle ;
int sizeof_ntvfs_handle_data ;
2003-08-13 01:53:07 +00:00
} ;
2005-12-27 22:51:30 +00:00
2006-04-24 01:26:31 +00: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 08:15:22 +00:00
. sizeof_ntvfs_handle = sizeof ( struct ntvfs_handle ) , \
. sizeof_ntvfs_handle_data = sizeof ( struct ntvfs_handle_data ) , \
2006-04-24 01:26:31 +00:00
}
2006-03-14 15:03:25 +00:00
struct messaging_context ;
2006-03-18 15:42:57 +00:00
# include "librpc/gen_ndr/security.h"
2006-03-21 11:47:24 +00:00
# include "librpc/gen_ndr/notify.h"
2005-12-27 22:51:30 +00:00
# include "ntvfs/ntvfs_proto.h"
2007-01-19 12:12:53 +00:00
# endif /* _NTVFS_H_ */