@cryptotaxi247 / kubo / commits / 01f9ef3c5

added fuseversion for osxfuse

Juan Batiz-Benet committed Jan 10, 2015 at 01:06 UTC 01f9ef3c54502666b9d83f09e05c8a953ae2eee3
10 files changed +162
Godeps/Godeps.json
+4
@@ -108,6 +108,10 @@
108 "ImportPath": "github.com/jbenet/go-datastore",
109 "Rev": "6a1c83bda2a71a9bdc936749fdb507df958ed949"
110 },
111 + {
112 + "ImportPath": "github.com/jbenet/go-fuse-version",
113 + "Rev": "ff72c39433f95ada15f116fa493a51eeec2bd52e"
114 + },
115 {
116 "ImportPath": "github.com/jbenet/go-is-domain",
117 "Rev": "93b717f2ae17838a265e30277275ee99ee7198d6"
Godeps/_workspace/src/github.com/jbenet/go-fuse-version/README.md new
+45
@@ -0,0 +1,45 @@
1 +# go-fuse-version
2 +
3 +Simple package to get the user's FUSE libraries information.
4 +
5 +- Godoc: https://godoc.org/github.com/jbenet/go-fuse-version
6 +
7 +**Warning** Currently only supports OSXFUSE. if you want more, add them, it's really trivial now.
8 +
9 +## Example
10 +
11 +```Go
12 +package main
13 +
14 +import (
15 + "fmt"
16 + "os"
17 +
18 + fuseversion "github.com/jbenet/go-fuse-version"
19 +)
20 +
21 +func main() {
22 + sys, err := fuseversion.LocalFuseSystems()
23 + if err != nil {
24 + fmt.Fprintf(os.Stderr, "%s\n", err)
25 + os.Exit(1)
26 + }
27 +
28 + fmt.Printf("FuseVersion, AgentVersion, Agent\n")
29 + for _, s := range *sys {
30 + fmt.Printf("%s, %s, %s\n", s.FuseVersion, s.AgentVersion, s.AgentName)
31 + }
32 +}
33 +```
34 +
35 +## fuseprint
36 +
37 +If you dont use Go, you can also install the example as the silly util fuseprint:
38 +
39 +```
40 +> go get github.com/jbenet/go-fuse-version/fuseprint
41 +> go install github.com/jbenet/go-fuse-version/fuseprint
42 +> fuseprint
43 +FuseVersion, AgentVersion, Agent
44 +27, 2.7.2, OSXFUSE
45 +```
Godeps/_workspace/src/github.com/jbenet/go-fuse-version/fuseprint/.gitignore new
+1
@@ -0,0 +1 @@
1 +fuseprint
Godeps/_workspace/src/github.com/jbenet/go-fuse-version/fuseprint/README.md new
+1
@@ -0,0 +1 @@
1 +../README.md
\ No newline at end of file
Godeps/_workspace/src/github.com/jbenet/go-fuse-version/fuseprint/index.go new
+21
@@ -0,0 +1,21 @@
1 +package main
2 +
3 +import (
4 + "fmt"
5 + "os"
6 +
7 + fuseversion "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-fuse-version"
8 +)
9 +
10 +func main() {
11 + sys, err := fuseversion.LocalFuseSystems()
12 + if err != nil {
13 + fmt.Fprintf(os.Stderr, "%s\n", err)
14 + os.Exit(1)
15 + }
16 +
17 + fmt.Printf("FuseVersion, AgentVersion, Agent\n")
18 + for _, s := range *sys {
19 + fmt.Printf("%s, %s, %s\n", s.FuseVersion, s.AgentVersion, s.AgentName)
20 + }
21 +}
Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version.go new
+37
@@ -0,0 +1,37 @@
1 +// package fuseversion simply exposes the version of FUSE installed
2 +// in the user's machine. For reasoning, see:
3 +// - https://github.com/jbenet/go-ipfs/issues/177
4 +// - https://github.com/jbenet/go-ipfs/issues/202
5 +// - https://github.com/osxfuse/osxfuse/issues/175#issuecomment-61888505
6 +package fuseversion
7 +
8 +type Systems map[string]FuseSystem
9 +
10 +type FuseSystem struct {
11 + // FuseVersion is the version of the FUSE protocol
12 + FuseVersion string
13 +
14 + // AgentName identifies the system implementing FUSE, or Agent
15 + AgentName string
16 +
17 + // AgentVersion is the version of the Agent program
18 + // (it fights for the user! Sometimes it fights the user...)
19 + AgentVersion string
20 +}
21 +
22 +// LocalFuseSystems returns a map of FuseSystems, keyed by name.
23 +// For example:
24 +//
25 +// systems := fuseversion.LocalFuseSystems()
26 +// for n, sys := range systems {
27 +// fmt.Printf("%s, %s, %s", n, sys.FuseVersion, sys.AgentVersion)
28 +// }
29 +// // Outputs:
30 +// // OSXFUSE, , 2.7.2
31 +//
32 +func LocalFuseSystems() (*Systems, error) {
33 + return getLocalFuseSystems() // implemented by each platform
34 +}
35 +
36 +var notImplYet = `Error: not implemented for %s yet. :(
37 +Please do it: https://github.com/jbenet/go-fuse-version`
Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_bsd.go new
+11
@@ -0,0 +1,11 @@
1 +// +build dragonfly freebsd netbsd openbsd
2 +
3 +package fuseversion
4 +
5 +import (
6 + "runtime"
7 +)
8 +
9 +func getLocalFuseSystems() (*Systems, error) {
10 + return nil, fmt.Sprintf(notImplYet, runtime.GOARCH())
11 +}
Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_darwin.go new
+24
@@ -0,0 +1,24 @@
1 +package fuseversion
2 +
3 +// #cgo CFLAGS: -I /usr/local/include/osxfuse/ -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=25
4 +// #cgo LDFLAGS: /usr/local/lib/libosxfuse.dylib
5 +//
6 +// #include <fuse/fuse.h>
7 +// #include <fuse/fuse_common.h>
8 +// #include <fuse/fuse_darwin.h>
9 +import "C"
10 +import "fmt"
11 +
12 +func getLocalFuseSystems() (*Systems, error) {
13 + sys := Systems{}
14 + sys["OSXFUSE"] = getOSXFUSE()
15 + return &sys, nil
16 +}
17 +
18 +func getOSXFUSE() FuseSystem {
19 + return FuseSystem{
20 + FuseVersion: fmt.Sprintf("%d", int(C.fuse_version())),
21 + AgentName: "OSXFUSE",
22 + AgentVersion: C.GoString(C.osxfuse_version()),
23 + }
24 +}
Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_linux.go new
+9
@@ -0,0 +1,9 @@
1 +package fuseversion
2 +
3 +import (
4 + "runtime"
5 +)
6 +
7 +func getLocalFuseSystems() (*Systems, error) {
8 + return nil, fmt.Sprintf(notImplYet, runtime.GOARCH())
9 +}
Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_windows.go new
+9
@@ -0,0 +1,9 @@
1 +package fuseversion
2 +
3 +import (
4 + "runtime"
5 +)
6 +
7 +func getLocalFuseSystems() (*Systems, error) {
8 + return nil, fmt.Sprintf(notImplYet, runtime.GOARCH())
9 +}