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

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) ===

From ec93b6c088dda4bfd93587d2dd6eb0295ea58f23 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 4 Dec 2019 13:53:05 -0500
Subject: [PATCH 1/2] lxd/util: Add HasFilesystem
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/util/kernel.go | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/lxd/util/kernel.go b/lxd/util/kernel.go
index 6f75915ba1..0272dd101e 100644
--- a/lxd/util/kernel.go
+++ b/lxd/util/kernel.go
@@ -1,7 +1,10 @@
 package util
 
 import (
+       "bufio"
        "fmt"
+       "os"
+       "strings"
 
        "github.com/lxc/lxd/shared"
 )
@@ -16,3 +19,26 @@ func LoadModule(module string) error {
        _, err := shared.RunCommand("modprobe", module)
        return err
 }
+
+// HasFilesystem checks whether a given filesystem is already supported
+// by the kernel. Note that if the filesystem is a module, you may need to
+// load it first.
+func HasFilesystem(filesystem string) bool {
+       file, err := os.Open("/proc/filesystems")
+       if err != nil {
+               return false
+       }
+       defer file.Close()
+
+       scanner := bufio.NewScanner(file)
+       for scanner.Scan() {
+               fields := strings.Fields(strings.TrimSpace(scanner.Text()))
+               entry := fields[len(fields)-1]
+
+               if entry == filesystem {
+                       return true
+               }
+       }
+
+       return false
+}

From 1c41bdf376ac398734580b972205f7a87a2b7d72 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 4 Dec 2019 13:53:16 -0500
Subject: [PATCH 2/2] lxd: Detect built-in shiftfs too
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #6545

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/daemon.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/daemon.go b/lxd/daemon.go
index 0e58df8b5d..c5416d7dfc 100644
--- a/lxd/daemon.go
+++ b/lxd/daemon.go
@@ -620,7 +620,7 @@ func (d *Daemon) init() error {
                logger.Infof(" - unprivileged file capabilities: no")
        }
 
-       if util.LoadModule("shiftfs") == nil {
+       if util.HasFilesystem("shiftfs") || util.LoadModule("shiftfs") == nil {
                d.os.Shiftfs = true
                logger.Infof(" - shiftfs support: yes")
        } else {
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to