From 318b11f62fe0f16a190e85e3cfe5d01432bf92a9 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Thu, 6 Nov 2014 15:04:10 -0500 Subject: [PATCH 1/3] btrfs: information for the information gods Signed-off-by: Vincent Batts --- daemon/graphdriver/btrfs/btrfs.go | 5 ++++- daemon/graphdriver/btrfs/version.go | 15 +++++++++++++++ daemon/graphdriver/btrfs/version_test.go | 13 +++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 daemon/graphdriver/btrfs/version.go create mode 100644 daemon/graphdriver/btrfs/version_test.go diff --git a/daemon/graphdriver/btrfs/btrfs.go b/daemon/graphdriver/btrfs/btrfs.go index 954cf9b245..ef77ae9158 100644 --- a/daemon/graphdriver/btrfs/btrfs.go +++ b/daemon/graphdriver/btrfs/btrfs.go @@ -60,7 +60,10 @@ func (d *Driver) String() string { } func (d *Driver) Status() [][2]string { - return nil + return [][2]string{ + {"Build Version", BtrfsBuildVersion()}, + {"Library Version", fmt.Sprintf("%d", BtrfsLibVersion())}, + } } func (d *Driver) Cleanup() error { diff --git a/daemon/graphdriver/btrfs/version.go b/daemon/graphdriver/btrfs/version.go new file mode 100644 index 0000000000..1b2b148c07 --- /dev/null +++ b/daemon/graphdriver/btrfs/version.go @@ -0,0 +1,15 @@ +// +build linux + +package btrfs + +/* +#include +*/ +import "C" + +func BtrfsBuildVersion() string { + return string(C.BTRFS_BUILD_VERSION) +} +func BtrfsLibVersion() int { + return int(C.BTRFS_LIB_VERSION) +} diff --git a/daemon/graphdriver/btrfs/version_test.go b/daemon/graphdriver/btrfs/version_test.go new file mode 100644 index 0000000000..d96e33f3df --- /dev/null +++ b/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") + } +} From 25154682a5cd57aa4fc3ef88baeee3ce1f204060 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Thu, 6 Nov 2014 15:56:13 -0500 Subject: [PATCH 2/3] btrfs: build tag to enable showing version info be default it is on, with build tags to disable the version info Signed-off-by: Vincent Batts --- daemon/graphdriver/btrfs/btrfs.go | 10 +++++++--- daemon/graphdriver/btrfs/version.go | 11 ++++++++++- daemon/graphdriver/btrfs/version_none.go | 13 +++++++++++++ hack/PACKAGERS.md | 6 ++++++ 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 daemon/graphdriver/btrfs/version_none.go diff --git a/daemon/graphdriver/btrfs/btrfs.go b/daemon/graphdriver/btrfs/btrfs.go index ef77ae9158..a3964b963c 100644 --- a/daemon/graphdriver/btrfs/btrfs.go +++ b/daemon/graphdriver/btrfs/btrfs.go @@ -60,10 +60,14 @@ func (d *Driver) String() string { } func (d *Driver) Status() [][2]string { - return [][2]string{ - {"Build Version", BtrfsBuildVersion()}, - {"Library Version", fmt.Sprintf("%d", BtrfsLibVersion())}, + 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 { diff --git a/daemon/graphdriver/btrfs/version.go b/daemon/graphdriver/btrfs/version.go index 1b2b148c07..89ed85749d 100644 --- a/daemon/graphdriver/btrfs/version.go +++ b/daemon/graphdriver/btrfs/version.go @@ -1,9 +1,18 @@ -// +build linux +// +build linux,!btrfs_noversion package btrfs /* #include + +// 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" diff --git a/daemon/graphdriver/btrfs/version_none.go b/daemon/graphdriver/btrfs/version_none.go new file mode 100644 index 0000000000..69a4e51cf8 --- /dev/null +++ b/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 +} diff --git a/hack/PACKAGERS.md b/hack/PACKAGERS.md index 265f7d676b..65bf60cd03 100644 --- a/hack/PACKAGERS.md +++ b/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. From d7c37b5a28de6e7c0a9270815c092a45d8d7fef7 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Thu, 13 Nov 2014 16:25:10 -0500 Subject: [PATCH 3/3] Dockerfile: buildtags for old btrfs Since the build uses ubuntu 14.04, which has an old btrfs, include the buildtags needed for this old version to not break the build. Signed-off-by: Vincent Batts --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e1c6236da8..43e15b31d4 100644 --- a/Dockerfile +++ b/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"]