The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7600

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From 7f28fe06cf7888589e8d4fdaa65d537490c45438 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Tue, 30 Jun 2020 16:17:27 -0400
Subject: [PATCH] lxd/storage: Fix regression in truncate handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/storage/drivers/utils.go | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/lxd/storage/drivers/utils.go b/lxd/storage/drivers/utils.go
index 988bf98208..d4539b693b 100644
--- a/lxd/storage/drivers/utils.go
+++ b/lxd/storage/drivers/utils.go
@@ -295,17 +295,12 @@ func deleteParentSnapshotDirIfEmpty(poolName string, 
volType VolumeType, volName
 // ensureSparseFile creates a sparse empty file at specified location with 
specified size.
 // If the path already exists, the file is truncated to the requested size.
 func ensureSparseFile(filePath string, sizeBytes int64) error {
-       f, err := os.Create(filePath)
+       f, err := os.OpenFile(filePath, os.O_RDWR|os.O_CREATE, 0600)
        if err != nil {
                return errors.Wrapf(err, "Failed to open %s", filePath)
        }
        defer f.Close()
 
-       err = f.Chmod(0600)
-       if err != nil {
-               return errors.Wrapf(err, "Failed to chmod %s", filePath)
-       }
-
        err = f.Truncate(sizeBytes)
        if err != nil {
                return errors.Wrapf(err, "Failed to create sparse file %s", 
filePath)
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to