opdump.c revision 1.9
1/* $NetBSD: opdump.c,v 1.9 2007/03/20 10:22:22 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.9 2007/03/20 10:22:22 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}; 113const char *cacheop_revmap[] = { 114 "PUFFS_CACHE_WRITE" 115}; 116 117void 118puffsdump_req(struct puffs_req *preq) 119{ 120 const char **map; 121 122 map = NULL; /* yes, we are all interested in your opinion, gcc */ 123 switch (PUFFSOP_OPCLASS(preq->preq_opclass)) { 124 case PUFFSOP_VFS: 125 map = vfsop_revmap; 126 break; 127 case PUFFSOP_VN: 128 map = vnop_revmap; 129 break; 130 case PUFFSOP_CACHE: 131 map = cacheop_revmap; 132 break; 133 } 134 135 printf("\treqid: %" PRIu64 ", opclass %d%s, optype: %s, " 136 "cookie: %p,\n\t\taux: %p, auxlen: %zu\n", 137 preq->preq_id, PUFFSOP_OPCLASS(preq->preq_opclass), 138 PUFFSOP_WANTREPLY(preq->preq_opclass) ? "" : " (FAF)", 139 map[preq->preq_optype], preq->preq_cookie, 140 preq->preq_buf, preq->preq_buflen); 141} 142 143void 144puffsdump_rv(struct puffs_req *preq) 145{ 146 147 printf("\tRV reqid: %" PRIu64 ", result: %d %s\n", 148 preq->preq_id, preq->preq_rv, 149 preq->preq_rv ? strerror(preq->preq_rv) : ""); 150} 151 152void 153puffsdump_cookie(void *c, const char *cookiename) 154{ 155 156 printf("\t%scookie: at %p\n", cookiename, c); 157} 158 159#if 0 160static const char *cn_opnames[] = { 161 "LOOKUP", 162 "CREATE", 163 "DELETE", 164 "RENAME" 165}; 166void 167puffsdump_cn(struct puffs_cn *pcn) 168{ 169 170 printf("\tpuffs_cn: %s (%sfollow)\n", 171 cn_opnames[pcn->pcn_nameio & PUFFSLOOKUP_OPMASK], 172 pcn->pcn_nameio&PUFFSLOOKUP_OPTIONS==PUFFSLOOKUP_NOFOLLOW?"no":""); 173 /* 174 TOFINISH 175 */ 176} 177#endif 178 179void 180/*ARGSUSED*/ 181puffsdump_creds(struct puffs_cred *pcr) 182{ 183 184} 185 186void 187puffsdump_int(int value, const char *name) 188{ 189 190 printf("\tint (%s): %d\n", name, value); 191} 192