static int xenstore_scan(const char *type, int dom, struct XenDevOps *ops)

{

    struct XenDevice *xendev;

    char path[XEN_BUFSIZE], token[XEN_BUFSIZE];

    char **dev = NULL, *dom0;

    unsigned int cdev, j;



    /* setup watch */

    dom0 = xs_get_domain_path(xenstore, 0);

    snprintf(token, sizeof(token), "be:%p:%d:%p", type, dom, ops);

    snprintf(path, sizeof(path), "%s/backend/%s/%d", dom0, type, dom);

    free(dom0);

    if (!xs_watch(xenstore, path, token)) {

        xen_be_printf(NULL, 0, "xen be: watching backend path (%s) failed\n", path);

        return -1;

    }



    /* look for backends */

    dev = xs_directory(xenstore, 0, path, &cdev);

    if (!dev) {

        return 0;

    }

    for (j = 0; j < cdev; j++) {

        xendev = xen_be_get_xendev(type, dom, atoi(dev[j]), ops);

        if (xendev == NULL) {

            continue;

        }

        xen_be_check_state(xendev);

    }

    free(dev);

    return 0;

}

static int xenstore_scan(const char *type, int dom, struct XenDevOps *ops)

{

    struct XenDevice *xendev;

    char path[XEN_BUFSIZE], token[XEN_BUFSIZE];

    char **dev = NULL, *dom0;

    unsigned int cdev, j;



    

    dom0 = xs_get_domain_path(xenstore, 0);

    snprintf(token, sizeof(token), "be:%p:%d:%p", type, dom, ops);

    snprintf(path, sizeof(path), "%s/backend/%s/%d", dom0, type, dom);

    free(dom0);

    if (!xs_watch(xenstore, path, token)) {

        xen_be_printf(NULL, 0, "xen be: watching backend path (%s) failed\n", path);

        return -1;

    }



    

    dev = xs_directory(xenstore, 0, path, &cdev);

    if (!dev) {

        return 0;

    }

    for (j = 0; j < cdev; j++) {

        xendev = xen_be_get_xendev(type, dom, atoi(dev[j]), ops);

        if (xendev == NULL) {

            continue;

        }

        xen_be_check_state(xendev);

    }

    free(dev);

    return 0;

}

    dom0 = xs_get_domain_path(xenstore, 0);     free(dom0);     char **dev = NULL, *dom0;     dom0 = xs_get_domain_path(xenstore, 0);     snprintf(path, sizeof(path), "%s/backend/%s/%d", dom0, type, dom);     free(dom0);     dom0 = xs_get_domain_path(xenstore, 0);     free(dom0);
static int FUNC_0(const char *VAR_0, int VAR_1, struct XenDevOps *VAR_2)

{

    struct XenDevice *VAR_3;

    char VAR_4[XEN_BUFSIZE], token[XEN_BUFSIZE];

    char **VAR_5 = NULL, *VAR_6;

    unsigned int VAR_7, VAR_8;



    

    VAR_6 = xs_get_domain_path(xenstore, 0);

    snprintf(token, sizeof(token), "be:%p:%d:%p", VAR_0, VAR_1, VAR_2);

    snprintf(VAR_4, sizeof(VAR_4), "%s/backend/%s/%d", VAR_6, VAR_0, VAR_1);

    free(VAR_6);

    if (!xs_watch(xenstore, VAR_4, token)) {

        xen_be_printf(NULL, 0, "xen be: watching backend VAR_4 (%s) failed\n", VAR_4);

        return -1;

    }



    

    VAR_5 = xs_directory(xenstore, 0, VAR_4, &VAR_7);

    if (!VAR_5) {

        return 0;

    }

    for (VAR_8 = 0; VAR_8 < VAR_7; VAR_8++) {

        VAR_3 = xen_be_get_xendev(VAR_0, VAR_1, atoi(VAR_5[VAR_8]), VAR_2);

        if (VAR_3 == NULL) {

            continue;

        }

        xen_be_check_state(VAR_3);

    }

    free(VAR_5);

    return 0;

}

static int FUNC_0(const char *VAR_0, int VAR_1, struct XenDevOps *VAR_2)
{ struct XenDevice *VAR_3; char VAR_4[XEN_BUFSIZE], token[XEN_BUFSIZE]; char **VAR_5 = NULL, *VAR_6; unsigned int VAR_7, VAR_8; VAR_6 = xs_get_domain_path(xenstore, 0); snprintf(token, sizeof(token), "be:%p:%d:%p", VAR_0, VAR_1, VAR_2); snprintf(VAR_4, sizeof(VAR_4), "%s/backend/%s/%d", VAR_6, VAR_0, VAR_1); free(VAR_6); if (!xs_watch(xenstore, VAR_4, token)) { xen_be_printf(NULL, 0, "xen be: watching backend VAR_4 (%s) failed\n", VAR_4); return -1; } VAR_5 = xs_directory(xenstore, 0, VAR_4, &VAR_7); if (!VAR_5) { return 0; } for (VAR_8 = 0; VAR_8 < VAR_7; VAR_8++) { VAR_3 = xen_be_get_xendev(VAR_0, VAR_1, atoi(VAR_5[VAR_8]), VAR_2); if (VAR_3 == NULL) { continue; } xen_be_check_state(VAR_3); } free(VAR_5); return 0; }