static int read_write_object(int fd, char *buf, uint64_t oid, int copies,

                             unsigned int datalen, uint64_t offset,

                             bool write, bool create, bool cache)

{

    SheepdogObjReq hdr;

    SheepdogObjRsp *rsp = (SheepdogObjRsp *)&hdr;

    unsigned int wlen, rlen;

    int ret;



    memset(&hdr, 0, sizeof(hdr));



    if (write) {

        wlen = datalen;

        rlen = 0;

        hdr.flags = SD_FLAG_CMD_WRITE;

        if (create) {

            hdr.opcode = SD_OP_CREATE_AND_WRITE_OBJ;

        } else {

            hdr.opcode = SD_OP_WRITE_OBJ;

        }

    } else {

        wlen = 0;

        rlen = datalen;

        hdr.opcode = SD_OP_READ_OBJ;

    }



    if (cache) {

        hdr.flags |= SD_FLAG_CMD_CACHE;

    }



    hdr.oid = oid;

    hdr.data_length = datalen;

    hdr.offset = offset;

    hdr.copies = copies;



    ret = do_req(fd, (SheepdogReq *)&hdr, buf, &wlen, &rlen);

    if (ret) {

        error_report("failed to send a request to the sheep");

        return ret;

    }



    switch (rsp->result) {

    case SD_RES_SUCCESS:

        return 0;

    default:

        error_report("%s", sd_strerror(rsp->result));

        return -EIO;

    }

}

static int read_write_object(int fd, char *buf, uint64_t oid, int copies,

                             unsigned int datalen, uint64_t offset,

                             bool write, bool create, bool cache)

{

    SheepdogObjReq hdr;

    SheepdogObjRsp *rsp = (SheepdogObjRsp *)&hdr;

    unsigned int wlen, rlen;

    int ret;



    memset(&hdr, 0, sizeof(hdr));



    if (write) {

        wlen = datalen;

        rlen = 0;

        hdr.flags = SD_FLAG_CMD_WRITE;

        if (create) {

            hdr.opcode = SD_OP_CREATE_AND_WRITE_OBJ;

        } else {

            hdr.opcode = SD_OP_WRITE_OBJ;

        }

    } else {

        wlen = 0;

        rlen = datalen;

        hdr.opcode = SD_OP_READ_OBJ;

    }



    if (cache) {

        hdr.flags |= SD_FLAG_CMD_CACHE;

    }



    hdr.oid = oid;

    hdr.data_length = datalen;

    hdr.offset = offset;

    hdr.copies = copies;



    ret = do_req(fd, (SheepdogReq *)&hdr, buf, &wlen, &rlen);

    if (ret) {

        error_report("failed to send a request to the sheep");

        return ret;

    }



    switch (rsp->result) {

    case SD_RES_SUCCESS:

        return 0;

    default:

        error_report("%s", sd_strerror(rsp->result));

        return -EIO;

    }

}

static int FUNC_0(int VAR_0, char *VAR_1, uint64_t VAR_2, int VAR_3,

                             unsigned int VAR_4, uint64_t VAR_5,

                             bool VAR_6, bool VAR_7, bool VAR_8)

{

    SheepdogObjReq hdr;

    SheepdogObjRsp *rsp = (SheepdogObjRsp *)&hdr;

    unsigned int VAR_9, VAR_10;

    int VAR_11;



    memset(&hdr, 0, sizeof(hdr));



    if (VAR_6) {

        VAR_9 = VAR_4;

        VAR_10 = 0;

        hdr.flags = SD_FLAG_CMD_WRITE;

        if (VAR_7) {

            hdr.opcode = SD_OP_CREATE_AND_WRITE_OBJ;

        } else {

            hdr.opcode = SD_OP_WRITE_OBJ;

        }

    } else {

        VAR_9 = 0;

        VAR_10 = VAR_4;

        hdr.opcode = SD_OP_READ_OBJ;

    }



    if (VAR_8) {

        hdr.flags |= SD_FLAG_CMD_CACHE;

    }



    hdr.VAR_2 = VAR_2;

    hdr.data_length = VAR_4;

    hdr.VAR_5 = VAR_5;

    hdr.VAR_3 = VAR_3;



    VAR_11 = do_req(VAR_0, (SheepdogReq *)&hdr, VAR_1, &VAR_9, &VAR_10);

    if (VAR_11) {

        error_report("failed to send a request to the sheep");

        return VAR_11;

    }



    switch (rsp->result) {

    case SD_RES_SUCCESS:

        return 0;

    default:

        error_report("%s", sd_strerror(rsp->result));

        return -EIO;

    }

}

static int FUNC_0(int VAR_0, char *VAR_1, uint64_t VAR_2, int VAR_3,
unsigned int VAR_4, uint64_t VAR_5,
bool VAR_6, bool VAR_7, bool VAR_8)
{ SheepdogObjReq hdr; SheepdogObjRsp *rsp = (SheepdogObjRsp *)&hdr; unsigned int VAR_9, VAR_10; int VAR_11; memset(&hdr, 0, sizeof(hdr)); if (VAR_6) { VAR_9 = VAR_4; VAR_10 = 0; hdr.flags = SD_FLAG_CMD_WRITE; if (VAR_7) { hdr.opcode = SD_OP_CREATE_AND_WRITE_OBJ; } else { hdr.opcode = SD_OP_WRITE_OBJ; } } else { VAR_9 = 0; VAR_10 = VAR_4; hdr.opcode = SD_OP_READ_OBJ; } if (VAR_8) { hdr.flags |= SD_FLAG_CMD_CACHE; } hdr.VAR_2 = VAR_2; hdr.data_length = VAR_4; hdr.VAR_5 = VAR_5; hdr.VAR_3 = VAR_3; VAR_11 = do_req(VAR_0, (SheepdogReq *)&hdr, VAR_1, &VAR_9, &VAR_10); if (VAR_11) { error_report("failed to send a request to the sheep"); return VAR_11; } switch (rsp->result) { case SD_RES_SUCCESS:
return 0; default:
error_report("%s", sd_strerror(rsp->result)); return -EIO; } }