int qemu_lock_fd_test(int fd, int64_t start, int64_t len, bool exclusive)

{

    int ret;

    struct flock fl = {

        .l_whence = SEEK_SET,

        .l_start  = start,

        .l_len    = len,

        .l_type   = exclusive ? F_WRLCK : F_RDLCK,

    };

    ret = fcntl(fd, QEMU_GETLK, &fl);

    if (ret == -1) {

        return -errno;

    } else {

        return fl.l_type == F_UNLCK ? 0 : -EAGAIN;

    }

}

int qemu_lock_fd_test(int fd, int64_t start, int64_t len, bool exclusive)

{

    int ret;

    struct flock fl = {

        .l_whence = SEEK_SET,

        .l_start  = start,

        .l_len    = len,

        .l_type   = exclusive ? F_WRLCK : F_RDLCK,

    };

    ret = fcntl(fd, QEMU_GETLK, &fl);

    if (ret == -1) {

        return -errno;

    } else {

        return fl.l_type == F_UNLCK ? 0 : -EAGAIN;

    }

}

int FUNC_0(int VAR_0, int64_t VAR_1, int64_t VAR_2, bool VAR_3)

{

    int VAR_4;

    struct flock VAR_5 = {

        .l_whence = SEEK_SET,

        .l_start  = VAR_1,

        .l_len    = VAR_2,

        .l_type   = VAR_3 ? F_WRLCK : F_RDLCK,

    };

    VAR_4 = fcntl(VAR_0, QEMU_GETLK, &VAR_5);

    if (VAR_4 == -1) {

        return -errno;

    } else {

        return VAR_5.l_type == F_UNLCK ? 0 : -EAGAIN;

    }

}

int FUNC_0(int VAR_0, int64_t VAR_1, int64_t VAR_2, bool VAR_3)
{ int VAR_4; struct flock VAR_5 = { .l_whence = SEEK_SET,
.l_start  = VAR_1,
.l_len    = VAR_2,
.l_type   = VAR_3 ? F_WRLCK : F_RDLCK,
}; VAR_4 = fcntl(VAR_0, QEMU_GETLK, &VAR_5); if (VAR_4 == -1) { return -errno; } else { return VAR_5.l_type == F_UNLCK ? 0 : -EAGAIN; } }