Browse code

Improve zfs init log message for zfs

Signed-off-by: Drew Hubl <drew.hubl@gmail.com>
Signed-off-by: Brian Goff <cpuguy83@gmail.com>

Drew Hubl authored on 2017/07/24 16:23:45
Showing 1 changed files
... ...
@@ -1,21 +1,22 @@
1 1
 package zfs
2 2
 
3 3
 import (
4
-	"fmt"
5
-
6 4
 	"github.com/docker/docker/daemon/graphdriver"
7 5
 	"github.com/sirupsen/logrus"
8
-	"golang.org/x/sys/unix"
9 6
 )
10 7
 
11
-func checkRootdirFs(rootdir string) error {
12
-	var buf unix.Statfs_t
13
-	if err := unix.Statfs(rootdir, &buf); err != nil {
14
-		return fmt.Errorf("Failed to access '%s': %s", rootdir, err)
8
+func checkRootdirFs(rootDir string) error {
9
+	fsMagic, err := graphdriver.GetFSMagic(rootDir)
10
+	if err != nil {
11
+		return err
12
+	}
13
+	backingFS := "unknown"
14
+	if fsName, ok := graphdriver.FsNames[fsMagic]; ok {
15
+		backingFS = fsName
15 16
 	}
16 17
 
17
-	if graphdriver.FsMagic(buf.Type) != graphdriver.FsMagicZfs {
18
-		logrus.Debugf("[zfs] no zfs dataset found for rootdir '%s'", rootdir)
18
+	if fsMagic != graphdriver.FsMagicZfs {
19
+		logrus.WithField("root", rootDir).WithField("backingFS", backingFS).WithField("driver", "zfs").Error("No zfs dataset found for root")
19 20
 		return graphdriver.ErrPrerequisites
20 21
 	}
21 22