2004-03-08 07:17:15 +00:00
/*
Unix SMB / CIFS implementation .
a pass - thru NTVFS module to record a NBENCH load file
Copyright ( C ) Andrew Tridgell 2004
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 2 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 , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
/*
" passthru " in this module refers to the next level of NTVFS being used
*/
# include "includes.h"
2005-02-10 05:09:35 +00:00
# include "system/filesys.h"
2004-11-02 07:18:24 +00:00
# include "smb_server/smb_server.h"
2005-12-27 22:51:30 +00:00
# include "ntvfs/ntvfs.h"
2004-03-08 07:17:15 +00:00
/* this is stored in ntvfs_private */
struct nbench_private {
int log_fd ;
} ;
/*
log one request to the nbench log
*/
2006-03-10 14:31:17 +00:00
static void nbench_log ( struct ntvfs_request * req ,
2004-08-25 07:15:21 +00:00
const char * format , . . . ) PRINTF_ATTRIBUTE ( 2 , 3 ) ;
2006-03-10 14:31:17 +00:00
static void nbench_log ( struct ntvfs_request * req ,
2004-03-08 07:17:15 +00:00
const char * format , . . . )
{
2004-10-29 00:51:41 +00:00
struct nbench_private * private = req - > async_states - > ntvfs - > private_data ;
2004-03-08 07:17:15 +00:00
va_list ap ;
char * s = NULL ;
va_start ( ap , format ) ;
vasprintf ( & s , format , ap ) ;
va_end ( ap ) ;
2004-10-28 22:18:52 +00:00
write ( private - > log_fd , s , strlen ( s ) ) ;
2004-03-08 07:17:15 +00:00
free ( s ) ;
}
/*
this pass through macro operates on request contexts , and disables
async calls .
async calls are a pain for the nbench module as it makes pulling the
status code and any result parameters much harder .
*/
2004-10-28 21:48:53 +00:00
# define PASS_THRU_REQ_PRE_ASYNC(ntvfs, req, op, par1) do { \
2006-03-10 14:31:17 +00:00
status = ntvfs_async_state_push ( ntvfs , req , par1 , nbench_ # # op # # _send ) ; \
2004-10-28 21:48:53 +00:00
if ( ! NT_STATUS_IS_OK ( status ) ) { \
return status ; \
} \
} while ( 0 )
# define PASS_THRU_REQ_POST_ASYNC(req) do { \
req - > async_states - > status = status ; \
if ( ! ( req - > async_states - > state & NTVFS_ASYNC_STATE_ASYNC ) ) { \
req - > async_states - > send_fn ( req ) ; \
} \
} while ( 0 )
# define PASS_THRU_REQ(ntvfs, req, op, par1, args) do { \
PASS_THRU_REQ_PRE_ASYNC ( ntvfs , req , op , par1 ) ; \
2004-09-29 13:17:09 +00:00
status = ntvfs_next_ # # op args ; \
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ_POST_ASYNC ( req ) ; \
2004-03-08 07:17:15 +00:00
} while ( 0 )
2004-10-28 21:48:53 +00:00
# define PASS_THRU_REP_POST(req) do { \
ntvfs_async_state_pop ( req ) ; \
if ( req - > async_states - > state & NTVFS_ASYNC_STATE_ASYNC ) { \
req - > async_states - > send_fn ( req ) ; \
} \
} while ( 0 )
2004-03-08 07:17:15 +00:00
/*
connect to a share - used when a tree_connect operation comes in .
*/
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_connect ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , const char * sharename )
2004-03-08 07:17:15 +00:00
{
2004-10-28 21:48:53 +00:00
struct nbench_private * nprivates ;
2004-03-08 07:17:15 +00:00
NTSTATUS status ;
char * logname = NULL ;
2006-01-25 12:19:49 +00:00
nprivates = talloc ( ntvfs , struct nbench_private ) ;
2004-10-28 21:48:53 +00:00
if ( ! nprivates ) {
2004-03-08 07:17:15 +00:00
return NT_STATUS_NO_MEMORY ;
}
2004-10-28 22:18:52 +00:00
2004-09-29 13:17:09 +00:00
asprintf ( & logname , " /tmp/nbenchlog%d.%u " , ntvfs - > depth , getpid ( ) ) ;
2004-11-01 20:21:54 +00:00
nprivates - > log_fd = open ( logname , O_WRONLY | O_CREAT | O_APPEND , 0644 ) ;
2004-03-08 07:17:15 +00:00
free ( logname ) ;
2004-10-28 21:48:53 +00:00
if ( nprivates - > log_fd = = - 1 ) {
2004-03-08 07:17:15 +00:00
DEBUG ( 0 , ( " Failed to open nbench log \n " ) ) ;
return NT_STATUS_UNSUCCESSFUL ;
}
2004-10-28 22:18:52 +00:00
2004-10-28 21:48:53 +00:00
ntvfs - > private_data = nprivates ;
2004-03-08 07:17:15 +00:00
2004-09-29 13:17:09 +00:00
status = ntvfs_next_connect ( ntvfs , req , sharename ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
disconnect from a share
*/
2006-03-10 14:31:17 +00:00
static NTSTATUS nbench_disconnect ( struct ntvfs_module_context * ntvfs )
2004-03-08 07:17:15 +00:00
{
2004-10-28 21:48:53 +00:00
struct nbench_private * nprivates = ntvfs - > private_data ;
2004-03-08 07:17:15 +00:00
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
close ( nprivates - > log_fd ) ;
2004-03-08 07:17:15 +00:00
2006-03-10 14:31:17 +00:00
status = ntvfs_next_disconnect ( ntvfs ) ;
2004-10-28 21:48:53 +00:00
2004-03-08 07:17:15 +00:00
return status ;
}
/*
delete a file - the dirtype specifies the file types to include in the search .
The name can contain CIFS wildcards , but rarely does ( except with OS / 2 clients )
*/
2006-03-10 14:31:17 +00:00
static void nbench_unlink_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
2006-03-10 20:49:20 +00:00
union smb_unlink * unl = req - > async_states - > private_data ;
2004-10-28 21:48:53 +00:00
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Unlink \" %s \" 0x%x %s \n " ,
2006-03-10 20:49:20 +00:00
unl - > unlink . in . pattern , unl - > unlink . in . attrib ,
2004-10-28 21:48:53 +00:00
get_nt_error_c_code ( req - > async_states - > status ) ) ;
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_unlink ( struct ntvfs_module_context * ntvfs ,
2006-03-10 20:49:20 +00:00
struct ntvfs_request * req ,
union smb_unlink * unl )
2004-03-08 07:17:15 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , unlink , unl , ( ntvfs , req , unl ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
ioctl interface
*/
2006-03-10 14:31:17 +00:00
static void nbench_ioctl_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Ioctl - NOT HANDLED \n " ) ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_ioctl ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , union smb_ioctl * io )
2004-03-08 07:17:15 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , ioctl , io , ( ntvfs , req , io ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
check if a directory exists
*/
2006-03-10 14:31:17 +00:00
static void nbench_chkpath_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
2006-03-10 20:49:20 +00:00
union smb_chkpath * cp = req - > async_states - > private_data ;
2004-10-28 21:48:53 +00:00
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Chkpath \" %s \" %s \n " ,
2006-03-10 20:49:20 +00:00
cp - > chkpath . in . path ,
2004-10-28 21:48:53 +00:00
get_nt_error_c_code ( req - > async_states - > status ) ) ;
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_chkpath ( struct ntvfs_module_context * ntvfs ,
2006-03-10 20:49:20 +00:00
struct ntvfs_request * req ,
union smb_chkpath * cp )
2004-03-08 07:17:15 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , chkpath , cp , ( ntvfs , req , cp ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
return info on a pathname
*/
2006-03-10 14:31:17 +00:00
static void nbench_qpathinfo_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
union smb_fileinfo * info = req - > async_states - > private_data ;
2004-10-29 00:51:41 +00:00
nbench_log ( req , " QUERY_PATH_INFORMATION \" %s \" %d %s \n " ,
2006-03-12 22:48:25 +00:00
info - > generic . in . file . path ,
2004-10-28 21:48:53 +00:00
info - > generic . level ,
get_nt_error_c_code ( req - > async_states - > status ) ) ;
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_qpathinfo ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , union smb_fileinfo * info )
2004-03-08 07:17:15 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , qpathinfo , info , ( ntvfs , req , info ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
query info on a open file
*/
2006-03-10 14:31:17 +00:00
static void nbench_qfileinfo_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
union smb_fileinfo * info = req - > async_states - > private_data ;
2004-10-29 00:51:41 +00:00
nbench_log ( req , " QUERY_FILE_INFORMATION %d %d %s \n " ,
2006-03-12 22:48:25 +00:00
info - > generic . in . file . fnum ,
2004-10-28 21:48:53 +00:00
info - > generic . level ,
get_nt_error_c_code ( req - > async_states - > status ) ) ;
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_qfileinfo ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , union smb_fileinfo * info )
2004-03-08 07:17:15 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , qfileinfo , info , ( ntvfs , req , info ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
set info on a pathname
*/
2006-03-10 14:31:17 +00:00
static void nbench_setpathinfo_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
union smb_setfileinfo * st = req - > async_states - > private_data ;
2004-10-29 00:51:41 +00:00
nbench_log ( req , " SET_PATH_INFORMATION \" %s \" %d %s \n " ,
2006-03-12 22:48:25 +00:00
st - > generic . in . file . path ,
2004-10-28 21:48:53 +00:00
st - > generic . level ,
get_nt_error_c_code ( req - > async_states - > status ) ) ;
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_setpathinfo ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , union smb_setfileinfo * st )
2004-03-08 07:17:15 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , setpathinfo , st , ( ntvfs , req , st ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
open a file
*/
2006-03-10 14:31:17 +00:00
static void nbench_open_send ( struct ntvfs_request * req )
2004-03-08 07:17:15 +00:00
{
2004-10-28 21:48:53 +00:00
union smb_open * io = req - > async_states - > private_data ;
2004-03-08 07:17:15 +00:00
switch ( io - > generic . level ) {
case RAW_OPEN_NTCREATEX :
2004-10-29 01:22:47 +00:00
if ( ! NT_STATUS_IS_OK ( req - > async_states - > status ) ) {
ZERO_STRUCT ( io - > ntcreatex . out ) ;
}
2004-10-29 00:51:41 +00:00
nbench_log ( req , " NTCreateX \" %s \" 0x%x 0x%x %d %s \n " ,
2004-03-08 07:17:15 +00:00
io - > ntcreatex . in . fname ,
io - > ntcreatex . in . create_options ,
io - > ntcreatex . in . open_disposition ,
2006-03-12 22:48:25 +00:00
io - > ntcreatex . out . file . fnum ,
2004-10-28 21:48:53 +00:00
get_nt_error_c_code ( req - > async_states - > status ) ) ;
2004-03-08 07:17:15 +00:00
break ;
default :
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Open-%d - NOT HANDLED \n " ,
2004-03-08 07:17:15 +00:00
io - > generic . level ) ;
break ;
}
2004-10-28 21:48:53 +00:00
PASS_THRU_REP_POST ( req ) ;
}
2006-03-10 14:31:17 +00:00
static NTSTATUS nbench_open ( struct ntvfs_module_context * ntvfs ,
struct ntvfs_request * req , union smb_open * io )
2004-10-28 21:48:53 +00:00
{
NTSTATUS status ;
2006-03-10 14:31:17 +00:00
PASS_THRU_REQ ( ntvfs , req , open , io , ( ntvfs , req , io ) ) ;
2004-10-28 21:48:53 +00:00
2004-03-08 07:17:15 +00:00
return status ;
}
/*
create a directory
*/
2006-03-10 14:31:17 +00:00
static void nbench_mkdir_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Mkdir - NOT HANDLED \n " ) ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_mkdir ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , union smb_mkdir * md )
2004-03-08 07:17:15 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , mkdir , md , ( ntvfs , req , md ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
remove a directory
*/
2006-03-10 14:31:17 +00:00
static void nbench_rmdir_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
struct smb_rmdir * rd = req - > async_states - > private_data ;
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Rmdir \" %s \" %s \n " ,
2004-10-28 21:48:53 +00:00
rd - > in . path ,
get_nt_error_c_code ( req - > async_states - > status ) ) ;
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_rmdir ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , struct smb_rmdir * rd )
2004-03-08 07:17:15 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , rmdir , rd , ( ntvfs , req , rd ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
rename a set of files
*/
2006-03-10 14:31:17 +00:00
static void nbench_rename_send ( struct ntvfs_request * req )
2004-03-08 07:17:15 +00:00
{
2004-10-28 21:48:53 +00:00
union smb_rename * ren = req - > async_states - > private_data ;
2004-03-08 07:17:15 +00:00
switch ( ren - > generic . level ) {
case RAW_RENAME_RENAME :
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Rename \" %s \" \" %s \" %s \n " ,
2004-03-08 07:17:15 +00:00
ren - > rename . in . pattern1 ,
ren - > rename . in . pattern2 ,
2004-10-28 21:48:53 +00:00
get_nt_error_c_code ( req - > async_states - > status ) ) ;
2004-03-08 07:17:15 +00:00
break ;
default :
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Rename-%d - NOT HANDLED \n " ,
2004-03-08 07:17:15 +00:00
ren - > generic . level ) ;
break ;
}
2004-10-28 21:48:53 +00:00
PASS_THRU_REP_POST ( req ) ;
}
static NTSTATUS nbench_rename ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , union smb_rename * ren )
2004-10-28 21:48:53 +00:00
{
NTSTATUS status ;
PASS_THRU_REQ ( ntvfs , req , rename , ren , ( ntvfs , req , ren ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
copy a set of files
*/
2006-03-10 14:31:17 +00:00
static void nbench_copy_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Copy - NOT HANDLED \n " ) ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_copy ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , struct smb_copy * cp )
2004-03-08 07:17:15 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , copy , cp , ( ntvfs , req , cp ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
read from a file
*/
2006-03-10 14:31:17 +00:00
static void nbench_read_send ( struct ntvfs_request * req )
2004-03-08 07:17:15 +00:00
{
2004-10-28 21:48:53 +00:00
union smb_read * rd = req - > async_states - > private_data ;
2004-10-29 01:07:07 +00:00
2004-03-08 07:17:15 +00:00
switch ( rd - > generic . level ) {
case RAW_READ_READX :
2004-10-29 01:22:47 +00:00
if ( ! NT_STATUS_IS_OK ( req - > async_states - > status ) ) {
ZERO_STRUCT ( rd - > readx . out ) ;
2004-10-29 01:07:07 +00:00
}
2004-10-29 00:51:41 +00:00
nbench_log ( req , " ReadX %d %d %d %d %s \n " ,
2006-03-12 22:48:25 +00:00
rd - > readx . in . file . fnum ,
2004-03-08 07:17:15 +00:00
( int ) rd - > readx . in . offset ,
rd - > readx . in . maxcnt ,
2004-10-29 01:22:47 +00:00
rd - > readx . out . nread ,
2004-10-28 21:48:53 +00:00
get_nt_error_c_code ( req - > async_states - > status ) ) ;
2004-03-08 07:17:15 +00:00
break ;
default :
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Read-%d - NOT HANDLED \n " ,
2004-03-08 07:17:15 +00:00
rd - > generic . level ) ;
break ;
}
2004-10-28 21:48:53 +00:00
PASS_THRU_REP_POST ( req ) ;
}
static NTSTATUS nbench_read ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , union smb_read * rd )
2004-10-28 21:48:53 +00:00
{
NTSTATUS status ;
PASS_THRU_REQ ( ntvfs , req , read , rd , ( ntvfs , req , rd ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
write to a file
*/
2006-03-10 14:31:17 +00:00
static void nbench_write_send ( struct ntvfs_request * req )
2004-03-08 07:17:15 +00:00
{
2004-10-28 21:48:53 +00:00
union smb_write * wr = req - > async_states - > private_data ;
2004-03-08 07:17:15 +00:00
switch ( wr - > generic . level ) {
case RAW_WRITE_WRITEX :
2004-10-29 01:22:47 +00:00
if ( ! NT_STATUS_IS_OK ( req - > async_states - > status ) ) {
ZERO_STRUCT ( wr - > writex . out ) ;
}
2004-10-29 00:51:41 +00:00
nbench_log ( req , " WriteX %d %d %d %d %s \n " ,
2006-03-12 22:48:25 +00:00
wr - > writex . in . file . fnum ,
2004-03-08 07:17:15 +00:00
( int ) wr - > writex . in . offset ,
wr - > writex . in . count ,
wr - > writex . out . nwritten ,
2004-10-28 21:48:53 +00:00
get_nt_error_c_code ( req - > async_states - > status ) ) ;
2004-03-08 07:17:15 +00:00
break ;
case RAW_WRITE_WRITE :
2004-10-29 01:22:47 +00:00
if ( ! NT_STATUS_IS_OK ( req - > async_states - > status ) ) {
ZERO_STRUCT ( wr - > write . out ) ;
}
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Write %d %d %d %d %s \n " ,
2006-03-12 22:48:25 +00:00
wr - > write . in . file . fnum ,
2004-03-08 07:17:15 +00:00
wr - > write . in . offset ,
wr - > write . in . count ,
wr - > write . out . nwritten ,
2004-10-28 21:48:53 +00:00
get_nt_error_c_code ( req - > async_states - > status ) ) ;
2004-03-08 07:17:15 +00:00
break ;
default :
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Write-%d - NOT HANDLED \n " ,
2004-03-08 07:17:15 +00:00
wr - > generic . level ) ;
break ;
}
2004-10-28 21:48:53 +00:00
PASS_THRU_REP_POST ( req ) ;
}
static NTSTATUS nbench_write ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , union smb_write * wr )
2004-10-28 21:48:53 +00:00
{
NTSTATUS status ;
PASS_THRU_REQ ( ntvfs , req , write , wr , ( ntvfs , req , wr ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
seek in a file
*/
2006-03-10 14:31:17 +00:00
static void nbench_seek_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Seek - NOT HANDLED \n " ) ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_seek ( struct ntvfs_module_context * ntvfs ,
2006-03-10 20:49:20 +00:00
struct ntvfs_request * req ,
union smb_seek * io )
2004-03-08 07:17:15 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , seek , io , ( ntvfs , req , io ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
flush a file
*/
2006-03-10 14:31:17 +00:00
static void nbench_flush_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
2006-03-10 20:49:20 +00:00
union smb_flush * io = req - > async_states - > private_data ;
2004-10-28 21:48:53 +00:00
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Flush %d %s \n " ,
2006-03-12 22:48:25 +00:00
io - > flush . in . file . fnum ,
2004-10-28 21:48:53 +00:00
get_nt_error_c_code ( req - > async_states - > status ) ) ;
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_flush ( struct ntvfs_module_context * ntvfs ,
2006-03-10 20:49:20 +00:00
struct ntvfs_request * req ,
union smb_flush * io )
2004-03-08 07:17:15 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , flush , io , ( ntvfs , req , io ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
close a file
*/
2006-03-10 14:31:17 +00:00
static void nbench_close_send ( struct ntvfs_request * req )
2004-03-08 07:17:15 +00:00
{
2004-10-28 21:48:53 +00:00
union smb_close * io = req - > async_states - > private_data ;
2004-03-08 07:17:15 +00:00
switch ( io - > generic . level ) {
case RAW_CLOSE_CLOSE :
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Close %d %s \n " ,
2006-03-12 22:48:25 +00:00
io - > close . in . file . fnum ,
2004-10-28 21:48:53 +00:00
get_nt_error_c_code ( req - > async_states - > status ) ) ;
2004-03-08 07:17:15 +00:00
break ;
default :
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Close-%d - NOT HANDLED \n " ,
2004-03-08 07:17:15 +00:00
io - > generic . level ) ;
break ;
}
2004-10-28 21:48:53 +00:00
PASS_THRU_REP_POST ( req ) ;
}
static NTSTATUS nbench_close ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , union smb_close * io )
2004-10-28 21:48:53 +00:00
{
NTSTATUS status ;
PASS_THRU_REQ ( ntvfs , req , close , io , ( ntvfs , req , io ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
exit - closing files
*/
2006-03-10 14:31:17 +00:00
static void nbench_exit_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Exit - NOT HANDLED \n " ) ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_exit ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req )
2004-03-08 07:17:15 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , exit , NULL , ( ntvfs , req ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
2004-09-26 11:30:20 +00:00
/*
logoff - closing files
*/
2006-03-10 14:31:17 +00:00
static void nbench_logoff_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Logoff - NOT HANDLED \n " ) ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_logoff ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req )
2004-09-26 11:30:20 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , logoff , NULL , ( ntvfs , req ) ) ;
2004-09-26 11:30:20 +00:00
return status ;
}
2004-10-29 00:51:41 +00:00
/*
async_setup - send fn
*/
2006-03-10 14:31:17 +00:00
static void nbench_async_setup_send ( struct ntvfs_request * req )
2004-10-29 00:51:41 +00:00
{
PASS_THRU_REP_POST ( req ) ;
}
2004-10-18 13:27:22 +00:00
/*
async setup
*/
static NTSTATUS nbench_async_setup ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req ,
2004-10-18 13:27:22 +00:00
void * private )
{
2004-10-29 00:51:41 +00:00
NTSTATUS status ;
PASS_THRU_REQ ( ntvfs , req , async_setup , NULL , ( ntvfs , req , private ) ) ;
return status ;
2004-10-18 13:27:22 +00:00
}
2004-11-04 11:28:38 +00:00
2006-03-10 14:31:17 +00:00
static void nbench_cancel_send ( struct ntvfs_request * req )
2004-11-04 11:28:38 +00:00
{
PASS_THRU_REP_POST ( req ) ;
}
/*
cancel an existing async request
*/
static NTSTATUS nbench_cancel ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req )
2004-11-04 11:28:38 +00:00
{
NTSTATUS status ;
PASS_THRU_REQ ( ntvfs , req , cancel , NULL , ( ntvfs , req ) ) ;
return status ;
}
2004-03-08 07:17:15 +00:00
/*
lock a byte range
*/
2006-03-10 14:31:17 +00:00
static void nbench_lock_send ( struct ntvfs_request * req )
2004-03-08 07:17:15 +00:00
{
2004-10-28 21:48:53 +00:00
union smb_lock * lck = req - > async_states - > private_data ;
2004-03-08 07:17:15 +00:00
if ( lck - > generic . level = = RAW_LOCK_LOCKX & &
lck - > lockx . in . lock_cnt = = 1 & &
lck - > lockx . in . ulock_cnt = = 0 ) {
2004-10-29 00:51:41 +00:00
nbench_log ( req , " LockX %d %d %d %s \n " ,
2006-03-12 22:48:25 +00:00
lck - > lockx . in . file . fnum ,
2004-03-08 07:17:15 +00:00
( int ) lck - > lockx . in . locks [ 0 ] . offset ,
( int ) lck - > lockx . in . locks [ 0 ] . count ,
2004-10-28 21:48:53 +00:00
get_nt_error_c_code ( req - > async_states - > status ) ) ;
2004-03-08 07:17:15 +00:00
} else if ( lck - > generic . level = = RAW_LOCK_LOCKX & &
lck - > lockx . in . ulock_cnt = = 1 ) {
2004-10-29 00:51:41 +00:00
nbench_log ( req , " UnlockX %d %d %d %s \n " ,
2006-03-12 22:48:25 +00:00
lck - > lockx . in . file . fnum ,
2004-03-08 07:17:15 +00:00
( int ) lck - > lockx . in . locks [ 0 ] . offset ,
( int ) lck - > lockx . in . locks [ 0 ] . count ,
2004-10-28 21:48:53 +00:00
get_nt_error_c_code ( req - > async_states - > status ) ) ;
2004-03-08 07:17:15 +00:00
} else {
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Lock-%d - NOT HANDLED \n " , lck - > generic . level ) ;
2004-03-08 07:17:15 +00:00
}
2004-10-28 21:48:53 +00:00
PASS_THRU_REP_POST ( req ) ;
}
static NTSTATUS nbench_lock ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , union smb_lock * lck )
2004-10-28 21:48:53 +00:00
{
NTSTATUS status ;
PASS_THRU_REQ ( ntvfs , req , lock , lck , ( ntvfs , req , lck ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
set info on a open file
*/
2006-03-10 14:31:17 +00:00
static void nbench_setfileinfo_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
union smb_setfileinfo * info = req - > async_states - > private_data ;
2004-10-29 00:51:41 +00:00
nbench_log ( req , " SET_FILE_INFORMATION %d %d %s \n " ,
2006-03-12 22:48:25 +00:00
info - > generic . in . file . fnum ,
2004-10-28 21:48:53 +00:00
info - > generic . level ,
get_nt_error_c_code ( req - > async_states - > status ) ) ;
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_setfileinfo ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req ,
2004-09-29 13:17:09 +00:00
union smb_setfileinfo * info )
2004-03-08 07:17:15 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , setfileinfo , info , ( ntvfs , req , info ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
return filesystem space info
*/
2006-03-10 14:31:17 +00:00
static void nbench_fsinfo_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
union smb_fsinfo * fs = req - > async_states - > private_data ;
2004-10-29 00:51:41 +00:00
nbench_log ( req , " QUERY_FS_INFORMATION %d %s \n " ,
2004-10-28 21:48:53 +00:00
fs - > generic . level ,
get_nt_error_c_code ( req - > async_states - > status ) ) ;
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_fsinfo ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , union smb_fsinfo * fs )
2004-03-08 07:17:15 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , fsinfo , fs , ( ntvfs , req , fs ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
return print queue info
*/
2006-03-10 14:31:17 +00:00
static void nbench_lpq_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
union smb_lpq * lpq = req - > async_states - > private_data ;
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Lpq-%d - NOT HANDLED \n " , lpq - > generic . level ) ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_lpq ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , union smb_lpq * lpq )
2004-03-08 07:17:15 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , lpq , lpq , ( ntvfs , req , lpq ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
list files in a directory matching a wildcard pattern
*/
2006-03-10 14:31:17 +00:00
static void nbench_search_first_send ( struct ntvfs_request * req )
2004-03-08 07:17:15 +00:00
{
2004-10-28 21:48:53 +00:00
union smb_search_first * io = req - > async_states - > private_data ;
2004-03-08 07:17:15 +00:00
switch ( io - > generic . level ) {
case RAW_SEARCH_BOTH_DIRECTORY_INFO :
2004-10-29 01:22:47 +00:00
if ( NT_STATUS_IS_ERR ( req - > async_states - > status ) ) {
ZERO_STRUCT ( io - > t2ffirst . out ) ;
}
2004-10-29 00:51:41 +00:00
nbench_log ( req , " FIND_FIRST \" %s \" %d %d %d %s \n " ,
2004-03-08 07:17:15 +00:00
io - > t2ffirst . in . pattern ,
io - > generic . level ,
io - > t2ffirst . in . max_count ,
io - > t2ffirst . out . count ,
2004-10-28 21:48:53 +00:00
get_nt_error_c_code ( req - > async_states - > status ) ) ;
2004-03-08 07:17:15 +00:00
break ;
default :
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Search-%d - NOT HANDLED \n " , io - > generic . level ) ;
2004-03-08 07:17:15 +00:00
break ;
}
2004-10-28 21:48:53 +00:00
PASS_THRU_REP_POST ( req ) ;
}
static NTSTATUS nbench_search_first ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , union smb_search_first * io ,
2004-10-28 21:48:53 +00:00
void * search_private ,
BOOL ( * callback ) ( void * , union smb_search_data * ) )
{
NTSTATUS status ;
PASS_THRU_REQ ( ntvfs , req , search_first , io , ( ntvfs , req , io , search_private , callback ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/* continue a search */
2006-03-10 14:31:17 +00:00
static void nbench_search_next_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
union smb_search_next * io = req - > async_states - > private_data ;
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Searchnext-%d - NOT HANDLED \n " , io - > generic . level ) ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_search_next ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , union smb_search_next * io ,
2004-09-29 13:17:09 +00:00
void * search_private ,
BOOL ( * callback ) ( void * , union smb_search_data * ) )
2004-03-08 07:17:15 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , search_next , io , ( ntvfs , req , io , search_private , callback ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/* close a search */
2006-03-10 14:31:17 +00:00
static void nbench_search_close_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
union smb_search_close * io = req - > async_states - > private_data ;
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Searchclose-%d - NOT HANDLED \n " , io - > generic . level ) ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_search_close ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , union smb_search_close * io )
2004-03-08 07:17:15 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , search_close , io , ( ntvfs , req , io ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/* SMBtrans - not used on file shares */
2006-03-10 14:31:17 +00:00
static void nbench_trans_send ( struct ntvfs_request * req )
2004-10-28 21:48:53 +00:00
{
2004-10-29 00:51:41 +00:00
nbench_log ( req , " Trans - NOT HANDLED \n " ) ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REP_POST ( req ) ;
}
2004-09-29 13:17:09 +00:00
static NTSTATUS nbench_trans ( struct ntvfs_module_context * ntvfs ,
2006-03-10 14:31:17 +00:00
struct ntvfs_request * req , struct smb_trans2 * trans2 )
2004-03-08 07:17:15 +00:00
{
NTSTATUS status ;
2004-10-28 21:48:53 +00:00
PASS_THRU_REQ ( ntvfs , req , trans , trans2 , ( ntvfs , req , trans2 ) ) ;
2004-03-08 07:17:15 +00:00
return status ;
}
/*
initialise the nbench backend , registering ourselves with the ntvfs subsystem
*/
NTSTATUS ntvfs_nbench_init ( void )
{
NTSTATUS ret ;
struct ntvfs_ops ops ;
ZERO_STRUCT ( ops ) ;
/* fill in the name and type */
ops . name = " nbench " ;
ops . type = NTVFS_DISK ;
/* fill in all the operations */
ops . connect = nbench_connect ;
ops . disconnect = nbench_disconnect ;
ops . unlink = nbench_unlink ;
ops . chkpath = nbench_chkpath ;
ops . qpathinfo = nbench_qpathinfo ;
ops . setpathinfo = nbench_setpathinfo ;
2006-03-10 14:31:17 +00:00
ops . open = nbench_open ;
2004-03-08 07:17:15 +00:00
ops . mkdir = nbench_mkdir ;
ops . rmdir = nbench_rmdir ;
ops . rename = nbench_rename ;
ops . copy = nbench_copy ;
ops . ioctl = nbench_ioctl ;
ops . read = nbench_read ;
ops . write = nbench_write ;
ops . seek = nbench_seek ;
ops . flush = nbench_flush ;
ops . close = nbench_close ;
ops . exit = nbench_exit ;
ops . lock = nbench_lock ;
ops . setfileinfo = nbench_setfileinfo ;
ops . qfileinfo = nbench_qfileinfo ;
ops . fsinfo = nbench_fsinfo ;
ops . lpq = nbench_lpq ;
ops . search_first = nbench_search_first ;
ops . search_next = nbench_search_next ;
ops . search_close = nbench_search_close ;
ops . trans = nbench_trans ;
2004-09-26 11:30:20 +00:00
ops . logoff = nbench_logoff ;
2004-10-18 13:27:22 +00:00
ops . async_setup = nbench_async_setup ;
2004-11-04 11:28:38 +00:00
ops . cancel = nbench_cancel ;
2004-03-08 07:17:15 +00:00
/* we don't register a trans2 handler as we want to be able to
log individual trans2 requests */
ops . trans2 = NULL ;
/* register ourselves with the NTVFS subsystem. */
2004-11-14 22:23:23 +00:00
ret = ntvfs_register ( & ops ) ;
2004-03-08 07:17:15 +00:00
if ( ! NT_STATUS_IS_OK ( ret ) ) {
DEBUG ( 0 , ( " Failed to register nbench backend! \n " ) ) ;
}
return ret ;
}