[lxc-devel] [lxd/master] gpu: fallback to default device mode

brauner on Github lxc-bot at linuxcontainers.org
Mon May 28 09:17:09 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 475 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180528/1b174e1b/attachment.bin>
-------------- next part --------------
From bf5430038262a1174ce46ad9838a3544ee1565ff Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Mon, 28 May 2018 11:15:56 +0200
Subject: [PATCH] gpu: fallback to default device mode

When the device in question does not exist we should fallback to the default
device mode.

Closes #4591.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 lxd/container_lxc.go | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 5371f214a..7310ba142 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -6204,7 +6204,11 @@ func (c *containerLXC) createUnixDevice(prefix string, m types.Device, defaultMo
 	} else if !defaultMode {
 		mode, err = shared.GetPathMode(srcPath)
 		if err != nil {
-			return nil, fmt.Errorf("Failed to retrieve mode of device %s: %s", m["path"], err)
+			errno, isErrno := shared.GetErrno(err)
+			if !isErrno || errno != syscall.ENOENT {
+				return nil, fmt.Errorf("Failed to retrieve mode of device %s: %s", m["path"], err)
+			}
+			mode = os.FileMode(0660)
 		}
 	}
 


More information about the lxc-devel mailing list