26ba25
From 36ce5f680149086b2feda220735255c2b31b0e00 Mon Sep 17 00:00:00 2001
26ba25
From: Max Reitz <mreitz@redhat.com>
26ba25
Date: Mon, 9 Jul 2018 15:11:21 +0200
26ba25
Subject: [PATCH 203/268] file-posix: Fix creation locking
26ba25
26ba25
RH-Author: Max Reitz <mreitz@redhat.com>
26ba25
Message-id: <20180709151122.27541-2-mreitz@redhat.com>
26ba25
Patchwork-id: 81271
26ba25
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 1/2] file-posix: Fix creation locking
26ba25
Bugzilla: 1599335
26ba25
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
26ba25
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
26ba25
RH-Acked-by: John Snow <jsnow@redhat.com>
26ba25
26ba25
raw_apply_lock_bytes() takes a bit mask of "permissions that are NOT
26ba25
shared".
26ba25
26ba25
Also, make the "perm" and "shared" variables uint64_t, because I do not
26ba25
particularly like using ~ on signed integers (and other permission masks
26ba25
are usually uint64_t, too).
26ba25
26ba25
Reported-by: Kevin Wolf <kwolf@redhat.com>
26ba25
Signed-off-by: Max Reitz <mreitz@redhat.com>
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
(cherry picked from commit d815efcaf01b1698e2fdf0f3e125201025c53191)
26ba25
Signed-off-by: Max Reitz <mreitz@redhat.com>
26ba25
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
---
26ba25
 block/file-posix.c | 4 ++--
26ba25
 1 file changed, 2 insertions(+), 2 deletions(-)
26ba25
26ba25
diff --git a/block/file-posix.c b/block/file-posix.c
26ba25
index 0a9df5b..e876770 100644
26ba25
--- a/block/file-posix.c
26ba25
+++ b/block/file-posix.c
26ba25
@@ -2052,7 +2052,7 @@ static int raw_co_create(BlockdevCreateOptions *options, Error **errp)
26ba25
 {
26ba25
     BlockdevCreateOptionsFile *file_opts;
26ba25
     int fd;
26ba25
-    int perm, shared;
26ba25
+    uint64_t perm, shared;
26ba25
     int result = 0;
26ba25
 
26ba25
     /* Validate options and set default values */
26ba25
@@ -2088,7 +2088,7 @@ static int raw_co_create(BlockdevCreateOptions *options, Error **errp)
26ba25
     shared = BLK_PERM_ALL & ~BLK_PERM_RESIZE;
26ba25
 
26ba25
     /* Step one: Take locks */
26ba25
-    result = raw_apply_lock_bytes(fd, perm, shared, false, errp);
26ba25
+    result = raw_apply_lock_bytes(fd, perm, ~shared, false, errp);
26ba25
     if (result < 0) {
26ba25
         goto out_close;
26ba25
     }
26ba25
-- 
26ba25
1.8.3.1
26ba25