/*
* Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
*
* Development of this software was supported by the
* Google Summer of Code program and the Ulla Tuominen Foundation.
* The Google SoC project was mentored by Bill Studenmund.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* Pretty-printing helper routines for VFS/VOP request contents */
if (isvn) {
switch ((enum puffs_vn)preq->preq_optype) {
case PUFFS_VN_LOOKUP:
puffsdump_lookup(preq);
break;
case PUFFS_VN_READ:
case PUFFS_VN_WRITE:
puffsdump_readwrite(preq);
break;
case PUFFS_VN_OPEN:
puffsdump_open(preq);
break;
case PUFFS_VN_REMOVE:
case PUFFS_VN_RMDIR:
case PUFFS_VN_LINK:
puffsdump_targ(preq);
break;
case PUFFS_VN_READDIR:
puffsdump_readdir(preq);
break;
case PUFFS_VN_CREATE:
case PUFFS_VN_MKDIR:
case PUFFS_VN_MKNOD:
case PUFFS_VN_SYMLINK:
puffsdump_create(preq);
break;
case PUFFS_VN_SETATTR:
puffsdump_attr(preq);
break;
default:
break;
}
}
if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VN) {
switch ((enum puffs_vn)preq->preq_optype) {
case PUFFS_VN_LOOKUP:
puffsdump_lookup_rv(preq);
break;
case PUFFS_VN_CREATE:
case PUFFS_VN_MKDIR:
case PUFFS_VN_MKNOD:
case PUFFS_VN_SYMLINK:
puffsdump_create_rv(preq);
break;
case PUFFS_VN_READ:
case PUFFS_VN_WRITE:
puffsdump_readwrite_rv(preq);
break;
case PUFFS_VN_READDIR:
puffsdump_readdir_rv(preq);
break;
case PUFFS_VN_GETATTR:
puffsdump_attr(preq);
break;
default:
break;
}
}
/*
* Slightly tedious print-routine so that we get a nice NOVAL instead
* of some tedious output representations for -1, especially (uint64_t)-1
*
* We use typecasting to make this work beyond time_t/dev_t size changes.
*/
static void
dumpattr(struct vattr *vap)
{
const char * const vtypes[] = { VNODE_TYPES };
char buf[128];
/* XXX: better readability. and this is debug, so no cycle-sweat */
#define DEFAULTBUF() snprintf(buf, sizeof(buf), "NOVAL")
DEFAULTBUF();
if ((unsigned long long)vap->va_fsid!=(unsigned long long)PUFFS_VNOVAL)
snprintf(buf, sizeof(buf), "0x%llx",
(unsigned long long)vap->va_fsid);
mydprintf(DINT DINT "fsid: %s, ", buf);
mydprintf(DINT "new %p, type 0x%x, size 0x%"PRIu64", dev 0x%llx\n",
lookup_msg->pvnr_newnode, lookup_msg->pvnr_vtype,
lookup_msg->pvnr_size, (unsigned long long)lookup_msg->pvnr_rdev);
}
void
puffsdump_create(struct puffs_req *preq)
{
/* XXX: wrong type, but we know it fits the slot */
struct puffs_vnmsg_create *create_msg = (void *)preq;
dumpattr(&create_msg->pvnr_va);
}
void
puffsdump_create_rv(struct puffs_req *preq)
{
/* XXX: wrong type, but we know it fits the slot */
struct puffs_vnmsg_create *create_msg = (void *)preq;
mydprintf(DINT "new %p\n", create_msg->pvnr_newnode);
}