static int ioreq_map(struct ioreq *ioreq)

{

    int gnt = ioreq->blkdev->xendev.gnttabdev;

    int i;



    if (ioreq->v.niov == 0) {

        return 0;

    }

    if (batch_maps) {

        ioreq->pages = xc_gnttab_map_grant_refs

            (gnt, ioreq->v.niov, ioreq->domids, ioreq->refs, ioreq->prot);

        if (ioreq->pages == NULL) {

            xen_be_printf(&ioreq->blkdev->xendev, 0,

                          "can't map %d grant refs (%s, %d maps)\n",

                          ioreq->v.niov, strerror(errno), ioreq->blkdev->cnt_map);

            return -1;

        }

        for (i = 0; i < ioreq->v.niov; i++) {

            ioreq->v.iov[i].iov_base = ioreq->pages + i * XC_PAGE_SIZE +

                (uintptr_t)ioreq->v.iov[i].iov_base;

        }

        ioreq->blkdev->cnt_map += ioreq->v.niov;

    } else  {

        for (i = 0; i < ioreq->v.niov; i++) {

            ioreq->page[i] = xc_gnttab_map_grant_ref

                (gnt, ioreq->domids[i], ioreq->refs[i], ioreq->prot);

            if (ioreq->page[i] == NULL) {

                xen_be_printf(&ioreq->blkdev->xendev, 0,

                              "can't map grant ref %d (%s, %d maps)\n",

                              ioreq->refs[i], strerror(errno), ioreq->blkdev->cnt_map);

                ioreq_unmap(ioreq);

                return -1;

            }

            ioreq->v.iov[i].iov_base = ioreq->page[i] + (uintptr_t)ioreq->v.iov[i].iov_base;

            ioreq->blkdev->cnt_map++;

        }

    }

    return 0;

}

static int ioreq_map(struct ioreq *ioreq)

{

    int gnt = ioreq->blkdev->xendev.gnttabdev;

    int i;



    if (ioreq->v.niov == 0) {

        return 0;

    }

    if (batch_maps) {

        ioreq->pages = xc_gnttab_map_grant_refs

            (gnt, ioreq->v.niov, ioreq->domids, ioreq->refs, ioreq->prot);

        if (ioreq->pages == NULL) {

            xen_be_printf(&ioreq->blkdev->xendev, 0,

                          "can't map %d grant refs (%s, %d maps)\n",

                          ioreq->v.niov, strerror(errno), ioreq->blkdev->cnt_map);

            return -1;

        }

        for (i = 0; i < ioreq->v.niov; i++) {

            ioreq->v.iov[i].iov_base = ioreq->pages + i * XC_PAGE_SIZE +

                (uintptr_t)ioreq->v.iov[i].iov_base;

        }

        ioreq->blkdev->cnt_map += ioreq->v.niov;

    } else  {

        for (i = 0; i < ioreq->v.niov; i++) {

            ioreq->page[i] = xc_gnttab_map_grant_ref

                (gnt, ioreq->domids[i], ioreq->refs[i], ioreq->prot);

            if (ioreq->page[i] == NULL) {

                xen_be_printf(&ioreq->blkdev->xendev, 0,

                              "can't map grant ref %d (%s, %d maps)\n",

                              ioreq->refs[i], strerror(errno), ioreq->blkdev->cnt_map);

                ioreq_unmap(ioreq);

                return -1;

            }

            ioreq->v.iov[i].iov_base = ioreq->page[i] + (uintptr_t)ioreq->v.iov[i].iov_base;

            ioreq->blkdev->cnt_map++;

        }

    }

    return 0;

}

static int FUNC_0(struct VAR_0 *VAR_0)

{

    int VAR_1 = VAR_0->blkdev->xendev.gnttabdev;

    int VAR_2;



    if (VAR_0->v.niov == 0) {

        return 0;

    }

    if (batch_maps) {

        VAR_0->pages = xc_gnttab_map_grant_refs

            (VAR_1, VAR_0->v.niov, VAR_0->domids, VAR_0->refs, VAR_0->prot);

        if (VAR_0->pages == NULL) {

            xen_be_printf(&VAR_0->blkdev->xendev, 0,

                          "can't map %d grant refs (%s, %d maps)\n",

                          VAR_0->v.niov, strerror(errno), VAR_0->blkdev->cnt_map);

            return -1;

        }

        for (VAR_2 = 0; VAR_2 < VAR_0->v.niov; VAR_2++) {

            VAR_0->v.iov[VAR_2].iov_base = VAR_0->pages + VAR_2 * XC_PAGE_SIZE +

                (uintptr_t)VAR_0->v.iov[VAR_2].iov_base;

        }

        VAR_0->blkdev->cnt_map += VAR_0->v.niov;

    } else  {

        for (VAR_2 = 0; VAR_2 < VAR_0->v.niov; VAR_2++) {

            VAR_0->page[VAR_2] = xc_gnttab_map_grant_ref

                (VAR_1, VAR_0->domids[VAR_2], VAR_0->refs[VAR_2], VAR_0->prot);

            if (VAR_0->page[VAR_2] == NULL) {

                xen_be_printf(&VAR_0->blkdev->xendev, 0,

                              "can't map grant ref %d (%s, %d maps)\n",

                              VAR_0->refs[VAR_2], strerror(errno), VAR_0->blkdev->cnt_map);

                ioreq_unmap(VAR_0);

                return -1;

            }

            VAR_0->v.iov[VAR_2].iov_base = VAR_0->page[VAR_2] + (uintptr_t)VAR_0->v.iov[VAR_2].iov_base;

            VAR_0->blkdev->cnt_map++;

        }

    }

    return 0;

}

static int FUNC_0(struct VAR_0 *VAR_0)
{ int VAR_1 = VAR_0->blkdev->xendev.gnttabdev; int VAR_2; if (VAR_0->v.niov == 0) { return 0; } if (batch_maps) { VAR_0->pages = xc_gnttab_map_grant_refs
(VAR_1, VAR_0->v.niov, VAR_0->domids, VAR_0->refs, VAR_0->prot); if (VAR_0->pages == NULL) { xen_be_printf(&VAR_0->blkdev->xendev, 0,
"can't map %d grant refs (%s, %d maps)\n",
VAR_0->v.niov, strerror(errno), VAR_0->blkdev->cnt_map); return -1; } for (VAR_2 = 0; VAR_2 < VAR_0->v.niov; VAR_2++) { VAR_0->v.iov[VAR_2].iov_base = VAR_0->pages + VAR_2 * XC_PAGE_SIZE +
(uintptr_t)VAR_0->v.iov[VAR_2].iov_base; } VAR_0->blkdev->cnt_map += VAR_0->v.niov; } else  { for (VAR_2 = 0; VAR_2 < VAR_0->v.niov; VAR_2++) { VAR_0->page[VAR_2] = xc_gnttab_map_grant_ref
(VAR_1, VAR_0->domids[VAR_2], VAR_0->refs[VAR_2], VAR_0->prot); if (VAR_0->page[VAR_2] == NULL) { xen_be_printf(&VAR_0->blkdev->xendev, 0,
"can't map grant ref %d (%s, %d maps)\n",
VAR_0->refs[VAR_2], strerror(errno), VAR_0->blkdev->cnt_map); ioreq_unmap(VAR_0); return -1; } VAR_0->v.iov[VAR_2].iov_base = VAR_0->page[VAR_2] + (uintptr_t)VAR_0->v.iov[VAR_2].iov_base; VAR_0->blkdev->cnt_map++; } } return 0; }