diff mbox series

[PULL,v2,11/12] file-posix: Fix creation locking

Message ID 20180705102604.4986-12-kwolf@redhat.com
State New
Headers show
Series [PULL,v2,01/12] qemu-img: allow compressed not-in-order writes | expand

Commit Message

Kevin Wolf July 5, 2018, 10:26 a.m. UTC
From: Max Reitz <mreitz@redhat.com>

raw_apply_lock_bytes() takes a bit mask of "permissions that are NOT
shared".

Also, make the "perm" and "shared" variables uint64_t, because I do not
particularly like using ~ on signed integers (and other permission masks
are usually uint64_t, too).

Reported-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/file-posix.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/block/file-posix.c b/block/file-posix.c
index 829ee538d8..b57c58e80f 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -2112,7 +2112,7 @@  raw_co_create(BlockdevCreateOptions *options, Error **errp)
 {
     BlockdevCreateOptionsFile *file_opts;
     int fd;
-    int perm, shared;
+    uint64_t perm, shared;
     int result = 0;
 
     /* Validate options and set default values */
@@ -2148,7 +2148,7 @@  raw_co_create(BlockdevCreateOptions *options, Error **errp)
     shared = BLK_PERM_ALL & ~BLK_PERM_RESIZE;
 
     /* Step one: Take locks */
-    result = raw_apply_lock_bytes(fd, perm, shared, false, errp);
+    result = raw_apply_lock_bytes(fd, perm, ~shared, false, errp);
     if (result < 0) {
         goto out_close;
     }