1*5812c3ccSTomohiro Kusumi /*- 2*5812c3ccSTomohiro Kusumi * Copyright (c) 2019 Tomohiro Kusumi <tkusumi@netbsd.org> 3*5812c3ccSTomohiro Kusumi * Copyright (c) 2019 The DragonFly Project 4*5812c3ccSTomohiro Kusumi * All rights reserved. 5*5812c3ccSTomohiro Kusumi * 6*5812c3ccSTomohiro Kusumi * Redistribution and use in source and binary forms, with or without 7*5812c3ccSTomohiro Kusumi * modification, are permitted provided that the following conditions 8*5812c3ccSTomohiro Kusumi * are met: 9*5812c3ccSTomohiro Kusumi * 1. Redistributions of source code must retain the above copyright 10*5812c3ccSTomohiro Kusumi * notice, this list of conditions and the following disclaimer. 11*5812c3ccSTomohiro Kusumi * 2. Redistributions in binary form must reproduce the above copyright 12*5812c3ccSTomohiro Kusumi * notice, this list of conditions and the following disclaimer in the 13*5812c3ccSTomohiro Kusumi * documentation and/or other materials provided with the distribution. 14*5812c3ccSTomohiro Kusumi * 15*5812c3ccSTomohiro Kusumi * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16*5812c3ccSTomohiro Kusumi * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17*5812c3ccSTomohiro Kusumi * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18*5812c3ccSTomohiro Kusumi * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19*5812c3ccSTomohiro Kusumi * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20*5812c3ccSTomohiro Kusumi * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21*5812c3ccSTomohiro Kusumi * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22*5812c3ccSTomohiro Kusumi * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23*5812c3ccSTomohiro Kusumi * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24*5812c3ccSTomohiro Kusumi * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25*5812c3ccSTomohiro Kusumi * SUCH DAMAGE. 26*5812c3ccSTomohiro Kusumi */ 27*5812c3ccSTomohiro Kusumi 28*5812c3ccSTomohiro Kusumi #ifndef FUSE_DEBUG_H 29*5812c3ccSTomohiro Kusumi #define FUSE_DEBUG_H 30*5812c3ccSTomohiro Kusumi 31*5812c3ccSTomohiro Kusumi #include <sys/param.h> 32*5812c3ccSTomohiro Kusumi #include <sys/systm.h> 33*5812c3ccSTomohiro Kusumi 34*5812c3ccSTomohiro Kusumi #include "fuse_abi.h" 35*5812c3ccSTomohiro Kusumi 36*5812c3ccSTomohiro Kusumi #if 1 37*5812c3ccSTomohiro Kusumi #define FUSE_CMDNAME (curproc ? curproc->p_comm : "...") 38*5812c3ccSTomohiro Kusumi #define FUSE_CMDPID (curproc ? curproc->p_pid : -1) 39*5812c3ccSTomohiro Kusumi #define fuse_print(X, ...) \ 40*5812c3ccSTomohiro Kusumi kprintf("%s(%s|%d): " X, __func__, FUSE_CMDNAME, FUSE_CMDPID, ## __VA_ARGS__) 41*5812c3ccSTomohiro Kusumi #define fuse_panic(X, ...) \ 42*5812c3ccSTomohiro Kusumi panic("%s(%s|%d): " X, __func__, FUSE_CMDNAME, FUSE_CMDPID, ## __VA_ARGS__) 43*5812c3ccSTomohiro Kusumi #define fuse_dbg(X, ...) if (fuse_debug) \ 44*5812c3ccSTomohiro Kusumi kprintf("### %s(%s|%d): " X, __func__, FUSE_CMDNAME, FUSE_CMDPID, ## __VA_ARGS__) 45*5812c3ccSTomohiro Kusumi #define fuse_dbgipc(fip, error, msg) do { \ 46*5812c3ccSTomohiro Kusumi struct fuse_in_header *ihd = fuse_in(fip); \ 47*5812c3ccSTomohiro Kusumi fuse_dbg("fip=%p ino=%ju op=%s len=%u error=%d %s\n", \ 48*5812c3ccSTomohiro Kusumi fip, ihd->nodeid, fuse_get_ops(ihd->opcode), ihd->len, error, msg); \ 49*5812c3ccSTomohiro Kusumi } while (0) 50*5812c3ccSTomohiro Kusumi #else 51*5812c3ccSTomohiro Kusumi #define fuse_print(X, ...) kprintf(X, ## __VA_ARGS__) 52*5812c3ccSTomohiro Kusumi #define fuse_panic(X, ...) panic(X, ## __VA_ARGS__) 53*5812c3ccSTomohiro Kusumi #define fuse_dbg(X, ...) do { } while (0) 54*5812c3ccSTomohiro Kusumi #define fuse_dbgipc(fip, error, msg) do { } while (0) 55*5812c3ccSTomohiro Kusumi #endif 56*5812c3ccSTomohiro Kusumi 57*5812c3ccSTomohiro Kusumi #endif /* FUSE_DEBUG_H */ 58