Merge pull request #9011 from vbatts/vbatts-btrfs_information

btrfs: information for the information gods
This commit is contained in:
Jessie Frazelle
2014-11-13 20:47:07 -08:00
6 changed files with 65 additions and 2 deletions
+8 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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")
}
}