|
Next: Glossary (DRAFT) Up: Linux System Administrators' Guide Previous: When the clock is
Measuring HolesThis appendix contains the interesting part of the program used to measure the potential for holes in a filesystem. The source distribution of the book contains the full source code (sag/measure-holes/measure-holes.c).
int process(FILE *f, char *filename) { static char *buf = NULL; static long prev_block_size = -1; long zeroes; char *p; if (buf == NULL || prev_block_size != block_size) { free(buf); buf = xmalloc(block_size + 1); buf[block_size] = 1; prev_block_size = block_size; } zeroes = 0; while (fread(buf, block_size, 1, f) == 1) { for (p = buf; *p == '\0'; ) ++p; if (p == buf+block_size) zeroes += block_size; } if (zeroes > 0) printf("%ld %s\n", zeroes, filename); if (ferror(f)) { errormsg(0, -1, "read failed for `%s'", filename); return -1; } return 0; } Lars Wirzenius Sat Nov 15 02:32:11 EET 1997 |
|||||||||||||||||
With any suggestions or questions please feel free to contact us |