Browse code

Merge pull request #9011 from vbatts/vbatts-btrfs_information

btrfs: information for the information gods

Jessie Frazelle authored on 2014/11/14 13:47:07
Showing 6 changed files
... ...
@@ -103,7 +103,7 @@ RUN useradd --create-home --gid docker unprivilegeduser
103 103
 
104 104
 VOLUME	/var/lib/docker
105 105
 WORKDIR	/go/src/github.com/docker/docker
106
-ENV	DOCKER_BUILDTAGS	apparmor selinux
106
+ENV	DOCKER_BUILDTAGS	apparmor selinux btrfs_noversion
107 107
 
108 108
 # Wrap all commands in the "docker-in-docker" script to allow nested containers
109 109
 ENTRYPOINT	["hack/dind"]
... ...
@@ -60,7 +60,14 @@ func (d *Driver) String() string {
60 60
 }
61 61
 
62 62
 func (d *Driver) Status() [][2]string {
63
-	return nil
63
+	status := [][2]string{}
64
+	if bv := BtrfsBuildVersion(); bv != "-" {
65
+		status = append(status, [2]string{"Build Version", bv})
66
+	}
67
+	if lv := BtrfsLibVersion(); lv != -1 {
68
+		status = append(status, [2]string{"Library Version", fmt.Sprintf("%d", lv)})
69
+	}
70
+	return status
64 71
 }
65 72
 
66 73
 func (d *Driver) Cleanup() error {
67 74
new file mode 100644
... ...
@@ -0,0 +1,24 @@
0
+// +build linux,!btrfs_noversion
1
+
2
+package btrfs
3
+
4
+/*
5
+#include <btrfs/version.h>
6
+
7
+// because around version 3.16, they did not define lib version yet
8
+int my_btrfs_lib_version() {
9
+#ifdef BTRFS_LIB_VERSION
10
+  return BTRFS_LIB_VERSION;
11
+#else
12
+  return -1;
13
+#endif
14
+}
15
+*/
16
+import "C"
17
+
18
+func BtrfsBuildVersion() string {
19
+	return string(C.BTRFS_BUILD_VERSION)
20
+}
21
+func BtrfsLibVersion() int {
22
+	return int(C.BTRFS_LIB_VERSION)
23
+}
0 24
new file mode 100644
... ...
@@ -0,0 +1,13 @@
0
+// +build linux,btrfs_noversion
1
+
2
+package btrfs
3
+
4
+// TODO(vbatts) remove this work-around once supported linux distros are on
5
+// btrfs utililties of >= 3.16.1
6
+
7
+func BtrfsBuildVersion() string {
8
+	return "-"
9
+}
10
+func BtrfsLibVersion() int {
11
+	return -1
12
+}
0 13
new file mode 100644
... ...
@@ -0,0 +1,13 @@
0
+// +build linux
1
+
2
+package btrfs
3
+
4
+import (
5
+	"testing"
6
+)
7
+
8
+func TestBuildVersion(t *testing.T) {
9
+	if len(BtrfsBuildVersion()) == 0 {
10
+		t.Errorf("expected output from btrfs build version, but got empty string")
11
+	}
12
+}
... ...
@@ -162,6 +162,12 @@ SELinux, you will need to use the `selinux` build tag:
162 162
 export DOCKER_BUILDTAGS='selinux'
163 163
 ```
164 164
 
165
+If your version of btrfs-progs is < 3.16.1 (also called btrfs-tools), then you
166
+will need the following tag to not check for btrfs version headers:
167
+```bash
168
+export DOCKER_BUILDTAGS='btrfs_noversion'
169
+```
170
+
165 171
 There are build tags for disabling graphdrivers as well. By default, support
166 172
 for all graphdrivers are built in.
167 173