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