double tests(int n, double p)
{
	int i;
	double k;

	for (k = i = 0; i < n; i++) {
		make_map(p);
		k += (double)count_clusters() / ww;
	}
	return k / n;
}
int main(void)
{
	w = 15;
	make_map(.5);
	printf("width=15, p=0.5, %d clusters:\n", count_clusters());
	show_cluster();

	printf("\np=0.5, iter=5:\n");
	for (w = 1<<2; w <= 1<<14; w<<=2)
		printf("%5d %9.6f\n", w, tests(5, .5));

	free(map);
	return 0;
}
Пример #3
0
/*
 * worker function that checks and repairs incosistency errors
 */
void chkerr(struct direntry* dirent, char* filename, 
                   uint8_t *image_buf, struct bpb33* bpb) {
    int num_clusters = count_clusters(dirent, image_buf, bpb);
    uint32_t entry_size = getulong(dirent->deFileSize);

    // remove empty files
    if (entry_size == 0) {
        if (dirent->deAttributes == ATTR_NORMAL && dirent->deName[0] != 
            SLOT_EMPTY && dirent->deName[0] != SLOT_DELETED) {
            printf("Empty file found... removing. \n\n");
            dirent->deName[0] = SLOT_DELETED;
        }
    }
    
    // fix size inconsistencies
    if (num_clusters != 0 && entry_size < num_clusters - 512 ) { // take entry to be right
        printf("OUT OF BOUNDS: \n\tFilename: %s \n\t\tsize in directory entry: %d, size in FAT chain: %d.) \n\n", filename, entry_size, num_clusters);
        repair(dirent, image_buf, bpb, entry_size);
    } else if (entry_size > num_clusters) { // take FAT to be right
        printf("OUT OF BOUNDS: \n\tFilename: %s \n\t\tsize in directory entry: %d, size in FAT chain: %d \n\n", filename, entry_size, num_clusters);
        putulong(dirent->deFileSize, num_clusters);
    }
}