opdump.c revision 1.5 1 1.5 pooka /* $NetBSD: opdump.c,v 1.5 2006/11/07 22:10:53 pooka Exp $ */
2 1.1 pooka
3 1.1 pooka /*
4 1.1 pooka * Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
5 1.1 pooka *
6 1.1 pooka * Development of this software was supported by the
7 1.1 pooka * Google Summer of Code program and the Ulla Tuominen Foundation.
8 1.1 pooka * The Google SoC project was mentored by Bill Studenmund.
9 1.1 pooka *
10 1.1 pooka * Redistribution and use in source and binary forms, with or without
11 1.1 pooka * modification, are permitted provided that the following conditions
12 1.1 pooka * are met:
13 1.1 pooka * 1. Redistributions of source code must retain the above copyright
14 1.1 pooka * notice, this list of conditions and the following disclaimer.
15 1.1 pooka * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 pooka * notice, this list of conditions and the following disclaimer in the
17 1.1 pooka * documentation and/or other materials provided with the distribution.
18 1.1 pooka * 3. The name of the company nor the name of the author may be used to
19 1.1 pooka * endorse or promote products derived from this software without specific
20 1.1 pooka * prior written permission.
21 1.1 pooka *
22 1.1 pooka * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
23 1.1 pooka * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 1.1 pooka * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 1.1 pooka * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26 1.1 pooka * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 1.1 pooka * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 1.1 pooka * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.1 pooka * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.1 pooka * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.1 pooka * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.1 pooka * SUCH DAMAGE.
33 1.1 pooka */
34 1.1 pooka
35 1.1 pooka /* Pretty-printing helper routines for VFS/VOP request contents */
36 1.1 pooka
37 1.1 pooka #include <sys/cdefs.h>
38 1.1 pooka #if !defined(lint)
39 1.5 pooka __RCSID("$NetBSD: opdump.c,v 1.5 2006/11/07 22:10:53 pooka Exp $");
40 1.1 pooka #endif /* !lint */
41 1.1 pooka
42 1.1 pooka #include <puffs.h>
43 1.1 pooka #include <puffsdump.h>
44 1.1 pooka #include <stdio.h>
45 1.1 pooka
46 1.1 pooka /* XXX! */
47 1.4 pooka const char *vfsop_revmap[] = {
48 1.4 pooka "PUFFS_VFS_MOUNT",
49 1.4 pooka "PUFFS_VFS_START",
50 1.4 pooka "PUFFS_VFS_UNMOUNT",
51 1.4 pooka "PUFFS_VFS_ROOT",
52 1.4 pooka "PUFFS_VFS_STATVFS",
53 1.4 pooka "PUFFS_VFS_SYNC",
54 1.4 pooka "PUFFS_VFS_VGET",
55 1.4 pooka "PUFFS_VFS_FHTOVP",
56 1.4 pooka "PUFFS_VFS_VPTOFH",
57 1.4 pooka "PUFFS_VFS_INIT",
58 1.4 pooka "PUFFS_VFS_DONE",
59 1.4 pooka "PUFFS_VFS_SNAPSHOT",
60 1.4 pooka "PUFFS_VFS_EXTATTCTL"
61 1.4 pooka };
62 1.4 pooka /* XXX! */
63 1.1 pooka const char *vnop_revmap[] = {
64 1.4 pooka "PUFFS_VN_LOOKUP",
65 1.4 pooka "PUFFS_VN_CREATE",
66 1.4 pooka "PUFFS_VN_MKNOD",
67 1.4 pooka "PUFFS_VN_OPEN",
68 1.4 pooka "PUFFS_VN_CLOSE",
69 1.4 pooka "PUFFS_VN_ACCESS",
70 1.4 pooka "PUFFS_VN_GETATTR",
71 1.4 pooka "PUFFS_VN_SETATTR",
72 1.4 pooka "PUFFS_VN_READ",
73 1.4 pooka "PUFFS_VN_WRITE",
74 1.4 pooka "PUFFS_VN_IOCTL",
75 1.4 pooka "PUFFS_VN_FCNTL",
76 1.4 pooka "PUFFS_VN_POLL",
77 1.4 pooka "PUFFS_VN_KQFILTER",
78 1.4 pooka "PUFFS_VN_REVOKE",
79 1.4 pooka "PUFFS_VN_MMAP",
80 1.4 pooka "PUFFS_VN_FSYNC",
81 1.4 pooka "PUFFS_VN_SEEK",
82 1.4 pooka "PUFFS_VN_REMOVE",
83 1.4 pooka "PUFFS_VN_LINK",
84 1.4 pooka "PUFFS_VN_RENAME",
85 1.4 pooka "PUFFS_VN_MKDIR",
86 1.4 pooka "PUFFS_VN_RMDIR",
87 1.4 pooka "PUFFS_VN_SYMLINK",
88 1.4 pooka "PUFFS_VN_READDIR",
89 1.4 pooka "PUFFS_VN_READLINK",
90 1.4 pooka "PUFFS_VN_ABORTOP",
91 1.4 pooka "PUFFS_VN_INACTIVE",
92 1.4 pooka "PUFFS_VN_RECLAIM",
93 1.4 pooka "PUFFS_VN_LOCK",
94 1.4 pooka "PUFFS_VN_UNLOCK",
95 1.4 pooka "PUFFS_VN_BMAP",
96 1.4 pooka "PUFFS_VN_STRATEGY",
97 1.4 pooka "PUFFS_VN_PRINT",
98 1.4 pooka "PUFFS_VN_ISLOCKED",
99 1.4 pooka "PUFFS_VN_PATHCONF",
100 1.4 pooka "PUFFS_VN_ADVLOCK",
101 1.4 pooka "PUFFS_VN_LEASE",
102 1.4 pooka "PUFFS_VN_WHITEOUT",
103 1.4 pooka "PUFFS_VN_GETPAGES",
104 1.4 pooka "PUFFS_VN_PUTPAGES",
105 1.4 pooka "PUFFS_VN_BWRITE",
106 1.4 pooka "PUFFS_VN_GETEXTATTR",
107 1.4 pooka "PUFFS_VN_LISTEXTATTR",
108 1.4 pooka "PUFFS_VN_OPENEXTATTR",
109 1.4 pooka "PUFFS_VN_DELETEEXTATTR",
110 1.4 pooka "PUFFS_VN_SETEXTATTR",
111 1.1 pooka };
112 1.1 pooka
113 1.1 pooka void
114 1.1 pooka puffsdump_req(struct puffs_req *preq)
115 1.1 pooka {
116 1.4 pooka const char **map;
117 1.1 pooka
118 1.5 pooka map = PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VFS
119 1.5 pooka ? vfsop_revmap : vnop_revmap;
120 1.5 pooka printf("\treqid: %" PRIuFAST64 ", opclass %d%s, optype: %s, "
121 1.5 pooka "cookie: %p,\n\t\taux: %p, auxlen: %zu\n",
122 1.5 pooka preq->preq_id, PUFFSOP_OPCLASS(preq->preq_opclass),
123 1.5 pooka PUFFSOP_WANTREPLY(preq->preq_opclass) ? "" : " (FAF)",
124 1.5 pooka map[preq->preq_optype], preq->preq_cookie,
125 1.5 pooka preq->preq_aux, preq->preq_auxlen);
126 1.1 pooka }
127 1.1 pooka
128 1.1 pooka void
129 1.1 pooka puffsdump_cookie(void *c, const char *cookiename)
130 1.1 pooka {
131 1.1 pooka
132 1.1 pooka printf("\t%scookie: at %p\n", cookiename, c);
133 1.1 pooka }
134 1.1 pooka
135 1.1 pooka #if 0
136 1.1 pooka static const char *cn_opnames[] = {
137 1.1 pooka "LOOKUP",
138 1.1 pooka "CREATE",
139 1.1 pooka "DELETE",
140 1.1 pooka "RENAME"
141 1.1 pooka };
142 1.1 pooka void
143 1.1 pooka puffsdump_cn(struct puffs_cn *pcn)
144 1.1 pooka {
145 1.1 pooka
146 1.1 pooka printf("\tpuffs_cn: %s (%sfollow)\n",
147 1.1 pooka cn_opnames[pcn->pcn_nameio & PUFFSLOOKUP_OPMASK],
148 1.1 pooka pcn->pcn_nameio&PUFFSLOOKUP_OPTIONS==PUFFSLOOKUP_NOFOLLOW?"no":"");
149 1.1 pooka /*
150 1.1 pooka TOFINISH
151 1.1 pooka */
152 1.1 pooka }
153 1.1 pooka #endif
154 1.1 pooka
155 1.1 pooka void
156 1.2 christos /*ARGSUSED*/
157 1.1 pooka puffsdump_creds(struct puffs_cred *pcr)
158 1.1 pooka {
159 1.1 pooka
160 1.1 pooka }
161 1.1 pooka
162 1.1 pooka void
163 1.1 pooka puffsdump_int(int value, const char *name)
164 1.1 pooka {
165 1.1 pooka
166 1.1 pooka printf("\tint (%s): %d\n", name, value);
167 1.1 pooka }
168