1 /* Quick and Dirty Hack to reset a CNFS buffer without having to DD the
2 * Entire Thing from /dev/zero again. */
10 /* uncomment the below for LARGE_FILES support */
11 /* #define LARGE_FILES */
13 int main(int argc, char *argv[])
25 bzero(buf, sizeof(buf));
26 for (i = 1; i < argc; i++) {
28 if ((fd = open(argv[i], O_LARGEFILE | O_RDWR, 0664)) < 0)
30 if ((fd = open(argv[i], O_RDWR, 0664)) < 0)
32 fprintf(stderr, "Could not open file %s: %s\n", argv[i], strerror(errno));
35 if (fstat64(fd, &st) < 0) {
37 if (fstat(fd, &st) < 0) {
39 fprintf(stderr, "Could not stat file %s: %s\n", argv[i], strerror(errno));
41 /* each bit in the bitfield is 512 bytes of data. Each byte
42 * has 8 bits, so calculate as 512 * 8 bytes of data, plus
43 * fuzz. buf has 512 bytes in it, therefore containing data for
44 * (512 * 8) * 512 bytes of data. */
45 numwr = (st.st_size / (512*8) / sizeof(buf)) + 50;
46 printf("File %s: %u %u\n", argv[i], st.st_size, numwr);
47 for (j = 0; j < numwr; j++) {
49 printf("\t%d/%d\n", j, numwr);
50 write(fd, buf, sizeof(buf));