1 /* NFSv4.1 client for Windows
2  * Copyright � 2012 The Regents of the University of Michigan
3  *
4  * Olga Kornievskaia <aglo@umich.edu>
5  * Casey Bodley <cbodley@umich.edu>
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation; either version 2.1 of the License, or (at
10  * your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * without any warranty; without even the implied warranty of merchantability
14  * or fitness for a particular purpose.  See the GNU Lesser General Public
15  * License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  */
21 
22 #ifndef _NFS41_DEBUG_
23 #define _NFS41_DEBUG_
24 
25 #define _DRIVER_NAME_ "NFS4.1 Driver"
26 
27 ULONG __cdecl DbgP(IN PCCH fmt, ...);
28 ULONG __cdecl print_error(IN PCCH fmt, ...);
29 VOID print_fo_all(int on, IN PRX_CONTEXT c);
30 VOID print_srv_call(int on, IN PMRX_SRV_CALL p);
31 VOID print_net_root(int on, IN PMRX_NET_ROOT p);
32 VOID print_v_net_root(int on, IN PMRX_V_NET_ROOT p);
33 VOID print_fcb(int on, IN PMRX_FCB p);
34 VOID print_srv_open(int on, IN PMRX_SRV_OPEN p);
35 VOID print_fobx(int on, IN PMRX_FOBX p);
36 VOID print_irp_flags(int on, PIRP irp);
37 VOID print_irps_flags(int on, PIO_STACK_LOCATION irps);
38 void print_nt_create_params(int on, NT_CREATE_PARAMETERS params);
39 unsigned char *print_file_information_class(int InfoClass);
40 unsigned char *print_fs_information_class(int InfoClass);
41 void print_hexbuf(int on, unsigned char *title, unsigned char *buf, int len);
42 void print_ioctl(int on, int op);
43 void print_fs_ioctl(int on, int op);
44 void print_driver_state(int state);
45 void print_file_object(int on, PFILE_OBJECT file);
46 void print_basic_info(int on, PFILE_BASIC_INFORMATION info);
47 void print_std_info(int on, PFILE_STANDARD_INFORMATION info);
48 void print_ea_info(int on, PFILE_FULL_EA_INFORMATION info);
49 void print_get_ea(int on, PFILE_GET_EA_INFORMATION info);
50 void print_caching_level(int on, ULONG flag, PUNICODE_STRING s);
51 const char *opcode2string(int opcode);
52 void print_open_error(int on, int status);
53 void print_wait_status(int on, const char *str, NTSTATUS status,
54                        const char *opcode, PVOID entry, LONGLONG xid);
55 void print_acl_args(SECURITY_INFORMATION info);
56 
57 #define DbgEn() DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, \
58         "--> [%s] [%04x] %s\n", _DRIVER_NAME_, PsGetCurrentProcessId(), \
59         __FUNCTION__); _SEH2_TRY {
60 
61 #define DbgEx() DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, \
62         "<-- [%s] [%04x] %s status = %08lx\n", _DRIVER_NAME_, PsGetCurrentProcessId(), \
63         __FUNCTION__, status); \
64         } _SEH2_EXCEPT (EXCEPTION_EXECUTE_HANDLER) { \
65             status = _SEH2_GetExceptionCode() ; \
66             DbgP("Exception encountered with value = Ox%x\n", status); \
67         } _SEH2_END;
68 #define DbgR() DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, \
69         "<-- [%s] [%04x] %s\n", _DRIVER_NAME_, PsGetCurrentProcessId(), __FUNCTION__); \
70         } _SEH2_EXCEPT (EXCEPTION_EXECUTE_HANDLER) { \
71             NTSTATUS status; \
72             status = _SEH2_GetExceptionCode() ; \
73             DbgP("Exception encountered with value = Ox%x\n", status); \
74         } _SEH2_END;
75 
76 /* These are for ToasterDebugPrint */
77 
78 #define     DBG_ERROR       0x00000001
79 #define     DBG_WARN        0x00000002
80 #define     DBG_TRACE       0x00000004
81 #define     DBG_INFO        0x00000008
82 #define     DBG_DISP_IN     0x00000010 /* Marks entry into dispatch functions */
83 #define     DBG_DISP_OUT    0x00000020 /* Marks exit from dispatch functions */
84 
85 /* I want to do:
86  * #define dprintk(flags, args...) DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_MASK | flags, ## args)
87  * but the ... is gcc specific, can't seem to do it here.
88  */
89 #define PNFS_TRACE_TAG      "PNFSMRX: "
90 #define PNFS_FLTR_ID        DPFLTR_IHVDRIVER_ID
91 
92 #define DbgEnter()      DbgPrintEx(PNFS_FLTR_ID, DPFLTR_MASK | DBG_DISP_IN, "%s*** %s ***\n", \
93                                 PNFS_TRACE_TAG, __FUNCTION__);
94 #define DbgExit(status) DbgPrintEx(PNFS_FLTR_ID, DPFLTR_MASK | DBG_DISP_OUT, "%s<-- %s <-- 0x%08lx\n", \
95                                 PNFS_TRACE_TAG, __FUNCTION__, status);
96 ULONG
97 dprintk(
98     IN PCHAR func,
99     IN ULONG flags,
100     IN PCHAR format,
101     ...);
102 #endif
103