static int nbd_negotiate_handle_export_name(NBDClient *client, uint32_t length)

{

    int rc = -EINVAL;

    char name[256];



    /* Client sends:

        [20 ..  xx]   export name (length bytes)

     */

    TRACE("Checking length");

    if (length > 255) {

        LOG("Bad length received");

        goto fail;

    }

    if (nbd_negotiate_read(client->ioc, name, length) != length) {

        LOG("read failed");

        goto fail;

    }

    name[length] = '\0';



    TRACE("Client requested export '%s'", name);



    client->exp = nbd_export_find(name);

    if (!client->exp) {

        LOG("export not found");

        goto fail;

    }



    QTAILQ_INSERT_TAIL(&client->exp->clients, client, next);

    nbd_export_get(client->exp);

    rc = 0;

fail:

    return rc;

}

static int nbd_negotiate_handle_export_name(NBDClient *client, uint32_t length)

{

    int rc = -EINVAL;

    char name[256];



    





    TRACE("Checking length");

    if (length > 255) {

        LOG("Bad length received");

        goto fail;

    }

    if (nbd_negotiate_read(client->ioc, name, length) != length) {

        LOG("read failed");

        goto fail;

    }

    name[length] = '\0';



    TRACE("Client requested export '%s'", name);



    client->exp = nbd_export_find(name);

    if (!client->exp) {

        LOG("export not found");

        goto fail;

    }



    QTAILQ_INSERT_TAIL(&client->exp->clients, client, next);

    nbd_export_get(client->exp);

    rc = 0;

fail:

    return rc;

}

static int FUNC_0(NBDClient *VAR_0, uint32_t VAR_1)

{

    int VAR_2 = -EINVAL;

    char VAR_3[256];



    





    TRACE("Checking VAR_1");

    if (VAR_1 > 255) {

        LOG("Bad VAR_1 received");

        goto fail;

    }

    if (nbd_negotiate_read(VAR_0->ioc, VAR_3, VAR_1) != VAR_1) {

        LOG("read failed");

        goto fail;

    }

    VAR_3[VAR_1] = '\0';



    TRACE("Client requested export '%s'", VAR_3);



    VAR_0->exp = nbd_export_find(VAR_3);

    if (!VAR_0->exp) {

        LOG("export not found");

        goto fail;

    }



    QTAILQ_INSERT_TAIL(&VAR_0->exp->clients, VAR_0, next);

    nbd_export_get(VAR_0->exp);

    VAR_2 = 0;

fail:

    return VAR_2;

}

static int FUNC_0(NBDClient *VAR_0, uint32_t VAR_1)
{ int VAR_2 = -EINVAL; char VAR_3[256]; TRACE("Checking VAR_1"); if (VAR_1 > 255) { LOG("Bad VAR_1 received"); goto fail; } if (nbd_negotiate_read(VAR_0->ioc, VAR_3, VAR_1) != VAR_1) { LOG("read failed"); goto fail; } VAR_3[VAR_1] = '\0'; TRACE("Client requested export '%s'", VAR_3); VAR_0->exp = nbd_export_find(VAR_3); if (!VAR_0->exp) { LOG("export not found"); goto fail; } QTAILQ_INSERT_TAIL(&VAR_0->exp->clients, VAR_0, next); nbd_export_get(VAR_0->exp); VAR_2 = 0; fail:
return VAR_2; }