8743916853bf99b54832d2e1b0b4e8bfc50503d6
[amitay/samba.git] / source4 / client / cifsdd.h
1 /*
2    CIFSDD - dd for SMB.
3    Declarations and administrivia.
4
5    Copyright (C) James Peach 2005-2006
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 extern const char * const PROGNAME;
23
24 enum argtype
25 {
26         ARG_NUMERIC,
27         ARG_SIZE,
28         ARG_PATHNAME,
29         ARG_BOOL,
30 };
31
32 struct argdef
33 {
34         const char *    arg_name;
35         enum argtype    arg_type;
36         const char *    arg_help;
37
38         union
39         {
40                 BOOL            bval;
41                 uint64_t        nval;
42                 const char *    pval;
43         } arg_val;
44 };
45
46 int set_arg_argv(const char * argv);
47 void set_arg_val(const char * name, ...);
48
49 BOOL check_arg_bool(const char * name);
50 uint64_t check_arg_numeric(const char * name);
51 const char * check_arg_pathname(const char * name);
52
53 typedef BOOL (*dd_seek_func)(void * handle, uint64_t offset);
54 typedef BOOL (*dd_read_func)(void * handle, uint8_t * buf,
55                                 uint64_t wanted, uint64_t * actual);
56 typedef BOOL (*dd_write_func)(void * handle, uint8_t * buf,
57                                 uint64_t wanted, uint64_t * actual);
58
59 struct dd_stats_record
60 {
61         struct
62         {
63                 uint64_t        fblocks;        /* Full blocks. */
64                 uint64_t        pblocks;        /* Partial blocks. */
65                 uint64_t        bytes;          /* Total bytes read. */
66         } in;
67         struct
68         {
69                 uint64_t        fblocks;        /* Full blocks. */
70                 uint64_t        pblocks;        /* Partial blocks. */
71                 uint64_t        bytes;          /* Total bytes written. */
72         } out;
73 };
74
75 extern struct dd_stats_record dd_stats;
76
77 struct dd_iohandle
78 {
79         dd_seek_func    io_seek;
80         dd_read_func    io_read;
81         dd_write_func   io_write;
82         int             io_flags;
83 };
84
85 #define DD_END_OF_FILE          0x10000000
86
87 #define DD_DIRECT_IO            0x00000001
88 #define DD_SYNC_IO              0x00000002
89 #define DD_WRITE                0x00000004
90 #define DD_OPLOCK               0x00000008
91
92 struct dd_iohandle * dd_open_path(const char * path,
93                                 uint64_t io_size, int options);
94 BOOL dd_fill_block(struct dd_iohandle * h, uint8_t * buf,
95                 uint64_t * buf_size, uint64_t need_size, uint64_t block_size);
96 BOOL dd_flush_block(struct dd_iohandle * h, uint8_t * buf,
97                 uint64_t * buf_size, uint64_t block_size);
98
99 /* vim: set sw=8 sts=8 ts=8 tw=79 : */