Home | History | Annotate | Line # | Download | only in libpuffs
opdump.c revision 1.5
      1 /*	$NetBSD: opdump.c,v 1.5 2006/11/07 22:10:53 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.5 2006/11/07 22:10:53 pooka Exp $");
     40 #endif /* !lint */
     41 
     42 #include <puffs.h>
     43 #include <puffsdump.h>
     44 #include <stdio.h>
     45 
     46 /* XXX! */
     47 const 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 };
     62 /* XXX! */
     63 const char *vnop_revmap[] = {
     64 	"PUFFS_VN_LOOKUP",
     65 	"PUFFS_VN_CREATE",
     66 	"PUFFS_VN_MKNOD",
     67 	"PUFFS_VN_OPEN",
     68 	"PUFFS_VN_CLOSE",
     69 	"PUFFS_VN_ACCESS",
     70 	"PUFFS_VN_GETATTR",
     71 	"PUFFS_VN_SETATTR",
     72 	"PUFFS_VN_READ",
     73 	"PUFFS_VN_WRITE",
     74 	"PUFFS_VN_IOCTL",
     75 	"PUFFS_VN_FCNTL",
     76 	"PUFFS_VN_POLL",
     77 	"PUFFS_VN_KQFILTER",
     78 	"PUFFS_VN_REVOKE",
     79 	"PUFFS_VN_MMAP",
     80 	"PUFFS_VN_FSYNC",
     81 	"PUFFS_VN_SEEK",
     82 	"PUFFS_VN_REMOVE",
     83 	"PUFFS_VN_LINK",
     84 	"PUFFS_VN_RENAME",
     85 	"PUFFS_VN_MKDIR",
     86 	"PUFFS_VN_RMDIR",
     87 	"PUFFS_VN_SYMLINK",
     88 	"PUFFS_VN_READDIR",
     89 	"PUFFS_VN_READLINK",
     90 	"PUFFS_VN_ABORTOP",
     91 	"PUFFS_VN_INACTIVE",
     92 	"PUFFS_VN_RECLAIM",
     93 	"PUFFS_VN_LOCK",
     94 	"PUFFS_VN_UNLOCK",
     95 	"PUFFS_VN_BMAP",
     96 	"PUFFS_VN_STRATEGY",
     97 	"PUFFS_VN_PRINT",
     98 	"PUFFS_VN_ISLOCKED",
     99 	"PUFFS_VN_PATHCONF",
    100 	"PUFFS_VN_ADVLOCK",
    101 	"PUFFS_VN_LEASE",
    102 	"PUFFS_VN_WHITEOUT",
    103 	"PUFFS_VN_GETPAGES",
    104 	"PUFFS_VN_PUTPAGES",
    105 	"PUFFS_VN_BWRITE",
    106 	"PUFFS_VN_GETEXTATTR",
    107 	"PUFFS_VN_LISTEXTATTR",
    108 	"PUFFS_VN_OPENEXTATTR",
    109 	"PUFFS_VN_DELETEEXTATTR",
    110 	"PUFFS_VN_SETEXTATTR",
    111 };
    112 
    113 void
    114 puffsdump_req(struct puffs_req *preq)
    115 {
    116 	const char **map;
    117 
    118 	map = PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VFS
    119 	    ? vfsop_revmap : vnop_revmap;
    120 	printf("\treqid: %" PRIuFAST64 ", opclass %d%s, optype: %s, "
    121 	    "cookie: %p,\n\t\taux: %p, auxlen: %zu\n",
    122 	    preq->preq_id, PUFFSOP_OPCLASS(preq->preq_opclass),
    123 	    PUFFSOP_WANTREPLY(preq->preq_opclass) ? "" : " (FAF)",
    124 	    map[preq->preq_optype], preq->preq_cookie,
    125 	    preq->preq_aux, preq->preq_auxlen);
    126 }
    127 
    128 void
    129 puffsdump_cookie(void *c, const char *cookiename)
    130 {
    131 
    132 	printf("\t%scookie: at %p\n", cookiename, c);
    133 }
    134 
    135 #if 0
    136 static const char *cn_opnames[] = {
    137 	"LOOKUP",
    138 	"CREATE",
    139 	"DELETE",
    140 	"RENAME"
    141 };
    142 void
    143 puffsdump_cn(struct puffs_cn *pcn)
    144 {
    145 
    146 	printf("\tpuffs_cn: %s (%sfollow)\n",
    147 	    cn_opnames[pcn->pcn_nameio & PUFFSLOOKUP_OPMASK],
    148 	    pcn->pcn_nameio&PUFFSLOOKUP_OPTIONS==PUFFSLOOKUP_NOFOLLOW?"no":"");
    149 	/*
    150 	TOFINISH
    151 	*/
    152 }
    153 #endif
    154 
    155 void
    156 /*ARGSUSED*/
    157 puffsdump_creds(struct puffs_cred *pcr)
    158 {
    159 
    160 }
    161 
    162 void
    163 puffsdump_int(int value, const char *name)
    164 {
    165 
    166 	printf("\tint (%s): %d\n", name, value);
    167 }
    168