Forráskód Böngészése

Merge pull request #9011 from vbatts/vbatts-btrfs_information

btrfs: information for the information gods
Jessie Frazelle 10 éve
szülő
commit
870a695375

+ 1 - 1
Dockerfile

@@ -103,7 +103,7 @@ RUN useradd --create-home --gid docker unprivilegeduser
 
 VOLUME	/var/lib/docker
 WORKDIR	/go/src/github.com/docker/docker
-ENV	DOCKER_BUILDTAGS	apparmor selinux
+ENV	DOCKER_BUILDTAGS	apparmor selinux btrfs_noversion
 
 # Wrap all commands in the "docker-in-docker" script to allow nested containers
 ENTRYPOINT	["hack/dind"]

+ 8 - 1
daemon/graphdriver/btrfs/btrfs.go

@@ -60,7 +60,14 @@ func (d *Driver) String() string {
 }
 
 func (d *Driver) Status() [][2]string {
-	return nil
+	status := [][2]string{}
+	if bv := BtrfsBuildVersion(); bv != "-" {
+		status = append(status, [2]string{"Build Version", bv})
+	}
+	if lv := BtrfsLibVersion(); lv != -1 {
+		status = append(status, [2]string{"Library Version", fmt.Sprintf("%d", lv)})
+	}
+	return status
 }
 
 func (d *Driver) Cleanup() error {

+ 24 - 0
daemon/graphdriver/btrfs/version.go

@@ -0,0 +1,24 @@
+// +build linux,!btrfs_noversion
+
+package btrfs
+
+/*
+#include <btrfs/version.h>
+
+// because around version 3.16, they did not define lib version yet
+int my_btrfs_lib_version() {
+#ifdef BTRFS_LIB_VERSION
+  return BTRFS_LIB_VERSION;
+#else
+  return -1;
+#endif
+}
+*/
+import "C"
+
+func BtrfsBuildVersion() string {
+	return string(C.BTRFS_BUILD_VERSION)
+}
+func BtrfsLibVersion() int {
+	return int(C.BTRFS_LIB_VERSION)
+}

+ 13 - 0
daemon/graphdriver/btrfs/version_none.go

@@ -0,0 +1,13 @@
+// +build linux,btrfs_noversion
+
+package btrfs
+
+// TODO(vbatts) remove this work-around once supported linux distros are on
+// btrfs utililties of >= 3.16.1
+
+func BtrfsBuildVersion() string {
+	return "-"
+}
+func BtrfsLibVersion() int {
+	return -1
+}

+ 13 - 0
daemon/graphdriver/btrfs/version_test.go

@@ -0,0 +1,13 @@
+// +build linux
+
+package btrfs
+
+import (
+	"testing"
+)
+
+func TestBuildVersion(t *testing.T) {
+	if len(BtrfsBuildVersion()) == 0 {
+		t.Errorf("expected output from btrfs build version, but got empty string")
+	}
+}

+ 6 - 0
hack/PACKAGERS.md

@@ -162,6 +162,12 @@ SELinux, you will need to use the `selinux` build tag:
 export DOCKER_BUILDTAGS='selinux'
 ```
 
+If your version of btrfs-progs is < 3.16.1 (also called btrfs-tools), then you
+will need the following tag to not check for btrfs version headers:
+```bash
+export DOCKER_BUILDTAGS='btrfs_noversion'
+```
+
 There are build tags for disabling graphdrivers as well. By default, support
 for all graphdrivers are built in.