Example #1
0
ATF_TC_BODY(free, tc)
{
	h_create("test10", 0xc0002000, 0xffffe000, EX_BOUNDZERO);

	h_alloc_subregion(0xc0002000, 0xffffe000, 0x2000,
	    0x10000, 0x10000, 0, 0xc0010000);
	h_alloc_subregion(0xc0002000, 0xffffe000, 0x2000,
	    0x10000, 0x10000, 0, 0xc0020000);

	h_require("test10", 0xc0002000, 0xffffe000, 0x0,
	    "0xc0010000 - 0xc0011fff\n"
	    "0xc0020000 - 0xc0021fff\n");

	h_free(0xc0020000, 0x2000);
	h_require("test10", 0xc0002000, 0xffffe000, 0x0,
	    "0xc0010000 - 0xc0011fff\n");

	h_alloc_subregion(0xc0002000, 0xffffe000, 0x10000,
	    0x10000, 0x10000, 0, 0xc0022000);

	h_require("test10", 0xc0002000, 0xffffe000, 0x0,
	    "0xc0010000 - 0xc0011fff\n"
	    "0xc0022000 - 0xc0031fff\n");

	extent_destroy(ex);
}
Example #2
0
ATF_TC_BODY(bound3, tc)
{
	h_create("test6", 0, 11, 0);

	h_alloc_subregion(0, 11, 8, EX_NOALIGN, 8, 0, 0);
	h_alloc_subregion(0, 11, 2, EX_NOALIGN, 8, 0, 0x8);
	h_alloc_subregion(0, 11, 2, EX_NOALIGN, 8, 0, 0xa);

	h_require("test6", 0x0, 0xb, 0x0, "0x0 - 0xb\n");

	extent_destroy(ex);
}
Example #3
0
ATF_TC_BODY(bound2, tc)
{
	h_create("test5", 0xf0000000, 0xffffffff, 0);

	h_alloc_subregion(0xf0000000, 0xffffffff, 0x1,
	    EX_NOALIGN, 0x20000000, 0, 0xf0000000);

	h_require("test5", 0xf0000000, 0xffffffff, 0x0,
	    "0xf0000000 - 0xf0000000\n");

	extent_destroy(ex);
}
Example #4
0
ATF_TC_BODY(bound4, tc)
{
	h_create("test7", 0, 11, 0);

	h_alloc_subregion(0, 11, 7, EX_NOALIGN, 8, 0, 0);
	h_alloc_subregion(0, 11, 4, EX_NOALIGN, 8, 0, 8);

	h_require("test7", 0x0, 0xb, 0x0,
	    "0x0 - 0x6\n"
	    "0x8 - 0xb\n");

	extent_destroy(ex);
}
Example #5
0
ATF_TC_BODY(subregion1, tc)
{
	h_create("test2", 0, 0x2f, EX_NOCOALESCE);

	h_alloc_region(0x00, 0x10);
	h_alloc_subregion(0x20, 0x30, 0x10, EX_NOALIGN, EX_NOBOUNDARY, 0, 0x20);

	h_require("test2", 0x00, 0x2f, 0x2,
	    "0x0 - 0xf\n"
	    "0x20 - 0x2f\n");

	extent_destroy(ex);
}
Example #6
0
ATF_TC_BODY(subregion3, tc)
{
	h_create("test8", 0, 0x4f, EX_NOCOALESCE);

	h_alloc_region(0x30, 0x10);
	h_alloc_subregion(0, 0xf, 0x10, EX_NOALIGN, EX_NOBOUNDARY, 0, 0);
	h_alloc_subregion(0, 0xf, 0x10, EX_NOALIGN, EX_NOBOUNDARY, EAGAIN, 0);

	h_require("test8", 0x0, 0x4f, 0x2,
	    "0x0 - 0xf\n"
	    "0x30 - 0x3f\n");

	extent_destroy(ex);
}
Example #7
0
ATF_TC_BODY(bound5, tc)
{
	h_create("test9", 0, 0x4f, 0);

	h_alloc_subregion(0, 0x10, 4, EX_NOALIGN, 0, 0, 0);
	h_alloc_subregion(0xd, 0x20, 2, EX_NOALIGN, 0, 0, 0xd);
	h_alloc_subregion(0, 0x4f, 8, EX_NOALIGN, 8, 0, 0x10);

	h_require("test9", 0x0, 0x4f, 0x0,
	    "0x0 - 0x3\n"
	    "0xd - 0xe\n"
	    "0x10 - 0x17\n");

	extent_destroy(ex);
}
Example #8
0
ATF_TC_BODY(coalesce, tc)
{
	h_create("test1", 0, 0x4f, 0);

	h_alloc_region(0x00, 0x10);
	h_alloc_region(0x20, 0x10);
	h_alloc_region(0x40, 0x10);
	h_alloc_region(0x10, 0x10);
	h_alloc_subregion(0, 0x4f, 0x10, EX_NOALIGN, EX_NOBOUNDARY, 0, 0x30);

	h_require("test1", 0x00, 0x4f, 0x00,
	    "0x0 - 0x4f\n");

	extent_destroy(ex);
}
Example #9
0
void
rmtab_load()
{
    FILE *fp;

    (void) rwlock_init(&rmtab_lock, USYNC_THREAD, NULL);

    /*
     * Don't need to lock the list at this point
     * because there's only a single thread running.
     */
    mntlist = h_create(mntentry_hash, mntentry_equal, 101, 0.75);

    if (fp = fopen(RMTAB, "r")) {
        char buf[RMTAB_LOADLEN+1];
        size_t len;

        /*
         * Read at most RMTAB_LOADLEN bytes from /etc/rmtab.
         * - if fread returns RMTAB_LOADLEN we can be in the middle
         *   of a line so change the last newline character into NUL
         *   and seek back to the next character after newline.
         * - otherwise set NUL behind the last character read.
         */
        while ((len = fread(buf, 1, RMTAB_LOADLEN, fp)) > 0) {
            if (len == RMTAB_LOADLEN) {
                int i;

                for (i = 1; i < len; i++) {
                    if (buf[len-i] == '\n') {
                        buf[len-i] = '\0';
                        (void) fseek(fp, -i+1,
                                     SEEK_CUR);
                        goto parse;
                    }
                }
            }

            /* Put a NUL character at the end of buffer */
            buf[len] = '\0';
parse:
            rmtab_parse(buf);
        }
        (void) fclose(fp);
    }
    rmtab_rewrite();
}
Example #10
0
ATF_TC_BODY(subregion4, tc)
{
	h_create("test11", 0x10, 0x20, EX_NOCOALESCE);

	h_alloc_subregion(0x10, 0x13, 0x4, EX_NOALIGN, EX_NOBOUNDARY, 0, 0x10);
	h_alloc_subregion(0x1e, 0x1f, 0x2, EX_NOALIGN, EX_NOBOUNDARY, 0, 0x1e);
	h_alloc_subregion(0x20, 0x20, 0x1, EX_NOALIGN, EX_NOBOUNDARY, 0, 0x20);
	h_alloc_subregion(0x20, 0x20, 0x1, EX_NOALIGN, EX_NOBOUNDARY, EAGAIN, 0);
	h_alloc_subregion(0x10, 0x20, 0x1, EX_NOALIGN, EX_NOBOUNDARY, 0, 0x14);

	h_require("test11", 0x10, 0x20, 0x2,
	    "0x10 - 0x13\n"
	    "0x14 - 0x14\n"
	    "0x1e - 0x1f\n"
	    "0x20 - 0x20\n");

	extent_destroy(ex);
}