10 #include <sys/param.h>
12 #include <sys/vnode.h>
13 /*----------------------------------*/
14 static u_int crc16_table[16] = {
15 0x0000, 0xCC01, 0xD801, 0x1400,
16 0xF001, 0x3C00, 0x2800, 0xE401,
17 0xA001, 0x6C00, 0x7800, 0xB401,
18 0x5000, 0x9C01, 0x8801, 0x4400
22 wlpsacrc(u_char *buf, u_int len)
27 for (i = 0; i < len; i++, buf++) {
29 r1 = crc16_table[crc & 0xF];
30 crc = (crc >> 4) & 0x0FFF;
31 crc = crc ^ r1 ^ crc16_table[*buf & 0xF];
34 r1 = crc16_table[crc & 0xF];
35 crc = (crc >> 4) & 0x0FFF;
36 crc = crc ^ r1 ^ crc16_table[(*buf >> 4) & 0xF];
41 /*----------------------------------*/
53 main(int argc, char **argv)
55 int nchash, i, j, k, kn;
58 LIST_HEAD(nchashhead, namecache) *nchashtbl;
62 kvm_t *kvm = kvm_open(0, 0, 0, O_RDONLY, 0);
64 printf("kvm: %p\n", kvm);
65 printf("kvm_nlist: %d\n", kvm_nlist(kvm, nl));
66 kvm_read(kvm, nl[0].n_value, &nchash, sizeof nchash);
68 nchashtbl = malloc(nchash * sizeof *nchashtbl);
69 nc = malloc(sizeof *nc + 400);
70 newbucket = malloc(nchash * sizeof (int));
71 memset(newbucket, 0, nchash * sizeof (int));
72 kvm_read(kvm, nl[1].n_value, &p, sizeof p);
73 kvm_read(kvm, p, nchashtbl, nchash * sizeof *nchashtbl);
74 for (i=0; i < nchash; i++) {
79 p = (u_long)LIST_FIRST(nchashtbl+i);
82 kvm_read(kvm, p, nc, sizeof *nc + 400);
83 kvm_read(kvm, (u_long)nc->nc_dvp, &vn, sizeof vn);
84 nc->nc_name[nc->nc_nlen] = '\0';
85 for (j=k=kn=0;nc->nc_name[j];j++) {
93 kn = wlpsacrc(nc->nc_name,nc->nc_nlen);
95 /* kn += (u_long)vn.v_data >> 8; */
96 /* kn += (u_long)nc->nc_dvp >> 7; */
101 printf("%4d dvp %08x hash %08x vp %08x id %08x name <%s>\n",
102 i,nc->nc_dvp, k, nc->nc_vp, vn.v_id, nc->nc_name);
104 p = (u_long)LIST_NEXT(nc, nc_hash);
108 for (i=0; i < nchash; i++) {
109 histn[newbucket[i]]++;
115 if (histo[i] || histn[i])
116 printf("H%02d %4d %4d / %4d %4d\n",i,histo[i], p1 , histn[i], p2);