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