Exemplo n.º 1
0
int
md_pre_update(void)
{
	if (get_ramsize() < 6)
		set_swap(diskdev, NULL);
	return 1;
}
Exemplo n.º 2
0
int
md_pre_update(void)
{
    struct mbr_partition *part;
    mbr_info_t *ext;
    int i;

    if (get_ramsize() <= 32)
        set_swap(diskdev, NULL);

    read_mbr(diskdev, &mbr);
    /* do a sanity check of the partition table */
    for (ext = &mbr; ext; ext = ext->extended) {
        part = ext->mbr.mbr_parts;
        for (i = 0; i < MBR_PART_COUNT; part++, i++) {
            if (part->mbrp_type != MBR_PTYPE_FAT12)
                continue;
            if (part->mbrp_size < (MIN_FAT12_BOOT / 512)) {
                msg_display(MSG_boottoosmall);
                msg_display_add(MSG_nobootpart, 0);
                process_menu(MENU_yesno, NULL);
                if (!yesno)
                    return 0;
                nobootfs = 1;
            }
        }
    }
    if (md_check_partitions() == 0)
        nobootfs = 1;
    return 1;
}
Exemplo n.º 3
0
/*
 * hook called after writing disklabel to new target disk.
 */
int
md_post_disklabel(void)
{
	if (get_ramsize() < 6)
		set_swap(diskdev, bsdlabel);
	return 0;
}
Exemplo n.º 4
0
static void
run_test(const char *file, size_t r, unsigned int size, unsigned int mode)
{
	FILE *fp;
	char buffer[512];
	size_t i, j;
	unsigned int d = 0;
	uint64_t s, e, a, ri, si, ai, sr, rg, sg, ag, sd, ng, ss, sts, su, sgc, sb;
	struct ck_hs_stat st;
	char **t;

	keys = malloc(sizeof(char *) * keys_capacity);
	assert(keys != NULL);

	fp = fopen(file, "r");
	assert(fp != NULL);

	while (fgets(buffer, sizeof(buffer), fp) != NULL) {
		buffer[strlen(buffer) - 1] = '\0';
		keys[keys_length++] = strdup(buffer);
		assert(keys[keys_length - 1] != NULL);

		if (keys_length == keys_capacity) {
			t = realloc(keys, sizeof(char *) * (keys_capacity *= 2));
			assert(t != NULL);
			keys = t;
		}
	}

	t = realloc(keys, sizeof(char *) * keys_length);
	assert(t != NULL);
	keys = t;

	set_init(size, mode);
	for (i = 0; i < keys_length; i++)
		d += set_insert(keys[i]) == false;
	ck_hs_stat(&hs, &st);

	fprintf(stderr, "# %zu entries stored, %u duplicates, %u probe.\n",
	    set_count(), d, st.probe_maximum);

	a = 0;
	for (j = 0; j < r; j++) {
		if (set_reset() == false) {
			ck_error("ERROR: Failed to reset hash table.\n");
		}

		s = rdtsc();
		for (i = keys_length; i > 0; i--)
			d += set_insert(keys[i - 1]) == false;
		e = rdtsc();
		a += e - s;
	}
	ri = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		if (set_reset() == false) {
			ck_error("ERROR: Failed to reset hash table.\n");
		}

		s = rdtsc();
		for (i = 0; i < keys_length; i++)
			d += set_insert(keys[i]) == false;
		e = rdtsc();
		a += e - s;
	}
	si = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		keys_shuffle(keys);

		if (set_reset() == false) {
			ck_error("ERROR: Failed to reset hash table.\n");
		}

		s = rdtsc();
		for (i = 0; i < keys_length; i++)
			d += set_insert(keys[i]) == false;
		e = rdtsc();
		a += e - s;
	}
	ai = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = 0; i < keys_length; i++)
			set_swap(keys[i]);
		e = rdtsc();
		a += e - s;
	}
	ss = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = 0; i < keys_length; i++)
			set_replace(keys[i]);
		e = rdtsc();
		a += e - s;
	}
	sr = a / (r * keys_length);

	set_reset();
	for (i = 0; i < keys_length; i++)
		set_insert(keys[i]);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = keys_length; i > 0; i--) {
			if (set_get(keys[i - 1]) == NULL) {
				ck_error("ERROR: Unexpected NULL value.\n");
			}
		}
		e = rdtsc();
		a += e - s;
	}
	rg = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = 0; i < keys_length; i++) {
			if (set_get(keys[i]) == NULL) {
				ck_error("ERROR: Unexpected NULL value.\n");
			}
		}
		e = rdtsc();
		a += e - s;
	}
	sg = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		keys_shuffle(keys);

		s = rdtsc();
		for (i = 0; i < keys_length; i++) {
			if (set_get(keys[i]) == NULL) {
				ck_error("ERROR: Unexpected NULL value.\n");
			}
		}
		e = rdtsc();
		a += e - s;
	}
	ag = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = 0; i < keys_length; i++)
			set_remove(keys[i]);
		e = rdtsc();
		a += e - s;

		for (i = 0; i < keys_length; i++)
			set_insert(keys[i]);
	}
	sd = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = 0; i < keys_length; i++) {
			set_get("\x50\x03\x04\x05\x06\x10");
		}
		e = rdtsc();
		a += e - s;
	}
	ng = a / (r * keys_length);

	set_reset();
	for (i = 0; i < keys_length; i++)
		set_insert(keys[i]);
	for (i = 0; i < keys_length; i++)
		set_remove(keys[i]);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = 0; i < keys_length; i++)
			set_insert(keys[i]);
		e = rdtsc();
		a += e - s;

		for (i = 0; i < keys_length; i++)
			set_remove(keys[i]);
	}
	sts = a / (r * keys_length);

	set_reset();

	/* Prune duplicates. */
	for (i = 0; i < keys_length; i++) {
		if (set_insert(keys[i]) == true)
			continue;

		free(keys[i]);
		keys[i] = keys[--keys_length];
	}

	for (i = 0; i < keys_length; i++)
		set_remove(keys[i]);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = 0; i < keys_length; i++)
			set_insert_unique(keys[i]);
		e = rdtsc();
		a += e - s;

		for (i = 0; i < keys_length; i++)
			set_remove(keys[i]);
	}
	su = a / (r * keys_length);

	for (i = 0; i < keys_length; i++)
		set_insert_unique(keys[i]);

	for (i = 0; i < keys_length / 2; i++)
		set_remove(keys[i]);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		set_gc();
		e = rdtsc();
		a += e - s;
	}
	sgc = a / r;

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		set_rebuild();
		e = rdtsc();
		a += e - s;
	}
	sb = a / r;

	printf("%zu "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 "\n",
	    keys_length, ri, si, ai, ss, sr, rg, sg, ag, sd, ng, sts, su, sgc, sb);

	fclose(fp);

	for (i = 0; i < keys_length; i++) {
		free(keys[i]);
	}

	free(keys);
	keys_length = 0;
	set_destroy();
	return;
}