Commit | Line | Data |
---|---|---|
805e021f CE |
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.target_root, &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.target_root, &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 = afs_calc_inum(tvc->f.fid.Cell, tvc->f.fid.Fid.Volume, | |
116 | tvc->f.fid.Fid.Vnode); | |
117 | qprintf("avp 0x%x type %s cnt %d pg %d map %d nodeid %lu(0x%lx)\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, | |
121 | (long unsigned)nodeid, (long unsigned)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 | union tokenUnion *token; | |
140 | ||
141 | token = afs_FindToken(tu->tokens, RX_SECIDX_KAD); | |
142 | ||
143 | qprintf("@0x%x nxt 0x%x uid %d (0x%x) cell 0x%x vid 0x%x ref %d\n", tu, | |
144 | tu->next, tu->uid, tu->uid, tu->cell, tu->viceId, tu->refCount); | |
145 | qprintf("time %dRX_SECIDX_KADstLen %d stp 0x%x exp 0x%x ", tu->tokenTime, | |
146 | (token != NULL)?token->rxkad.ticketLen:0, | |
147 | (token != NULL)?token->rxkad.ticket:NULL, | |
148 | tu->exporter); | |
149 | printflags(tu->states, tab_userstates); | |
150 | qprintf("\n"); | |
151 | qprintf("ClearToken: handle 0x%x ViceID 0x%x Btime %d Etime %d\n", | |
152 | (token != NULL)?token->rxkad.clearToken.AuthHandle:0, | |
153 | tu->viceId, | |
154 | (token != NULL)?token->rxkad.clearToken.BeginTimestamp:0, | |
155 | (token != NULL)?token->rxkad.clearToken.EndTimestamp:0); | |
156 | } | |
157 | ||
158 | extern struct unixuser *afs_users[NUSERS]; | |
159 | int | |
160 | idbg_afsuser(void *x) | |
161 | { | |
162 | struct unixuser *tu; | |
163 | int i; | |
164 | AFS_GLOCK(); | |
165 | ||
166 | if (x == (void *)-1L) { | |
167 | for (i = 0; i < NUSERS; i++) | |
168 | for (tu = afs_users[i]; tu; tu = tu->next) | |
169 | idbg_pruser(tu); | |
170 | } else | |
171 | idbg_pruser((struct unixuser *)x); | |
172 | ||
173 | AFS_GUNLOCK(); | |
174 | return 0; | |
175 | } | |
176 | ||
177 | #endif /* AFS_SGI62_ENV */ |