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