static int hdev_create(const char *filename, QEMUOptionParameter *options)

{

    int fd;

    int ret = 0;

    struct stat stat_buf;

    int64_t total_size = 0;



    /* Read out options */

    while (options && options->name) {

        if (!strcmp(options->name, "size")) {

            total_size = options->value.n / 512;

        }

        options++;

    }



    fd = open(filename, O_WRONLY | O_BINARY);

    if (fd < 0)

        return -EIO;



    if (fstat(fd, &stat_buf) < 0)

        ret = -EIO;

    else if (!S_ISBLK(stat_buf.st_mode))

        ret = -EIO;

    else if (lseek(fd, 0, SEEK_END) < total_size * 512)

        ret = -ENOSPC;



    close(fd);

    return ret;

}

static int hdev_create(const char *filename, QEMUOptionParameter *options)

{

    int fd;

    int ret = 0;

    struct stat stat_buf;

    int64_t total_size = 0;



    

    while (options && options->name) {

        if (!strcmp(options->name, "size")) {

            total_size = options->value.n / 512;

        }

        options++;

    }



    fd = open(filename, O_WRONLY | O_BINARY);

    if (fd < 0)

        return -EIO;



    if (fstat(fd, &stat_buf) < 0)

        ret = -EIO;

    else if (!S_ISBLK(stat_buf.st_mode))

        ret = -EIO;

    else if (lseek(fd, 0, SEEK_END) < total_size * 512)

        ret = -ENOSPC;



    close(fd);

    return ret;

}

static int FUNC_0(const char *VAR_0, QEMUOptionParameter *VAR_1)

{

    int VAR_2;

    int VAR_3 = 0;

    struct stat VAR_4;

    int64_t total_size = 0;



    

    while (VAR_1 && VAR_1->name) {

        if (!strcmp(VAR_1->name, "size")) {

            total_size = VAR_1->value.n / 512;

        }

        VAR_1++;

    }



    VAR_2 = open(VAR_0, O_WRONLY | O_BINARY);

    if (VAR_2 < 0)

        return -EIO;



    if (fstat(VAR_2, &VAR_4) < 0)

        VAR_3 = -EIO;

    else if (!S_ISBLK(VAR_4.st_mode))

        VAR_3 = -EIO;

    else if (lseek(VAR_2, 0, SEEK_END) < total_size * 512)

        VAR_3 = -ENOSPC;



    close(VAR_2);

    return VAR_3;

}

static int FUNC_0(const char *VAR_0, QEMUOptionParameter *VAR_1)
{ int VAR_2; int VAR_3 = 0; struct stat VAR_4; int64_t total_size = 0; while (VAR_1 && VAR_1->name) { if (!strcmp(VAR_1->name, "size")) { total_size = VAR_1->value.n / 512; } VAR_1++; } VAR_2 = open(VAR_0, O_WRONLY | O_BINARY); if (VAR_2 < 0)
return -EIO; if (fstat(VAR_2, &VAR_4) < 0)
VAR_3 = -EIO; else if (!S_ISBLK(VAR_4.st_mode))
VAR_3 = -EIO; else if (lseek(VAR_2, 0, SEEK_END) < total_size * 512)
VAR_3 = -ENOSPC; close(VAR_2); return VAR_3; }