OS 14 b
OS 14 b
blocks[j] = block;
count++;
j++;
}
if (count == len) {
// Mark index block allocated
disk[indexBlock] = 1;
// Mark data blocks allocated
for (j = 0; j < len; j++) {
disk[blocks[j]] = 1;
}
printf("File allocated successfully!\n");
}
}
// Display allocated blocks
printf("\nFile Allocation Table (Indexed):\n");
for (i = 0; i < MAX_BLOCKS; i++) {
if (disk[i] == 1) {
printf("Block %d: Allocated\n", i);
}
}
return 0;
}
OUTPUT:
Enter number of files: 1
Enter index block and number of blocks for file 1: 5 2
Enter block number 1: 10
Enter block number 2: 12
File allocated successfully!
Sprno:9223