static int create_fixed_disk(int fd, uint8_t *buf, int64_t total_size)

{

    int ret = -EIO;



    /* Add footer to total size */

    total_size += 512;

    if (ftruncate(fd, total_size) != 0) {

        ret = -errno;

        goto fail;

    }

    if (lseek(fd, -512, SEEK_END) < 0) {

        goto fail;

    }

    if (write(fd, buf, HEADER_SIZE) != HEADER_SIZE) {

        goto fail;

    }



    ret = 0;



 fail:

    return ret;

}

static int create_fixed_disk(int fd, uint8_t *buf, int64_t total_size)

{

    int ret = -EIO;



    

    total_size += 512;

    if (ftruncate(fd, total_size) != 0) {

        ret = -errno;

        goto fail;

    }

    if (lseek(fd, -512, SEEK_END) < 0) {

        goto fail;

    }

    if (write(fd, buf, HEADER_SIZE) != HEADER_SIZE) {

        goto fail;

    }



    ret = 0;



 fail:

    return ret;

}

static int FUNC_0(int VAR_0, uint8_t *VAR_1, int64_t VAR_2)

{

    int VAR_3 = -EIO;



    

    VAR_2 += 512;

    if (ftruncate(VAR_0, VAR_2) != 0) {

        VAR_3 = -errno;

        goto fail;

    }

    if (lseek(VAR_0, -512, SEEK_END) < 0) {

        goto fail;

    }

    if (write(VAR_0, VAR_1, HEADER_SIZE) != HEADER_SIZE) {

        goto fail;

    }



    VAR_3 = 0;



 fail:

    return VAR_3;

}

static int FUNC_0(int VAR_0, uint8_t *VAR_1, int64_t VAR_2)
{ int VAR_3 = -EIO; VAR_2 += 512; if (ftruncate(VAR_0, VAR_2) != 0) { VAR_3 = -errno; goto fail; } if (lseek(VAR_0, -512, SEEK_END) < 0) { goto fail; } if (write(VAR_0, VAR_1, HEADER_SIZE) != HEADER_SIZE) { goto fail; } VAR_3 = 0; fail:
return VAR_3; }