static int nbd_handle_export_name(NBDClient *client, uint32_t length)

{

    int rc = -EINVAL, csock = client->sock;

    char name[256];



    /* Client sends:

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

     */

    TRACE("Checking length");

    if (length > 255) {

        LOG("Bad length received");

        goto fail;

    }

    if (read_sync(csock, name, length) != length) {

        LOG("read failed");

        goto fail;

    }

    name[length] = '\0';



    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_handle_export_name(NBDClient *client, uint32_t length)

{

    int rc = -EINVAL, csock = client->sock;

    char name[256];



    





    TRACE("Checking length");

    if (length > 255) {

        LOG("Bad length received");

        goto fail;

    }

    if (read_sync(csock, name, length) != length) {

        LOG("read failed");

        goto fail;

    }

    name[length] = '\0';



    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, VAR_3 = VAR_0->sock;

    char VAR_4[256];



    





    TRACE("Checking VAR_1");

    if (VAR_1 > 255) {

        LOG("Bad VAR_1 received");

        goto fail;

    }

    if (read_sync(VAR_3, VAR_4, VAR_1) != VAR_1) {

        LOG("read failed");

        goto fail;

    }

    VAR_4[VAR_1] = '\0';



    VAR_0->exp = nbd_export_find(VAR_4);

    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, VAR_3 = VAR_0->sock; char VAR_4[256]; TRACE("Checking VAR_1"); if (VAR_1 > 255) { LOG("Bad VAR_1 received"); goto fail; } if (read_sync(VAR_3, VAR_4, VAR_1) != VAR_1) { LOG("read failed"); goto fail; } VAR_4[VAR_1] = '\0'; VAR_0->exp = nbd_export_find(VAR_4); 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; }