1*0a6a1f1dSLionel Sambuc /* $NetBSD: opdump.c,v 1.37 2014/10/31 13:56:04 manu Exp $ */
284d9c625SLionel Sambuc
384d9c625SLionel Sambuc /*
484d9c625SLionel Sambuc * Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
584d9c625SLionel Sambuc *
684d9c625SLionel Sambuc * Development of this software was supported by the
784d9c625SLionel Sambuc * Google Summer of Code program and the Ulla Tuominen Foundation.
884d9c625SLionel Sambuc * The Google SoC project was mentored by Bill Studenmund.
984d9c625SLionel Sambuc *
1084d9c625SLionel Sambuc * Redistribution and use in source and binary forms, with or without
1184d9c625SLionel Sambuc * modification, are permitted provided that the following conditions
1284d9c625SLionel Sambuc * are met:
1384d9c625SLionel Sambuc * 1. Redistributions of source code must retain the above copyright
1484d9c625SLionel Sambuc * notice, this list of conditions and the following disclaimer.
1584d9c625SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
1684d9c625SLionel Sambuc * notice, this list of conditions and the following disclaimer in the
1784d9c625SLionel Sambuc * documentation and/or other materials provided with the distribution.
1884d9c625SLionel Sambuc *
1984d9c625SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
2084d9c625SLionel Sambuc * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2184d9c625SLionel Sambuc * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2284d9c625SLionel Sambuc * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2384d9c625SLionel Sambuc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2484d9c625SLionel Sambuc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2584d9c625SLionel Sambuc * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2684d9c625SLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2784d9c625SLionel Sambuc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2884d9c625SLionel Sambuc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2984d9c625SLionel Sambuc * SUCH DAMAGE.
3084d9c625SLionel Sambuc */
3184d9c625SLionel Sambuc
3284d9c625SLionel Sambuc /* Pretty-printing helper routines for VFS/VOP request contents */
3384d9c625SLionel Sambuc
3484d9c625SLionel Sambuc /* yes, this is pretty much a mess */
3584d9c625SLionel Sambuc
3684d9c625SLionel Sambuc #include <sys/cdefs.h>
3784d9c625SLionel Sambuc #if !defined(lint)
38*0a6a1f1dSLionel Sambuc __RCSID("$NetBSD: opdump.c,v 1.37 2014/10/31 13:56:04 manu Exp $");
3984d9c625SLionel Sambuc #endif /* !lint */
4084d9c625SLionel Sambuc
4184d9c625SLionel Sambuc #include <sys/types.h>
4284d9c625SLionel Sambuc #include <sys/time.h>
4384d9c625SLionel Sambuc
4484d9c625SLionel Sambuc #include <puffs.h>
4584d9c625SLionel Sambuc #include <puffsdump.h>
4684d9c625SLionel Sambuc #include <stdarg.h>
4784d9c625SLionel Sambuc #include <stdio.h>
4884d9c625SLionel Sambuc
4984d9c625SLionel Sambuc #include "puffs_priv.h"
5084d9c625SLionel Sambuc
5184d9c625SLionel Sambuc #define DINT " "
5284d9c625SLionel Sambuc
5384d9c625SLionel Sambuc const char *puffsdump_vfsop_revmap[] = {
5484d9c625SLionel Sambuc "PUFFS_VFS_MOUNT",
5584d9c625SLionel Sambuc "PUFFS_VFS_START",
5684d9c625SLionel Sambuc "PUFFS_VFS_UNMOUNT",
5784d9c625SLionel Sambuc "PUFFS_VFS_ROOT",
5884d9c625SLionel Sambuc "PUFFS_VFS_QUOTACTL",
5984d9c625SLionel Sambuc "PUFFS_VFS_STATVFS",
6084d9c625SLionel Sambuc "PUFFS_VFS_SYNC",
6184d9c625SLionel Sambuc "PUFFS_VFS_VGET",
6284d9c625SLionel Sambuc "PUFFS_VFS_FHTOVP",
6384d9c625SLionel Sambuc "PUFFS_VFS_VPTOFH",
6484d9c625SLionel Sambuc "PUFFS_VFS_INIT",
6584d9c625SLionel Sambuc "PUFFS_VFS_DONE",
6684d9c625SLionel Sambuc "PUFFS_VFS_SNAPSHOT",
6784d9c625SLionel Sambuc "PUFFS_VFS_EXTATTRCTL",
6884d9c625SLionel Sambuc "PUFFS_VFS_SUSPEND"
6984d9c625SLionel Sambuc };
7084d9c625SLionel Sambuc size_t puffsdump_vfsop_count = __arraycount(puffsdump_vfsop_revmap);
7184d9c625SLionel Sambuc
7284d9c625SLionel Sambuc const char *puffsdump_vnop_revmap[] = {
7384d9c625SLionel Sambuc "PUFFS_VN_LOOKUP",
7484d9c625SLionel Sambuc "PUFFS_VN_CREATE",
7584d9c625SLionel Sambuc "PUFFS_VN_MKNOD",
7684d9c625SLionel Sambuc "PUFFS_VN_OPEN",
7784d9c625SLionel Sambuc "PUFFS_VN_CLOSE",
7884d9c625SLionel Sambuc "PUFFS_VN_ACCESS",
7984d9c625SLionel Sambuc "PUFFS_VN_GETATTR",
8084d9c625SLionel Sambuc "PUFFS_VN_SETATTR",
8184d9c625SLionel Sambuc "PUFFS_VN_READ",
8284d9c625SLionel Sambuc "PUFFS_VN_WRITE",
8384d9c625SLionel Sambuc "PUFFS_VN_IOCTL",
8484d9c625SLionel Sambuc "PUFFS_VN_FCNTL",
8584d9c625SLionel Sambuc "PUFFS_VN_POLL",
8684d9c625SLionel Sambuc "PUFFS_VN_KQFILTER",
8784d9c625SLionel Sambuc "PUFFS_VN_REVOKE",
8884d9c625SLionel Sambuc "PUFFS_VN_MMAP",
8984d9c625SLionel Sambuc "PUFFS_VN_FSYNC",
9084d9c625SLionel Sambuc "PUFFS_VN_SEEK",
9184d9c625SLionel Sambuc "PUFFS_VN_REMOVE",
9284d9c625SLionel Sambuc "PUFFS_VN_LINK",
9384d9c625SLionel Sambuc "PUFFS_VN_RENAME",
9484d9c625SLionel Sambuc "PUFFS_VN_MKDIR",
9584d9c625SLionel Sambuc "PUFFS_VN_RMDIR",
9684d9c625SLionel Sambuc "PUFFS_VN_SYMLINK",
9784d9c625SLionel Sambuc "PUFFS_VN_READDIR",
9884d9c625SLionel Sambuc "PUFFS_VN_READLINK",
9984d9c625SLionel Sambuc "PUFFS_VN_ABORTOP",
10084d9c625SLionel Sambuc "PUFFS_VN_INACTIVE",
10184d9c625SLionel Sambuc "PUFFS_VN_RECLAIM",
10284d9c625SLionel Sambuc "PUFFS_VN_LOCK",
10384d9c625SLionel Sambuc "PUFFS_VN_UNLOCK",
10484d9c625SLionel Sambuc "PUFFS_VN_BMAP",
10584d9c625SLionel Sambuc "PUFFS_VN_STRATEGY",
10684d9c625SLionel Sambuc "PUFFS_VN_PRINT",
10784d9c625SLionel Sambuc "PUFFS_VN_ISLOCKED",
10884d9c625SLionel Sambuc "PUFFS_VN_PATHCONF",
10984d9c625SLionel Sambuc "PUFFS_VN_ADVLOCK",
11084d9c625SLionel Sambuc "PUFFS_VN_LEASE",
11184d9c625SLionel Sambuc "PUFFS_VN_WHITEOUT",
11284d9c625SLionel Sambuc "PUFFS_VN_GETPAGES",
11384d9c625SLionel Sambuc "PUFFS_VN_PUTPAGES",
11484d9c625SLionel Sambuc "PUFFS_VN_GETEXTATTR",
11584d9c625SLionel Sambuc "PUFFS_VN_LISTEXTATTR",
11684d9c625SLionel Sambuc "PUFFS_VN_OPENEXTATTR",
11784d9c625SLionel Sambuc "PUFFS_VN_DELETEEXTATTR",
11884d9c625SLionel Sambuc "PUFFS_VN_SETEXTATTR",
11984d9c625SLionel Sambuc "PUFFS_VN_CLOSEEXTATTR",
120*0a6a1f1dSLionel Sambuc "PUFFS_VN_FALLOCATE",
121*0a6a1f1dSLionel Sambuc "PUFFS_VN_FDISCARD",
12284d9c625SLionel Sambuc };
12384d9c625SLionel Sambuc size_t puffsdump_vnop_count = __arraycount(puffsdump_vnop_revmap);
12484d9c625SLionel Sambuc
12584d9c625SLionel Sambuc /* XXX! */
12684d9c625SLionel Sambuc const char *puffsdump_cacheop_revmap[] = {
12784d9c625SLionel Sambuc "PUFFS_CACHE_WRITE"
12884d9c625SLionel Sambuc };
12984d9c625SLionel Sambuc
13084d9c625SLionel Sambuc const char *puffsdump_errnot_revmap[] = {
13184d9c625SLionel Sambuc "PUFFS_ERR_ERROR",
13284d9c625SLionel Sambuc "PUFFS_ERR_MAKENODE",
13384d9c625SLionel Sambuc "PUFFS_ERR_LOOKUP",
13484d9c625SLionel Sambuc "PUFFS_ERR_READDIR",
13584d9c625SLionel Sambuc "PUFFS_ERR_READLINK",
13684d9c625SLionel Sambuc "PUFFS_ERR_READ",
13784d9c625SLionel Sambuc "PUFFS_ERR_WRITE",
13884d9c625SLionel Sambuc "PUFFS_ERR_VPTOFH",
13984d9c625SLionel Sambuc "PUFFS_ERR_GETEXTATTR",
14084d9c625SLionel Sambuc "PUFFS_ERR_LISTEXTATTR",
14184d9c625SLionel Sambuc };
14284d9c625SLionel Sambuc size_t puffsdump_errnot_count = __arraycount(puffsdump_errnot_revmap);
14384d9c625SLionel Sambuc
14484d9c625SLionel Sambuc const char *puffsdump_flush_revmap[] = {
14584d9c625SLionel Sambuc "PUFFS_INVAL_NAMECACHE_NODE",
14684d9c625SLionel Sambuc "PUFFS_INVAL_NAMECACHE_DIR",
14784d9c625SLionel Sambuc "PUFFS_INVAL_NAMECACHE_ALL",
14884d9c625SLionel Sambuc "PUFFS_INVAL_PAGECACHE_NODE_RANGE",
14984d9c625SLionel Sambuc "PUFFS_FLUSH_PAGECACHE_NODE_RANGE",
15084d9c625SLionel Sambuc };
15184d9c625SLionel Sambuc size_t puffsdump_flush_count = __arraycount(puffsdump_flush_revmap);
15284d9c625SLionel Sambuc
15384d9c625SLionel Sambuc static __printflike(1, 2) void
mydprintf(const char * fmt,...)15484d9c625SLionel Sambuc mydprintf(const char *fmt, ...)
15584d9c625SLionel Sambuc {
15684d9c625SLionel Sambuc va_list ap;
15784d9c625SLionel Sambuc
15884d9c625SLionel Sambuc va_start(ap, fmt);
15984d9c625SLionel Sambuc vfprintf(stderr, fmt, ap);
16084d9c625SLionel Sambuc va_end(ap);
16184d9c625SLionel Sambuc }
16284d9c625SLionel Sambuc
16384d9c625SLionel Sambuc void
puffsdump_req(struct puffs_req * preq)16484d9c625SLionel Sambuc puffsdump_req(struct puffs_req *preq)
16584d9c625SLionel Sambuc {
16684d9c625SLionel Sambuc char buf[128];
16784d9c625SLionel Sambuc static struct timeval tv_prev;
16884d9c625SLionel Sambuc struct timeval tv_now, tv;
16984d9c625SLionel Sambuc const char **map;
17084d9c625SLionel Sambuc const char *optype;
17184d9c625SLionel Sambuc size_t maxhandle;
17284d9c625SLionel Sambuc int opclass, isvn = 0;
17384d9c625SLionel Sambuc
17484d9c625SLionel Sambuc mydprintf("reqid: %" PRIu64 ", ", preq->preq_id);
17584d9c625SLionel Sambuc opclass = PUFFSOP_OPCLASS(preq->preq_opclass);
17684d9c625SLionel Sambuc switch (opclass) {
17784d9c625SLionel Sambuc case PUFFSOP_VFS:
17884d9c625SLionel Sambuc map = puffsdump_vfsop_revmap;
17984d9c625SLionel Sambuc maxhandle = puffsdump_vfsop_count;
18084d9c625SLionel Sambuc break;
18184d9c625SLionel Sambuc case PUFFSOP_VN:
18284d9c625SLionel Sambuc map = puffsdump_vnop_revmap;
18384d9c625SLionel Sambuc maxhandle = puffsdump_vnop_count;
18484d9c625SLionel Sambuc isvn = 1;
18584d9c625SLionel Sambuc break;
18684d9c625SLionel Sambuc case PUFFSOP_CACHE:
18784d9c625SLionel Sambuc map = puffsdump_cacheop_revmap;
18884d9c625SLionel Sambuc maxhandle = __arraycount(puffsdump_cacheop_revmap);
18984d9c625SLionel Sambuc break;
19084d9c625SLionel Sambuc case PUFFSOP_ERROR:
19184d9c625SLionel Sambuc map = puffsdump_errnot_revmap;
19284d9c625SLionel Sambuc maxhandle = puffsdump_errnot_count;
19384d9c625SLionel Sambuc break;
19484d9c625SLionel Sambuc case PUFFSOP_FLUSH:
19584d9c625SLionel Sambuc map = puffsdump_flush_revmap;
19684d9c625SLionel Sambuc maxhandle = puffsdump_flush_count;
19784d9c625SLionel Sambuc break;
19884d9c625SLionel Sambuc default:
19984d9c625SLionel Sambuc mydprintf("unhandled opclass %d\n", opclass);
20084d9c625SLionel Sambuc return;
20184d9c625SLionel Sambuc }
20284d9c625SLionel Sambuc
20384d9c625SLionel Sambuc if (preq->preq_optype < maxhandle) {
20484d9c625SLionel Sambuc optype = map[preq->preq_optype];
20584d9c625SLionel Sambuc } else {
20684d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "UNKNOWN (%d)", preq->preq_optype);
20784d9c625SLionel Sambuc optype = buf;
20884d9c625SLionel Sambuc }
20984d9c625SLionel Sambuc
21084d9c625SLionel Sambuc mydprintf("opclass %d%s, optype: %s, "
21184d9c625SLionel Sambuc "cookie: %p,\n" DINT "aux: %p, auxlen: %zu, pid: %d, lwpid: %d\n",
21284d9c625SLionel Sambuc opclass, PUFFSOP_WANTREPLY(preq->preq_opclass) ? "" : " (FAF)",
21384d9c625SLionel Sambuc optype, preq->preq_cookie,
21484d9c625SLionel Sambuc preq->preq_buf, preq->preq_buflen,
21584d9c625SLionel Sambuc preq->preq_pid, preq->preq_lid);
21684d9c625SLionel Sambuc
21784d9c625SLionel Sambuc if (isvn) {
21884d9c625SLionel Sambuc switch (preq->preq_optype) {
21984d9c625SLionel Sambuc case PUFFS_VN_LOOKUP:
22084d9c625SLionel Sambuc puffsdump_lookup(preq);
22184d9c625SLionel Sambuc break;
22284d9c625SLionel Sambuc case PUFFS_VN_READ:
22384d9c625SLionel Sambuc case PUFFS_VN_WRITE:
22484d9c625SLionel Sambuc puffsdump_readwrite(preq);
22584d9c625SLionel Sambuc break;
22684d9c625SLionel Sambuc case PUFFS_VN_OPEN:
22784d9c625SLionel Sambuc puffsdump_open(preq);
22884d9c625SLionel Sambuc break;
22984d9c625SLionel Sambuc case PUFFS_VN_REMOVE:
23084d9c625SLionel Sambuc case PUFFS_VN_RMDIR:
23184d9c625SLionel Sambuc case PUFFS_VN_LINK:
23284d9c625SLionel Sambuc puffsdump_targ(preq);
23384d9c625SLionel Sambuc break;
23484d9c625SLionel Sambuc case PUFFS_VN_READDIR:
23584d9c625SLionel Sambuc puffsdump_readdir(preq);
23684d9c625SLionel Sambuc break;
23784d9c625SLionel Sambuc case PUFFS_VN_CREATE:
23884d9c625SLionel Sambuc case PUFFS_VN_MKDIR:
23984d9c625SLionel Sambuc case PUFFS_VN_MKNOD:
24084d9c625SLionel Sambuc case PUFFS_VN_SYMLINK:
24184d9c625SLionel Sambuc puffsdump_create(preq);
24284d9c625SLionel Sambuc break;
24384d9c625SLionel Sambuc case PUFFS_VN_SETATTR:
24484d9c625SLionel Sambuc puffsdump_attr(preq);
24584d9c625SLionel Sambuc break;
24684d9c625SLionel Sambuc default:
24784d9c625SLionel Sambuc break;
24884d9c625SLionel Sambuc }
24984d9c625SLionel Sambuc }
25084d9c625SLionel Sambuc
25184d9c625SLionel Sambuc PU_LOCK();
25284d9c625SLionel Sambuc gettimeofday(&tv_now, NULL);
25384d9c625SLionel Sambuc timersub(&tv_now, &tv_prev, &tv);
25484d9c625SLionel Sambuc mydprintf(DINT "since previous call: %lld.%06ld\n",
25584d9c625SLionel Sambuc (long long)tv.tv_sec, (long)tv.tv_usec);
25684d9c625SLionel Sambuc gettimeofday(&tv_prev, NULL);
25784d9c625SLionel Sambuc PU_UNLOCK();
25884d9c625SLionel Sambuc }
25984d9c625SLionel Sambuc
26084d9c625SLionel Sambuc void
puffsdump_rv(struct puffs_req * preq)26184d9c625SLionel Sambuc puffsdump_rv(struct puffs_req *preq)
26284d9c625SLionel Sambuc {
26384d9c625SLionel Sambuc
26484d9c625SLionel Sambuc if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VN) {
26584d9c625SLionel Sambuc switch (preq->preq_optype) {
26684d9c625SLionel Sambuc case PUFFS_VN_LOOKUP:
26784d9c625SLionel Sambuc puffsdump_lookup_rv(preq);
26884d9c625SLionel Sambuc break;
26984d9c625SLionel Sambuc case PUFFS_VN_CREATE:
27084d9c625SLionel Sambuc case PUFFS_VN_MKDIR:
27184d9c625SLionel Sambuc case PUFFS_VN_MKNOD:
27284d9c625SLionel Sambuc case PUFFS_VN_SYMLINK:
27384d9c625SLionel Sambuc puffsdump_create_rv(preq);
27484d9c625SLionel Sambuc break;
27584d9c625SLionel Sambuc case PUFFS_VN_READ:
27684d9c625SLionel Sambuc case PUFFS_VN_WRITE:
27784d9c625SLionel Sambuc puffsdump_readwrite_rv(preq);
27884d9c625SLionel Sambuc break;
27984d9c625SLionel Sambuc case PUFFS_VN_READDIR:
28084d9c625SLionel Sambuc puffsdump_readdir_rv(preq);
28184d9c625SLionel Sambuc break;
28284d9c625SLionel Sambuc case PUFFS_VN_GETATTR:
28384d9c625SLionel Sambuc puffsdump_attr(preq);
28484d9c625SLionel Sambuc break;
28584d9c625SLionel Sambuc default:
28684d9c625SLionel Sambuc break;
28784d9c625SLionel Sambuc }
28884d9c625SLionel Sambuc }
28984d9c625SLionel Sambuc
29084d9c625SLionel Sambuc mydprintf("RV reqid: %" PRIu64 ", result: %d %s\n",
29184d9c625SLionel Sambuc preq->preq_id, preq->preq_rv,
29284d9c625SLionel Sambuc preq->preq_rv ? strerror(preq->preq_rv) : "");
29384d9c625SLionel Sambuc }
29484d9c625SLionel Sambuc
29584d9c625SLionel Sambuc /*
29684d9c625SLionel Sambuc * Slightly tedious print-routine so that we get a nice NOVAL instead
29784d9c625SLionel Sambuc * of some tedious output representations for -1, especially (uint64_t)-1
29884d9c625SLionel Sambuc *
29984d9c625SLionel Sambuc * We use typecasting to make this work beyond time_t/dev_t size changes.
30084d9c625SLionel Sambuc */
30184d9c625SLionel Sambuc static void
dumpattr(struct vattr * vap)30284d9c625SLionel Sambuc dumpattr(struct vattr *vap)
30384d9c625SLionel Sambuc {
30484d9c625SLionel Sambuc const char * const vtypes[] = { VNODE_TYPES };
30584d9c625SLionel Sambuc char buf[128];
30684d9c625SLionel Sambuc
30784d9c625SLionel Sambuc /* XXX: better readability. and this is debug, so no cycle-sweat */
30884d9c625SLionel Sambuc #define DEFAULTBUF() snprintf(buf, sizeof(buf), "NOVAL")
30984d9c625SLionel Sambuc
31084d9c625SLionel Sambuc mydprintf(DINT "vattr:\n");
31184d9c625SLionel Sambuc mydprintf(DINT DINT "type: %s, ", vtypes[vap->va_type]);
31284d9c625SLionel Sambuc
31384d9c625SLionel Sambuc DEFAULTBUF();
31484d9c625SLionel Sambuc if (vap->va_mode != (mode_t)PUFFS_VNOVAL)
31584d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "0%o", vap->va_mode);
31684d9c625SLionel Sambuc mydprintf("mode: %s, ", buf);
31784d9c625SLionel Sambuc
31884d9c625SLionel Sambuc DEFAULTBUF();
31984d9c625SLionel Sambuc if (vap->va_nlink != (nlink_t)PUFFS_VNOVAL)
32084d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "%d", vap->va_nlink);
32184d9c625SLionel Sambuc mydprintf("nlink: %s, ", buf);
32284d9c625SLionel Sambuc
32384d9c625SLionel Sambuc DEFAULTBUF();
32484d9c625SLionel Sambuc if (vap->va_uid != (uid_t)PUFFS_VNOVAL)
32584d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "%d", vap->va_uid);
32684d9c625SLionel Sambuc mydprintf("uid: %s, ", buf);
32784d9c625SLionel Sambuc
32884d9c625SLionel Sambuc DEFAULTBUF();
32984d9c625SLionel Sambuc if (vap->va_gid != (gid_t)PUFFS_VNOVAL)
33084d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "%d", vap->va_gid);
33184d9c625SLionel Sambuc mydprintf("gid: %s\n", buf);
33284d9c625SLionel Sambuc
33384d9c625SLionel Sambuc DEFAULTBUF();
33484d9c625SLionel Sambuc if ((unsigned long long)vap->va_fsid!=(unsigned long long)PUFFS_VNOVAL)
33584d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "0x%llx",
33684d9c625SLionel Sambuc (unsigned long long)vap->va_fsid);
33784d9c625SLionel Sambuc mydprintf(DINT DINT "fsid: %s, ", buf);
33884d9c625SLionel Sambuc
33984d9c625SLionel Sambuc DEFAULTBUF();
34084d9c625SLionel Sambuc if (vap->va_fileid != (ino_t)PUFFS_VNOVAL)
34184d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "%" PRIu64, vap->va_fileid);
34284d9c625SLionel Sambuc mydprintf("ino: %s, ", buf);
34384d9c625SLionel Sambuc
34484d9c625SLionel Sambuc DEFAULTBUF();
34584d9c625SLionel Sambuc if (vap->va_size != (u_quad_t)PUFFS_VNOVAL)
34684d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "%" PRIu64, vap->va_size);
34784d9c625SLionel Sambuc mydprintf("size: %s, ", buf);
34884d9c625SLionel Sambuc
34984d9c625SLionel Sambuc DEFAULTBUF();
35084d9c625SLionel Sambuc if (vap->va_blocksize != (long)PUFFS_VNOVAL)
35184d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "%ld", vap->va_blocksize);
35284d9c625SLionel Sambuc mydprintf("bsize: %s\n", buf);
35384d9c625SLionel Sambuc
35484d9c625SLionel Sambuc DEFAULTBUF();
35584d9c625SLionel Sambuc if (vap->va_atime.tv_sec != (time_t)PUFFS_VNOVAL)
35684d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "%lld",
35784d9c625SLionel Sambuc (long long)vap->va_atime.tv_sec);
35884d9c625SLionel Sambuc mydprintf(DINT DINT "a.s: %s, ", buf);
35984d9c625SLionel Sambuc
36084d9c625SLionel Sambuc DEFAULTBUF();
36184d9c625SLionel Sambuc if (vap->va_atime.tv_nsec != (long)PUFFS_VNOVAL)
36284d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "%ld", vap->va_atime.tv_nsec);
36384d9c625SLionel Sambuc mydprintf("a.ns: %s, ", buf);
36484d9c625SLionel Sambuc
36584d9c625SLionel Sambuc DEFAULTBUF();
36684d9c625SLionel Sambuc if (vap->va_mtime.tv_sec != (time_t)PUFFS_VNOVAL)
36784d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "%lld",
36884d9c625SLionel Sambuc (long long)vap->va_mtime.tv_sec);
36984d9c625SLionel Sambuc mydprintf("m.s: %s, ", buf);
37084d9c625SLionel Sambuc
37184d9c625SLionel Sambuc DEFAULTBUF();
37284d9c625SLionel Sambuc if (vap->va_mtime.tv_nsec != (long)PUFFS_VNOVAL)
37384d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "%ld", vap->va_mtime.tv_nsec);
37484d9c625SLionel Sambuc mydprintf("m.ns: %s\n", buf);
37584d9c625SLionel Sambuc
37684d9c625SLionel Sambuc DEFAULTBUF();
37784d9c625SLionel Sambuc if (vap->va_ctime.tv_sec != (time_t)PUFFS_VNOVAL)
37884d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "%lld",
37984d9c625SLionel Sambuc (long long)vap->va_ctime.tv_sec);
38084d9c625SLionel Sambuc mydprintf(DINT DINT "c.s: %s, ", buf);
38184d9c625SLionel Sambuc
38284d9c625SLionel Sambuc DEFAULTBUF();
38384d9c625SLionel Sambuc if (vap->va_ctime.tv_nsec != (long)PUFFS_VNOVAL)
38484d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "%ld", vap->va_ctime.tv_nsec);
38584d9c625SLionel Sambuc mydprintf("c.ns: %s, ", buf);
38684d9c625SLionel Sambuc
38784d9c625SLionel Sambuc DEFAULTBUF();
38884d9c625SLionel Sambuc if (vap->va_birthtime.tv_sec != (time_t)PUFFS_VNOVAL)
38984d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "%lld",
39084d9c625SLionel Sambuc (long long)vap->va_birthtime.tv_sec);
39184d9c625SLionel Sambuc mydprintf("b.s: %s, ", buf);
39284d9c625SLionel Sambuc
39384d9c625SLionel Sambuc DEFAULTBUF();
39484d9c625SLionel Sambuc if (vap->va_birthtime.tv_nsec != (long)PUFFS_VNOVAL)
39584d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "%ld", vap->va_birthtime.tv_nsec);
39684d9c625SLionel Sambuc mydprintf("b.ns: %s\n", buf);
39784d9c625SLionel Sambuc
39884d9c625SLionel Sambuc DEFAULTBUF();
39984d9c625SLionel Sambuc if (vap->va_gen != (u_long)PUFFS_VNOVAL)
40084d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "%lu", vap->va_gen);
40184d9c625SLionel Sambuc mydprintf(DINT DINT "gen: %s, ", buf);
40284d9c625SLionel Sambuc
40384d9c625SLionel Sambuc DEFAULTBUF();
40484d9c625SLionel Sambuc if (vap->va_flags != (u_long)PUFFS_VNOVAL)
40584d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "0x%lx", vap->va_flags);
40684d9c625SLionel Sambuc mydprintf("flags: %s, ", buf);
40784d9c625SLionel Sambuc
40884d9c625SLionel Sambuc DEFAULTBUF();
40984d9c625SLionel Sambuc if (vap->va_rdev != (dev_t)PUFFS_VNOVAL)
41084d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "0x%llx",
41184d9c625SLionel Sambuc (unsigned long long)vap->va_rdev);
41284d9c625SLionel Sambuc mydprintf("rdev: %s\n", buf);
41384d9c625SLionel Sambuc
41484d9c625SLionel Sambuc DEFAULTBUF();
41584d9c625SLionel Sambuc if (vap->va_bytes != (u_quad_t)PUFFS_VNOVAL)
41684d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "%" PRIu64, vap->va_bytes);
41784d9c625SLionel Sambuc mydprintf(DINT DINT "bytes: %s, ", buf);
41884d9c625SLionel Sambuc
41984d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "%" PRIu64, vap->va_filerev);
42084d9c625SLionel Sambuc mydprintf("filerev: %s, ", buf);
42184d9c625SLionel Sambuc
42284d9c625SLionel Sambuc snprintf(buf, sizeof(buf), "0x%x", vap->va_vaflags);
42384d9c625SLionel Sambuc mydprintf("vaflags: %s\n", buf);
42484d9c625SLionel Sambuc }
42584d9c625SLionel Sambuc
42684d9c625SLionel Sambuc void
puffsdump_cookie(puffs_cookie_t c,const char * cookiename)42784d9c625SLionel Sambuc puffsdump_cookie(puffs_cookie_t c, const char *cookiename)
42884d9c625SLionel Sambuc {
42984d9c625SLionel Sambuc
43084d9c625SLionel Sambuc mydprintf("%scookie: at %p\n", cookiename, c);
43184d9c625SLionel Sambuc }
43284d9c625SLionel Sambuc
43384d9c625SLionel Sambuc static const char *cn_opnames[] = {
43484d9c625SLionel Sambuc "LOOKUP",
43584d9c625SLionel Sambuc "CREATE",
43684d9c625SLionel Sambuc "DELETE",
43784d9c625SLionel Sambuc "RENAME"
43884d9c625SLionel Sambuc };
43984d9c625SLionel Sambuc
44084d9c625SLionel Sambuc void
puffsdump_cn(struct puffs_kcn * pkcn)44184d9c625SLionel Sambuc puffsdump_cn(struct puffs_kcn *pkcn)
44284d9c625SLionel Sambuc {
44384d9c625SLionel Sambuc
44484d9c625SLionel Sambuc mydprintf(DINT "puffs_cn: \"%s\", len %zu op %s (flags 0x%x)\n",
44584d9c625SLionel Sambuc pkcn->pkcn_name, pkcn->pkcn_namelen,
44684d9c625SLionel Sambuc cn_opnames[pkcn->pkcn_nameiop & NAMEI_OPMASK],
44784d9c625SLionel Sambuc pkcn->pkcn_flags);
44884d9c625SLionel Sambuc }
44984d9c625SLionel Sambuc
45084d9c625SLionel Sambuc void
puffsdump_lookup(struct puffs_req * preq)45184d9c625SLionel Sambuc puffsdump_lookup(struct puffs_req *preq)
45284d9c625SLionel Sambuc {
45384d9c625SLionel Sambuc struct puffs_vnmsg_lookup *lookup_msg = (void *)preq;
45484d9c625SLionel Sambuc
45584d9c625SLionel Sambuc puffsdump_cn(&lookup_msg->pvnr_cn);
45684d9c625SLionel Sambuc }
45784d9c625SLionel Sambuc
45884d9c625SLionel Sambuc void
puffsdump_lookup_rv(struct puffs_req * preq)45984d9c625SLionel Sambuc puffsdump_lookup_rv(struct puffs_req *preq)
46084d9c625SLionel Sambuc {
46184d9c625SLionel Sambuc struct puffs_vnmsg_lookup *lookup_msg = (void *)preq;
46284d9c625SLionel Sambuc
46384d9c625SLionel Sambuc mydprintf(DINT "new %p, type 0x%x, size 0x%"PRIu64", dev 0x%llx\n",
46484d9c625SLionel Sambuc lookup_msg->pvnr_newnode, lookup_msg->pvnr_vtype,
46584d9c625SLionel Sambuc lookup_msg->pvnr_size, (unsigned long long)lookup_msg->pvnr_rdev);
46684d9c625SLionel Sambuc }
46784d9c625SLionel Sambuc
46884d9c625SLionel Sambuc void
puffsdump_create(struct puffs_req * preq)46984d9c625SLionel Sambuc puffsdump_create(struct puffs_req *preq)
47084d9c625SLionel Sambuc {
47184d9c625SLionel Sambuc /* XXX: wrong type, but we know it fits the slot */
47284d9c625SLionel Sambuc struct puffs_vnmsg_create *create_msg = (void *)preq;
47384d9c625SLionel Sambuc
47484d9c625SLionel Sambuc dumpattr(&create_msg->pvnr_va);
47584d9c625SLionel Sambuc }
47684d9c625SLionel Sambuc
47784d9c625SLionel Sambuc void
puffsdump_create_rv(struct puffs_req * preq)47884d9c625SLionel Sambuc puffsdump_create_rv(struct puffs_req *preq)
47984d9c625SLionel Sambuc {
48084d9c625SLionel Sambuc /* XXX: wrong type, but we know it fits the slot */
48184d9c625SLionel Sambuc struct puffs_vnmsg_create *create_msg = (void *)preq;
48284d9c625SLionel Sambuc
48384d9c625SLionel Sambuc mydprintf(DINT "new %p\n", create_msg->pvnr_newnode);
48484d9c625SLionel Sambuc }
48584d9c625SLionel Sambuc
48684d9c625SLionel Sambuc void
puffsdump_readwrite(struct puffs_req * preq)48784d9c625SLionel Sambuc puffsdump_readwrite(struct puffs_req *preq)
48884d9c625SLionel Sambuc {
48984d9c625SLionel Sambuc struct puffs_vnmsg_rw *rw_msg = (void *)preq;
49084d9c625SLionel Sambuc
49184d9c625SLionel Sambuc mydprintf(DINT "offset: %" PRId64 ", resid %zu, ioflag 0x%x\n",
49284d9c625SLionel Sambuc rw_msg->pvnr_offset, rw_msg->pvnr_resid, rw_msg->pvnr_ioflag);
49384d9c625SLionel Sambuc }
49484d9c625SLionel Sambuc
49584d9c625SLionel Sambuc void
puffsdump_readwrite_rv(struct puffs_req * preq)49684d9c625SLionel Sambuc puffsdump_readwrite_rv(struct puffs_req *preq)
49784d9c625SLionel Sambuc {
49884d9c625SLionel Sambuc struct puffs_vnmsg_rw *rw_msg = (void *)preq;
49984d9c625SLionel Sambuc
50084d9c625SLionel Sambuc mydprintf(DINT "resid after op: %zu\n", rw_msg->pvnr_resid);
50184d9c625SLionel Sambuc }
50284d9c625SLionel Sambuc
50384d9c625SLionel Sambuc void
puffsdump_readdir_rv(struct puffs_req * preq)50484d9c625SLionel Sambuc puffsdump_readdir_rv(struct puffs_req *preq)
50584d9c625SLionel Sambuc {
50684d9c625SLionel Sambuc struct puffs_vnmsg_readdir *readdir_msg = (void *)preq;
50784d9c625SLionel Sambuc
50884d9c625SLionel Sambuc mydprintf(DINT "resid after op: %zu, eofflag %d\n",
50984d9c625SLionel Sambuc readdir_msg->pvnr_resid, readdir_msg->pvnr_eofflag);
51084d9c625SLionel Sambuc }
51184d9c625SLionel Sambuc
51284d9c625SLionel Sambuc void
puffsdump_open(struct puffs_req * preq)51384d9c625SLionel Sambuc puffsdump_open(struct puffs_req *preq)
51484d9c625SLionel Sambuc {
51584d9c625SLionel Sambuc struct puffs_vnmsg_open *open_msg = (void *)preq;
51684d9c625SLionel Sambuc
51784d9c625SLionel Sambuc mydprintf(DINT "mode: 0x%x\n", open_msg->pvnr_mode);
51884d9c625SLionel Sambuc }
51984d9c625SLionel Sambuc
52084d9c625SLionel Sambuc void
puffsdump_targ(struct puffs_req * preq)52184d9c625SLionel Sambuc puffsdump_targ(struct puffs_req *preq)
52284d9c625SLionel Sambuc {
52384d9c625SLionel Sambuc struct puffs_vnmsg_remove *remove_msg = (void *)preq; /* XXX! */
52484d9c625SLionel Sambuc
52584d9c625SLionel Sambuc mydprintf(DINT "target cookie: %p\n", remove_msg->pvnr_cookie_targ);
52684d9c625SLionel Sambuc }
52784d9c625SLionel Sambuc
52884d9c625SLionel Sambuc void
puffsdump_readdir(struct puffs_req * preq)52984d9c625SLionel Sambuc puffsdump_readdir(struct puffs_req *preq)
53084d9c625SLionel Sambuc {
53184d9c625SLionel Sambuc struct puffs_vnmsg_readdir *readdir_msg = (void *)preq;
53284d9c625SLionel Sambuc
53384d9c625SLionel Sambuc mydprintf(DINT "read offset: %" PRId64 "\n", readdir_msg->pvnr_offset);
53484d9c625SLionel Sambuc }
53584d9c625SLionel Sambuc
53684d9c625SLionel Sambuc void
puffsdump_attr(struct puffs_req * preq)53784d9c625SLionel Sambuc puffsdump_attr(struct puffs_req *preq)
53884d9c625SLionel Sambuc {
53984d9c625SLionel Sambuc struct puffs_vnmsg_setgetattr *attr_msg = (void *)preq;
54084d9c625SLionel Sambuc
54184d9c625SLionel Sambuc dumpattr(&attr_msg->pvnr_va);
54284d9c625SLionel Sambuc }
543