#include #define BLOCKSIZE 512 #define POINTERSIZE 4 #define DIRECT 12 #define INDIRECT1 1 #define INDIRECT2 1 #define INDIRECT3 1 int main() { int size, pointers, maxsize; printf("Block size: %d bytes\n", BLOCKSIZE); printf("Pointer size: %d bytes\n", POINTERSIZE); printf("Number of direct blocks: %d\n", DIRECT); printf("Number of single indirect blocks: %d\n", INDIRECT1); printf("Number of double indirect blocks: %d\n", INDIRECT2); printf("Number of triple indirect blocks: %d\n", INDIRECT2); maxsize = 0; /* compute size from direct blocks */ size = DIRECT * BLOCKSIZE; printf("Direct blocks max file size: %d bytes\n", size); maxsize += size; /* compute size from single indirect blocks */ pointers = INDIRECT1 * BLOCKSIZE / POINTERSIZE; size = pointers * BLOCKSIZE; printf("Single indirect block max file size: %d bytes (%d pointers)\n", size, pointers); maxsize += size; /* compute size from double indirect blocks */ pointers = INDIRECT2 * (BLOCKSIZE / POINTERSIZE) * (BLOCKSIZE / POINTERSIZE); size = pointers * BLOCKSIZE; printf("Double indirect block max file size: %d bytes (%d pointers)\n", size, pointers); maxsize += size; /* compute size from triple indirect blocks */ pointers = INDIRECT2 * (BLOCKSIZE / POINTERSIZE) * (BLOCKSIZE / POINTERSIZE) * (BLOCKSIZE / POINTERSIZE); size = pointers * BLOCKSIZE; printf("Triple indirect block max file size: %d bytes (%d pointers)\n", size, pointers); maxsize += size; printf("Total max file size: %d bytes\n", maxsize); }