Standardize License information
[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 "../afs/param.h"       /* Should be always first */
14 #ifdef  AFS_SGI62_ENV
15 #include "../afs/sysincludes.h" /* Standard vendor system headers */
16 #include "../afs/afsincludes.h" /* Afs-based standard headers */
17 #include "../afs/afs_stats.h"  /* statistics */
18
19
20 /*
21  * debugging routine - invoked by calling kp vnode xx
22  */
23 static void
24 printflags(register unsigned int flags, register char **strings)
25 {
26     register int mask = 1;
27
28     while (flags != 0) {
29         if (mask & flags) {
30             qprintf("%s ", *strings);
31             flags &= ~mask;
32         }
33         mask <<= 1;
34         strings++;
35     }
36 }
37
38 char *tab_vcache[] = {
39         "CStatd",           /* 1 */
40         "CBackup",          /* 2 */
41         "CRO",                  /* 4 */
42         "CMValid",              /* 8 */
43         "CCore",                /* 0x10 */
44         "CDirty",               /* 0x20 */
45         "CSafeStore",           /* 0x40 */
46         "CMAPPED",              /* 0x80 */
47         "CNSHARE",              /* 0x100 */
48 };
49
50 int
51 idbg_prafsnode(OSI_VC_DECL(avc))
52 {
53     OSI_VC_CONVERT(avc)
54
55     AFS_GLOCK();
56     qprintf("   Len %d DV %d Date %d Own %d Grp %d Mode 0%o Lnk %d\n",
57             avc->m.Length, avc->m.DataVersion, avc->m.Date,
58             avc->m.Owner, avc->m.Group, avc->m.Mode, avc->m.LinkCount);
59     qprintf("   flushDV %d mapDV %d truncpos 0x%x cb 0x%x cbE 0x%x\n",
60             avc->flushDV, avc->mapDV, avc->truncPos,
61             avc->callback, avc->cbExpires);
62     qprintf("   opens %d ex/wr %d flckcnt %d state 0x%x ",
63             avc->opens, avc->execsOrWriters, avc->flockCount,
64             avc->states);
65     printflags(avc->states, tab_vcache);
66     qprintf("\n");
67 #ifdef AFS_SGI64_ENV
68     qprintf("   mapcnt %llu, mvstat %d anyAcc 0x%x Access 0x%x\n",
69             avc->mapcnt, avc->mvstat, avc->anyAccess, avc->Access);
70     qprintf("   mvid 0x%x &lock 0x%x cred 0x%x\n",
71             avc->mvid, &avc->lock, avc->cred);
72     qprintf("   rwlock 0x%x (%d) id %llu trips %d\n",
73             &avc->vc_rwlock, valusema(&avc->vc_rwlock), avc->vc_rwlockid,
74             avc->vc_locktrips);
75 #else
76     qprintf("   mapcnt %d mvstat %d anyAcc 0x%x Access 0x%x\n",
77             avc->mapcnt, avc->mvstat, avc->anyAccess, avc->Access);
78     qprintf("   mvid 0x%x &lock 0x%x cred 0x%x\n",
79             avc->mvid, &avc->lock, avc->cred);
80     qprintf("   rwlock 0x%x (%d) id %d trips %d\n",
81             &avc->vc_rwlock, valusema(&avc->vc_rwlock), avc->vc_rwlockid,
82             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         register 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->fid.Fid.Vnode + (tvc->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",
118                         tvc, tab_vtypes[((vnode_t *)tvc)->v_type],
119                         ((vnode_t *)tvc)->v_count,
120                         (int) VN_GET_PGCNT((vnode_t *)tvc),
121                         (int)tvc->mapcnt, nodeid, 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",
140             tu, tu->next, tu->uid, tu->uid, tu->cell,
141             tu->vid, tu->refCount);
142     qprintf("time %d stLen %d stp 0x%x exp 0x%x ",
143             tu->tokenTime, tu->stLen, tu->stp, tu->exporter);
144     printflags(tu->states, tab_userstates);
145     qprintf("\n");
146     qprintf("ClearToken: handle 0x%x ViceID 0x%x Btime %d Etime %d\n",
147                 tu->ct.AuthHandle, tu->ct.ViceId, tu->ct.BeginTimestamp,
148                 tu->ct.EndTimestamp);
149 }
150
151 extern struct unixuser *afs_users[NUSERS];
152 int
153 idbg_afsuser(void *x)
154 {
155         struct unixuser *tu;
156         int i;
157         AFS_GLOCK();
158
159         if (x == (void *)-1L) {
160                 for (i = 0; i < NUSERS; i++)
161                         for (tu = afs_users[i]; tu; tu = tu->next)
162                                 idbg_pruser(tu);
163         } else
164                 idbg_pruser((struct unixuser *)x);
165
166         AFS_GUNLOCK();
167         return 0;
168 }
169
170 #endif /* AFS_SGI62_ENV */