cryptospore / rpms / qemu-kvm

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