Home | History | Annotate | Line # | Download | only in libperfuse
debug.c revision 1.4
      1  1.4  manu /*  $NetBSD: debug.c,v 1.4 2010/09/29 08:01:10 manu Exp $ */
      2  1.1  manu 
      3  1.1  manu /*-
      4  1.1  manu  *  Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
      5  1.1  manu  *
      6  1.1  manu  *  Redistribution and use in source and binary forms, with or without
      7  1.1  manu  *  modification, are permitted provided that the following conditions
      8  1.1  manu  *  are met:
      9  1.1  manu  *  1. Redistributions of source code must retain the above copyright
     10  1.1  manu  *     notice, this list of conditions and the following disclaimer.
     11  1.1  manu  *  2. Redistributions in binary form must reproduce the above copyright
     12  1.1  manu  *     notice, this list of conditions and the following disclaimer in the
     13  1.1  manu  *     documentation and/or other materials provided with the distribution.
     14  1.1  manu  *
     15  1.1  manu  *  THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     16  1.1  manu  *  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     17  1.1  manu  *  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     18  1.1  manu  *  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     19  1.1  manu  *  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     20  1.1  manu  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     21  1.1  manu  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     22  1.1  manu  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     23  1.1  manu  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     24  1.1  manu  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     25  1.1  manu  *  POSSIBILITY OF SUCH DAMAGE.
     26  1.1  manu  */
     27  1.1  manu 
     28  1.1  manu #include <puffs.h>
     29  1.1  manu #include <sys/types.h>
     30  1.1  manu 
     31  1.1  manu #include "perfuse_if.h"
     32  1.1  manu #include "fuse.h"
     33  1.1  manu 
     34  1.1  manu struct perfuse_opcode {
     35  1.1  manu 	int  opcode;
     36  1.1  manu 	const char *opname;
     37  1.1  manu };
     38  1.1  manu 
     39  1.1  manu const struct perfuse_opcode perfuse_opcode[] = {
     40  1.1  manu 	{ FUSE_LOOKUP, "LOOKUP" },
     41  1.1  manu 	{ FUSE_FORGET, "FORGET" },
     42  1.1  manu 	{ FUSE_GETATTR, "GETATTR" },
     43  1.1  manu 	{ FUSE_SETATTR, "SETATTR" },
     44  1.1  manu 	{ FUSE_READLINK, "READLINK" },
     45  1.1  manu 	{ FUSE_SYMLINK, "SYMLINK" },
     46  1.1  manu 	{ FUSE_MKNOD, "MKNOD" },
     47  1.1  manu 	{ FUSE_MKDIR, "MKDIR" },
     48  1.1  manu 	{ FUSE_UNLINK, "UNLINK" },
     49  1.1  manu 	{ FUSE_RMDIR, "RMDIR" },
     50  1.1  manu 	{ FUSE_RENAME, "RENAME" },
     51  1.1  manu 	{ FUSE_LINK, "LINK" },
     52  1.1  manu 	{ FUSE_OPEN, "OPEN" },
     53  1.1  manu 	{ FUSE_READ, "READ" },
     54  1.1  manu 	{ FUSE_WRITE, "WRITE" },
     55  1.1  manu 	{ FUSE_STATFS, "STATFS" },
     56  1.1  manu 	{ FUSE_RELEASE, "RELEASE" },
     57  1.1  manu 	{ FUSE_FSYNC, "FSYNC" },
     58  1.1  manu 	{ FUSE_SETXATTR, "SETXATTR" },
     59  1.1  manu 	{ FUSE_GETXATTR, "GETXATTR" },
     60  1.1  manu 	{ FUSE_LISTXATTR, "LISTXATTR" },
     61  1.1  manu 	{ FUSE_REMOVEXATTR, "REMOVEXATTR" },
     62  1.1  manu 	{ FUSE_FLUSH, "FLUSH" },
     63  1.1  manu 	{ FUSE_INIT, "INIT" },
     64  1.1  manu 	{ FUSE_OPENDIR, "OPENDIR" },
     65  1.1  manu 	{ FUSE_READDIR, "READDIR" },
     66  1.1  manu 	{ FUSE_RELEASEDIR, "RELEASEDIR" },
     67  1.1  manu 	{ FUSE_FSYNCDIR, "FSYNCDIR" },
     68  1.1  manu 	{ FUSE_GETLK, "GETLK" },
     69  1.1  manu 	{ FUSE_SETLK, "SETLK" },
     70  1.1  manu 	{ FUSE_SETLKW, "SETLKW" },
     71  1.1  manu 	{ FUSE_ACCESS, "ACCESS" },
     72  1.1  manu 	{ FUSE_CREATE, "CREATE" },
     73  1.1  manu 	{ FUSE_INTERRUPT, "INTERRUPT" },
     74  1.1  manu 	{ FUSE_BMAP, "BMAP" },
     75  1.1  manu 	{ FUSE_DESTROY, "DESTROY" },
     76  1.1  manu 	{ FUSE_IOCTL, "IOCTL" },
     77  1.1  manu 	{ FUSE_POLL, "POLL" },
     78  1.1  manu 	{ FUSE_CUSE_INIT, "CUSE_INIT" },
     79  1.1  manu 	{ 0, "UNKNOWN" },
     80  1.1  manu };
     81  1.1  manu 
     82  1.3  manu const char *perfuse_qtypestr[] = {
     83  1.3  manu 	"READDIR",
     84  1.3  manu 	"READ",
     85  1.3  manu 	"WRITE",
     86  1.3  manu 	"AFTERWRITE",
     87  1.3  manu 	"OPEN"
     88  1.4  manu 	"AFTERXCHG"
     89  1.3  manu };
     90  1.2  manu 
     91  1.1  manu const char *
     92  1.1  manu perfuse_opname(opcode)
     93  1.1  manu 	int opcode;
     94  1.1  manu {
     95  1.1  manu 	const struct perfuse_opcode *po;
     96  1.1  manu 
     97  1.1  manu 	for (po = perfuse_opcode; po->opcode; po++) {
     98  1.1  manu 		if (po->opcode == opcode)
     99  1.1  manu 			return po->opname;
    100  1.1  manu 	}
    101  1.1  manu 
    102  1.1  manu 	return po->opname; /* "UNKNOWN" */
    103  1.1  manu }
    104