death to register
[openafs.git] / src / afs / IRIX / osi_idbg.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /*
11  * Implementation of Irix IDBG facility for AFS.
12  */
13 #include <afsconfig.h>
14 #include "afs/param.h"
15
16
17 #ifdef  AFS_SGI62_ENV
18 #include "afs/sysincludes.h"    /* Standard vendor system headers */
19 #include "afsincludes.h"        /* Afs-based standard headers */
20 #include "afs/afs_stats.h"      /* statistics */
21
22
23 /*
24  * debugging routine - invoked by calling kp vnode xx
25  */
26 static void
27 printflags(unsigned int flags, char **strings)
28 {
29     int mask = 1;
30
31     while (flags != 0) {
32         if (mask & flags) {
33             qprintf("%s ", *strings);
34             flags &= ~mask;
35         }
36         mask <<= 1;
37         strings++;
38     }
39 }
40
41 char *tab_vcache[] = {
42     "CStatd",                   /* 1 */
43     "CBackup",                  /* 2 */
44     "CRO",                      /* 4 */
45     "CMValid",                  /* 8 */
46     "CCore",                    /* 0x10 */
47     "CDirty",                   /* 0x20 */
48     "CSafeStore",               /* 0x40 */
49     "CMAPPED",                  /* 0x80 */
50     "CNSHARE",                  /* 0x100 */
51 };
52
53 int
54 idbg_prafsnode(OSI_VC_DECL(avc))
55 {
56     OSI_VC_CONVERT(avc);
57
58     AFS_GLOCK();
59     qprintf("   Len %d DV %d Date %d Own %d Grp %d Mode 0%o Lnk %d\n",
60             avc->f.m.Length, avc->f.m.DataVersion, avc->f.m.Date, avc->f.m.Owner,
61             avc->f.m.Group, avc->f.m.Mode, avc->f.m.LinkCount);
62     qprintf("   flushDV %d mapDV %d truncpos 0x%x cb 0x%x cbE 0x%x\n",
63             avc->flushDV, avc->mapDV, avc->f.truncPos, avc->callback,
64             avc->cbExpires);
65     qprintf("   opens %d ex/wr %d flckcnt %d state 0x%x ", avc->opens,
66             avc->execsOrWriters, avc->flockCount, avc->f.states);
67     printflags(avc->f.states, tab_vcache);
68     qprintf("\n");
69 #ifdef AFS_SGI64_ENV
70     qprintf("   mapcnt %llu, mvstat %d anyAcc 0x%x Access 0x%x\n",
71             avc->mapcnt, avc->mvstat, avc->f.anyAccess, avc->Access);
72     qprintf("   mvid 0x%x &lock 0x%x cred 0x%x\n", avc->mvid, &avc->lock,
73             avc->cred);
74     qprintf("   rwlock 0x%x (%d) id %llu trips %d\n", &avc->vc_rwlock,
75             valusema(&avc->vc_rwlock), avc->vc_rwlockid, avc->vc_locktrips);
76 #else
77     qprintf("   mapcnt %d mvstat %d anyAcc 0x%x Access 0x%x\n", avc->mapcnt,
78             avc->mvstat, avc->f.anyAccess, avc->Access);
79     qprintf("   mvid 0x%x &lock 0x%x cred 0x%x\n", avc->mvid, &avc->lock,
80             avc->cred);
81     qprintf("   rwlock 0x%x (%d) id %d trips %d\n", &avc->vc_rwlock,
82             valusema(&avc->vc_rwlock), avc->vc_rwlockid, avc->vc_locktrips);
83 #endif
84     AFS_GUNLOCK();
85     return 0;
86 }
87
88 extern struct afs_q VLRU;       /*vcache LRU */
89 static char *tab_vtypes[] = {
90     "VNON",
91     "VREG",
92     "VDIR",
93     "VBLK",
94     "VCHR",
95     "VLNK",
96     "VFIFO",
97     "VXNAM",
98     "VBAD",
99     "VSOCK",
100     0
101 };
102
103 int
104 idbg_afsvfslist()
105 {
106     struct vcache *tvc;
107     struct afs_q *tq;
108     struct afs_q *uq;
109     afs_int32 nodeid;           /* what ls prints as 'inode' */
110
111     AFS_GLOCK();
112     for (tq = VLRU.prev; tq != &VLRU; tq = uq) {
113         tvc = QTOV(tq);
114         uq = QPrev(tq);
115         nodeid = tvc->f.fid.Fid.Vnode + (tvc->f.fid.Fid.Volume << 16);
116         nodeid &= 0x7fffffff;
117         qprintf("avp 0x%x type %s cnt %d pg %d map %d nodeid %d(0x%x)\n", tvc,
118                 tab_vtypes[((vnode_t *) tvc)->v_type],
119                 ((vnode_t *) tvc)->v_count,
120                 (int)VN_GET_PGCNT((vnode_t *) tvc), (int)tvc->mapcnt, nodeid,
121                 nodeid);
122     }
123     AFS_GUNLOCK();
124     return 0;
125 }
126
127 static char *tab_userstates[] = {
128     "UHasTokens",
129     "UTokensBad",
130     "UPrimary",
131     "UNeedsReset",
132     "UPAGcounted",
133     "UNK",
134 };
135
136 static void
137 idbg_pruser(struct unixuser *tu)
138 {
139     qprintf("@0x%x nxt 0x%x uid %d (0x%x) cell 0x%x vid 0x%x ref %d\n", tu,
140             tu->next, tu->uid, tu->uid, tu->cell, tu->vid, tu->refCount);
141     qprintf("time %d stLen %d stp 0x%x exp 0x%x ", tu->tokenTime, tu->stLen,
142             tu->stp, tu->exporter);
143     printflags(tu->states, tab_userstates);
144     qprintf("\n");
145     qprintf("ClearToken: handle 0x%x ViceID 0x%x Btime %d Etime %d\n",
146             tu->ct.AuthHandle, tu->ct.ViceId, tu->ct.BeginTimestamp,
147             tu->ct.EndTimestamp);
148 }
149
150 extern struct unixuser *afs_users[NUSERS];
151 int
152 idbg_afsuser(void *x)
153 {
154     struct unixuser *tu;
155     int i;
156     AFS_GLOCK();
157
158     if (x == (void *)-1L) {
159         for (i = 0; i < NUSERS; i++)
160             for (tu = afs_users[i]; tu; tu = tu->next)
161                 idbg_pruser(tu);
162     } else
163         idbg_pruser((struct unixuser *)x);
164
165     AFS_GUNLOCK();
166     return 0;
167 }
168
169 #endif /* AFS_SGI62_ENV */