Skip to contentSkip to conversation

osdep: Less restrictive F_SEFL in qemu_dup_flags()

PATCH Applied Corey Bryant 2 participants 2 messages Oct 18, 2012 – Oct 23, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 osdep: Less restrictive F_SEFL in qemu_dup_flags()

qemu_dup_flags() currently limits the flags that can be set on the fcntl() F_SETFL call to those that we currently know can be set with fcntl() F_SETFL. The problem with this is that it will prevent use of new flags in the future without a code update.

This patch relaxes the checking and lets fcntl() determine the flags it can set.

---
 osdep.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
osdep.c +1 -11
index 3b25297..c822a01 100644
@@ -88,7 +88,6 @@ static int qemu_dup_flags(int fd, int flags)
     int ret;
     int serrno;
     int dup_flags;
-    int setfl_flags;
 
 #ifdef F_DUPFD_CLOEXEC
     ret = fcntl(fd, F_DUPFD_CLOEXEC, 0);
@@ -113,16 +112,7 @@ static int qemu_dup_flags(int fd, int flags)
     }
 
     /* Set/unset flags that we can with fcntl */
-    setfl_flags = O_APPEND | O_ASYNC | O_NONBLOCK;
-#ifdef O_NOATIME
-    setfl_flags |= O_NOATIME;
-#endif
-#ifdef O_DIRECT
-    setfl_flags |= O_DIRECT;
-#endif
-    dup_flags &= ~setfl_flags;
-    dup_flags |= (flags & setfl_flags);
-    if (fcntl(ret, F_SETFL, dup_flags) == -1) {
+    if (fcntl(ret, F_SETFL, flags) == -1) {
         goto fail;
     }
 
Signature · 1 line
1.7.11.4
Applied
#1 lore raw

Am 18.10.2012 22:41, schrieb Corey Bryant:

Quoted 9 lines

qemu_dup_flags() currently limits the flags that can be set on the fcntl() F_SETFL call to those that we currently know can be set with fcntl() F_SETFL. The problem with this is that it will prevent use of new flags in the future without a code update.

This patch relaxes the checking and lets fcntl() determine the flags it can set.

Thanks, applied to the block branch.

Kevin