Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libpuffs Dump contents of struct vattr -- i never rememb...
details: https://anonhg.NetBSD.org/src/rev/4f7ea13b8666
branches: trunk
changeset: 750590:4f7ea13b8666
user: pooka <pooka%NetBSD.org@localhost>
date: Thu Jan 07 20:47:47 2010 +0000
description:
Dump contents of struct vattr -- i never remember which members
the kernel passes when, so this helps tapping that info.
diffstat:
lib/libpuffs/opdump.c | 166 ++++++++++++++++++++++++++++++++++++++++++++++-
lib/libpuffs/puffsdump.h | 5 +-
2 files changed, 167 insertions(+), 4 deletions(-)
diffs (237 lines):
diff -r d79de4b730cd -r 4f7ea13b8666 lib/libpuffs/opdump.c
--- a/lib/libpuffs/opdump.c Thu Jan 07 19:54:40 2010 +0000
+++ b/lib/libpuffs/opdump.c Thu Jan 07 20:47:47 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opdump.c,v 1.28 2010/01/07 18:09:07 pooka Exp $ */
+/* $NetBSD: opdump.c,v 1.29 2010/01/07 20:47:47 pooka Exp $ */
/*
* Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
-__RCSID("$NetBSD: opdump.c,v 1.28 2010/01/07 18:09:07 pooka Exp $");
+__RCSID("$NetBSD: opdump.c,v 1.29 2010/01/07 20:47:47 pooka Exp $");
#endif /* !lint */
#include <sys/types.h>
@@ -195,11 +195,20 @@
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;
}
}
-
+
PU_LOCK();
gettimeofday(&tv_now, NULL);
timersub(&tv_now, &tv_prev, &tv);
@@ -231,6 +240,9 @@
case PUFFS_VN_READDIR:
puffsdump_readdir_rv(preq);
break;
+ case PUFFS_VN_GETATTR:
+ puffsdump_attr(preq);
+ break;
default:
break;
}
@@ -241,6 +253,137 @@
preq->preq_rv ? strerror(preq->preq_rv) : "");
}
+/*
+ * 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")
+
+ printf(DINT "vattr:\n");
+ printf(DINT DINT "type: %s, ", vtypes[vap->va_type]);
+
+ DEFAULTBUF();
+ if (vap->va_mode != (mode_t)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "0%o", vap->va_mode);
+ printf("mode: %s, ", buf);
+
+ DEFAULTBUF();
+ if (vap->va_nlink != (nlink_t)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "%d", vap->va_nlink);
+ printf("nlink: %s, ", buf);
+
+ DEFAULTBUF();
+ if (vap->va_uid != (uid_t)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "%d", vap->va_uid);
+ printf("uid: %s, ", buf);
+
+ DEFAULTBUF();
+ if (vap->va_gid != (gid_t)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "%d", vap->va_gid);
+ printf("gid: %s\n", buf);
+
+ DEFAULTBUF();
+ if (vap->va_fsid != (dev_t)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "0x%llx",
+ (unsigned long long)vap->va_fsid);
+ printf(DINT DINT "fsid: %s, ", buf);
+
+ DEFAULTBUF();
+ if (vap->va_fileid != (ino_t)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "%" PRIu64, vap->va_fileid);
+ printf("ino: %s, ", buf);
+
+ DEFAULTBUF();
+ if (vap->va_size != (u_quad_t)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "%" PRIu64, vap->va_size);
+ printf("size: %s, ", buf);
+
+ DEFAULTBUF();
+ if (vap->va_blocksize != (long)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "%ld", vap->va_blocksize);
+ printf("bsize: %s\n", buf);
+
+ DEFAULTBUF();
+ if (vap->va_atime.tv_sec != (time_t)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "%lld",
+ (long long)vap->va_atime.tv_sec);
+ printf(DINT DINT "a.s: %s, ", buf);
+
+ DEFAULTBUF();
+ if (vap->va_atime.tv_nsec != (long)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "%ld", vap->va_atime.tv_nsec);
+ printf("a.ns: %s, ", buf);
+
+ DEFAULTBUF();
+ if (vap->va_mtime.tv_sec != (time_t)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "%lld",
+ (long long)vap->va_mtime.tv_sec);
+ printf("m.s: %s, ", buf);
+
+ DEFAULTBUF();
+ if (vap->va_mtime.tv_nsec != (long)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "%ld", vap->va_mtime.tv_nsec);
+ printf("m.ns: %s\n", buf);
+
+ DEFAULTBUF();
+ if (vap->va_ctime.tv_sec != (time_t)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "%lld",
+ (long long)vap->va_ctime.tv_sec);
+ printf(DINT DINT "c.s: %s, ", buf);
+
+ DEFAULTBUF();
+ if (vap->va_ctime.tv_nsec != (long)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "%ld", vap->va_ctime.tv_nsec);
+ printf("c.ns: %s, ", buf);
+
+ DEFAULTBUF();
+ if (vap->va_birthtime.tv_sec != (time_t)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "%lld",
+ (long long)vap->va_birthtime.tv_sec);
+ printf("b.s: %s, ", buf);
+
+ DEFAULTBUF();
+ if (vap->va_birthtime.tv_nsec != (long)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "%ld", vap->va_birthtime.tv_nsec);
+ printf("b.ns: %s\n", buf);
+
+ DEFAULTBUF();
+ if (vap->va_gen != (u_long)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "%lu", vap->va_gen);
+ printf(DINT DINT "gen: %s, ", buf);
+
+ DEFAULTBUF();
+ if (vap->va_flags != (u_long)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "0x%lx", vap->va_flags);
+ printf("flags: %s, ", buf);
+
+ DEFAULTBUF();
+ if (vap->va_rdev != (dev_t)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "0x%llx",
+ (unsigned long long)vap->va_rdev);
+ printf("rdev: %s\n", buf);
+
+ DEFAULTBUF();
+ if (vap->va_bytes != (u_quad_t)PUFFS_VNOVAL)
+ snprintf(buf, sizeof(buf), "%" PRIu64, vap->va_bytes);
+ printf(DINT DINT "bytes: %s, ", buf);
+
+ snprintf(buf, sizeof(buf), "%" PRIu64, vap->va_filerev);
+ printf("filerev: %s, ", buf);
+
+ snprintf(buf, sizeof(buf), "0x%x", vap->va_vaflags);
+ printf("vaflags: %s\n", buf);
+}
+
void
puffsdump_cookie(puffs_cookie_t c, const char *cookiename)
{
@@ -284,6 +427,15 @@
}
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 */
@@ -341,3 +493,11 @@
printf(DINT "read offset: %" PRId64 "\n", readdir_msg->pvnr_offset);
}
+
+void
+puffsdump_attr(struct puffs_req *preq)
+{
+ struct puffs_vnmsg_setgetattr *attr_msg = (void *)preq;
+
+ dumpattr(&attr_msg->pvnr_va);
+}
diff -r d79de4b730cd -r 4f7ea13b8666 lib/libpuffs/puffsdump.h
--- a/lib/libpuffs/puffsdump.h Thu Jan 07 19:54:40 2010 +0000
+++ b/lib/libpuffs/puffsdump.h Thu Jan 07 20:47:47 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: puffsdump.h,v 1.13 2010/01/07 18:09:07 pooka Exp $ */
+/* $NetBSD: puffsdump.h,v 1.14 2010/01/07 20:47:47 pooka Exp $ */
/*
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
@@ -48,8 +48,11 @@
void puffsdump_readdir_rv(struct puffs_req *);
void puffsdump_lookup(struct puffs_req *);
void puffsdump_lookup_rv(struct puffs_req *);
+void puffsdump_create(struct puffs_req *);
void puffsdump_create_rv(struct puffs_req *);
void puffsdump_open(struct puffs_req *);
+
+void puffsdump_attr(struct puffs_req *);
void puffsdump_targ(struct puffs_req *);
#endif /* _PUFFSDUMP_H_ */
Home |
Main Index |
Thread Index |
Old Index