示例#1
0
void init_disk (void)
{
    char **list;
    char *msg;
    int i;
    char *path;

    msg = xenbus_ls(XBT_NIL, "device/vbd", &list);
    if (msg) {
        printk("Error %s while reading list of disks\n", msg);
        free(msg);
        return;
    }
    blk_nb = 0;
    while (list[blk_nb])
        blk_nb++;
    blk_dev = malloc(blk_nb * sizeof(*blk_dev));
    blk_info = malloc(blk_nb * sizeof(*blk_info));

    qsort(list, blk_nb, sizeof(*list), vbdcmp);

    for (i = 0; i < blk_nb; i++) {
        printk("vbd %s is hd%d\n", list[i], i);
        asprintf(&path, "device/vbd/%s", list[i]);
        blk_dev[i] = init_blkfront(path, &blk_info[i]);
        free(path);
        free(list[i]);
    }
}
示例#2
0
static void do_ls_test(const char *pre)
{
    char **dirs, *msg;
    int x;

    printk("ls %s...\n", pre);
    msg = xenbus_ls(XBT_NIL, pre, &dirs);
    if (msg) {
	printk("Error in xenbus ls: %s\n", msg);
	free(msg);
	return;
    }
    for (x = 0; dirs[x]; x++) 
    {
        printk("ls %s[%d] -> %s\n", pre, x, dirs[x]);
        free(dirs[x]);
    }
    free(dirs);
}