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