Commit 6165f4d8 authored by Corey Bryant's avatar Corey Bryant Committed by Kevin Wolf
Browse files

block: Convert open calls to qemu_open



This patch converts all block layer open calls to qemu_open.

Note that this adds the O_CLOEXEC flag to the changed open paths
when the O_CLOEXEC macro is defined.

Signed-off-by: default avatarCorey Bryant <coreyb@linux.vnet.ibm.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent e1740828
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -572,7 +572,7 @@ static int raw_create(const char *filename, QEMUOptionParameter *options)
        options++;
    }

    fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
    fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
                   0644);
    if (fd < 0) {
        result = -errno;
@@ -846,7 +846,7 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
        if ( bsdPath[ 0 ] != '\0' ) {
            strcat(bsdPath,"s0");
            /* some CDs don't have a partition 0 */
            fd = open(bsdPath, O_RDONLY | O_BINARY | O_LARGEFILE);
            fd = qemu_open(bsdPath, O_RDONLY | O_BINARY | O_LARGEFILE);
            if (fd < 0) {
                bsdPath[strlen(bsdPath)-1] = '1';
            } else {
@@ -903,7 +903,7 @@ static int fd_open(BlockDriverState *bs)
#endif
            return -EIO;
        }
        s->fd = open(bs->filename, s->open_flags & ~O_NONBLOCK);
        s->fd = qemu_open(bs->filename, s->open_flags & ~O_NONBLOCK);
        if (s->fd < 0) {
            s->fd_error_time = get_clock();
            s->fd_got_error = 1;
@@ -977,7 +977,7 @@ static int hdev_create(const char *filename, QEMUOptionParameter *options)
        options++;
    }

    fd = open(filename, O_WRONLY | O_BINARY);
    fd = qemu_open(filename, O_WRONLY | O_BINARY);
    if (fd < 0)
        return -errno;

@@ -1057,7 +1057,7 @@ static int floppy_probe_device(const char *filename)
        prio = 50;
    }

    fd = open(filename, O_RDONLY | O_NONBLOCK);
    fd = qemu_open(filename, O_RDONLY | O_NONBLOCK);
    if (fd < 0) {
        goto out;
    }
@@ -1110,7 +1110,7 @@ static void floppy_eject(BlockDriverState *bs, bool eject_flag)
        close(s->fd);
        s->fd = -1;
    }
    fd = open(bs->filename, s->open_flags | O_NONBLOCK);
    fd = qemu_open(bs->filename, s->open_flags | O_NONBLOCK);
    if (fd >= 0) {
        if (ioctl(fd, FDEJECT, 0) < 0)
            perror("FDEJECT");
@@ -1160,7 +1160,7 @@ static int cdrom_probe_device(const char *filename)
    int prio = 0;
    struct stat st;

    fd = open(filename, O_RDONLY | O_NONBLOCK);
    fd = qemu_open(filename, O_RDONLY | O_NONBLOCK);
    if (fd < 0) {
        goto out;
    }
@@ -1284,7 +1284,7 @@ static int cdrom_reopen(BlockDriverState *bs)
     */
    if (s->fd >= 0)
        close(s->fd);
    fd = open(bs->filename, s->open_flags, 0644);
    fd = qemu_open(bs->filename, s->open_flags, 0644);
    if (fd < 0) {
        s->fd = -1;
        return -EIO;
+2 −2
Original line number Diff line number Diff line
@@ -255,7 +255,7 @@ static int raw_create(const char *filename, QEMUOptionParameter *options)
        options++;
    }

    fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
    fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
                   0644);
    if (fd < 0)
        return -EIO;
+3 −2
Original line number Diff line number Diff line
@@ -653,7 +653,8 @@ static int vdi_create(const char *filename, QEMUOptionParameter *options)
        options++;
    }

    fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE,
    fd = qemu_open(filename,
                   O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE,
                   0644);
    if (fd < 0) {
        return -errno;
+9 −12
Original line number Diff line number Diff line
@@ -1161,8 +1161,7 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
    VMDK4Header header;
    uint32_t tmp, magic, grains, gd_size, gt_size, gt_count;

    fd = open(
        filename,
    fd = qemu_open(filename,
                   O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE,
                   0644);
    if (fd < 0) {
@@ -1484,13 +1483,11 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options)
            (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4),
            total_size / (int64_t)(63 * 16 * 512));
    if (split || flat) {
        fd = open(
                filename,
        fd = qemu_open(filename,
                       O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE,
                       0644);
    } else {
        fd = open(
                filename,
        fd = qemu_open(filename,
                       O_WRONLY | O_BINARY | O_LARGEFILE,
                       0644);
    }
+1 −1
Original line number Diff line number Diff line
@@ -678,7 +678,7 @@ static int vpc_create(const char *filename, QEMUOptionParameter *options)
    }

    /* Create the file */
    fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
    fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
    if (fd < 0) {
        return -EIO;
    }
Loading