2 * This is a really simple stupid standalone program which will find two
3 * filenames with the same CRC, used to test the directory iterator.
5 * cc -I /usr/src/sys test_dupkey.c /usr/src/sys/libkern/crc32.c -o test_dupkey
7 * $DragonFly: src/sbin/hammer/test_dupkey.c,v 1.1 2008/06/26 04:07:57 dillon Exp $
13 #include "hammer_util.h"
15 static u_int32_t
namekey(const char *name
);
16 static void randomname(char *name
);
18 u_int32_t bitmap
[0x80000000U
/ 32];
21 main(int ac
, char **av
)
30 srandom(0); /* reproducable random sequence number */
35 ptr
= &bitmap
[key
/ 32];
36 mask
= 1 << (key
& 31);
43 printf("duplicate found at count %d key %08x\n", count
, key
);
44 printf("'%s' and", name
);
56 printf(" '%s'\n", name
);
61 namekey(const char *name
)
65 key
= crc32(name
, strlen(name
)) & 0x7FFFFFFF;
73 randomname(char *name
)
75 int len
= random() % 16 + 8;
78 for (i
= 0; i
< len
; ++i
)
79 name
[i
] = random() % 26 + 'a';