]> git.proxmox.com Git - qemu.git/blobdiff - cutils.c
blockdev: Clean up how readonly persists across virtual media change
[qemu.git] / cutils.c
index 7a2234646a0f019ebfe3fd15af7f07461639e772..036ae3ce317805089ff772818ee746402989923b 100644 (file)
--- a/cutils.c
+++ b/cutils.c
@@ -124,7 +124,7 @@ int qemu_fls(int i)
  */
 int qemu_fdatasync(int fd)
 {
-#ifdef _POSIX_SYNCHRONIZED_IO
+#ifdef CONFIG_FDATASYNC
     return fdatasync(fd);
 #else
     return fsync(fd);
@@ -233,3 +233,21 @@ void qemu_iovec_from_buffer(QEMUIOVector *qiov, const void *buf, size_t count)
         count -= copy;
     }
 }
+
+#ifndef _WIN32
+/* Sets a specific flag */
+int fcntl_setfl(int fd, int flag)
+{
+    int flags;
+
+    flags = fcntl(fd, F_GETFL);
+    if (flags == -1)
+        return -errno;
+
+    if (fcntl(fd, F_SETFL, flags | flag) == -1)
+        return -errno;
+
+    return 0;
+}
+#endif
+