From 05a0a944ceb9e0c5d8697febcdc145ebfa899e56 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Sat, 10 Jan 2015 01:06:36 -0800 Subject: [PATCH 1/3] makefile: fix target in sharness tests --- test/sharness/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/sharness/Makefile b/test/sharness/Makefile index b314c6757..96f0462f3 100644 --- a/test/sharness/Makefile +++ b/test/sharness/Makefile @@ -9,6 +9,7 @@ T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)) BINS = bin/random bin/ipfs SHARNESS = lib/sharness/sharness.sh +IPFS_ROOT = ../.. all: clean deps $(T) aggregate @@ -30,7 +31,7 @@ $(SHARNESS): @echo "*** installing $@ ***" lib/install-sharness.sh -bin/%: +bin/%: $(IPFS_ROOT)/**/*.go @echo "*** installing $@ ***" cd .. && make $@ From 01f9ef3c54502666b9d83f09e05c8a953ae2eee3 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Sat, 10 Jan 2015 01:06:12 -0800 Subject: [PATCH 2/3] added fuseversion for osxfuse --- Godeps/Godeps.json | 4 ++ .../jbenet/go-fuse-version/README.md | 45 +++++++++++++++++++ .../go-fuse-version/fuseprint/.gitignore | 1 + .../go-fuse-version/fuseprint/README.md | 1 + .../jbenet/go-fuse-version/fuseprint/index.go | 21 +++++++++ .../jbenet/go-fuse-version/version.go | 37 +++++++++++++++ .../jbenet/go-fuse-version/version_bsd.go | 11 +++++ .../jbenet/go-fuse-version/version_darwin.go | 24 ++++++++++ .../jbenet/go-fuse-version/version_linux.go | 9 ++++ .../jbenet/go-fuse-version/version_windows.go | 9 ++++ 10 files changed, 162 insertions(+) create mode 100644 Godeps/_workspace/src/github.com/jbenet/go-fuse-version/README.md create mode 100644 Godeps/_workspace/src/github.com/jbenet/go-fuse-version/fuseprint/.gitignore create mode 120000 Godeps/_workspace/src/github.com/jbenet/go-fuse-version/fuseprint/README.md create mode 100644 Godeps/_workspace/src/github.com/jbenet/go-fuse-version/fuseprint/index.go create mode 100644 Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version.go create mode 100644 Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_bsd.go create mode 100644 Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_darwin.go create mode 100644 Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_linux.go create mode 100644 Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_windows.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index ada8c7bd1..f72ac9e6a 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -108,6 +108,10 @@ "ImportPath": "github.com/jbenet/go-datastore", "Rev": "6a1c83bda2a71a9bdc936749fdb507df958ed949" }, + { + "ImportPath": "github.com/jbenet/go-fuse-version", + "Rev": "ff72c39433f95ada15f116fa493a51eeec2bd52e" + }, { "ImportPath": "github.com/jbenet/go-is-domain", "Rev": "93b717f2ae17838a265e30277275ee99ee7198d6" diff --git a/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/README.md b/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/README.md new file mode 100644 index 000000000..e03afc0c7 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/README.md @@ -0,0 +1,45 @@ +# go-fuse-version + +Simple package to get the user's FUSE libraries information. + +- Godoc: https://godoc.org/github.com/jbenet/go-fuse-version + +**Warning** Currently only supports OSXFUSE. if you want more, add them, it's really trivial now. + +## Example + +```Go +package main + +import ( + "fmt" + "os" + + fuseversion "github.com/jbenet/go-fuse-version" +) + +func main() { + sys, err := fuseversion.LocalFuseSystems() + if err != nil { + fmt.Fprintf(os.Stderr, "%s\n", err) + os.Exit(1) + } + + fmt.Printf("FuseVersion, AgentVersion, Agent\n") + for _, s := range *sys { + fmt.Printf("%s, %s, %s\n", s.FuseVersion, s.AgentVersion, s.AgentName) + } +} +``` + +## fuseprint + +If you dont use Go, you can also install the example as the silly util fuseprint: + +``` +> go get github.com/jbenet/go-fuse-version/fuseprint +> go install github.com/jbenet/go-fuse-version/fuseprint +> fuseprint +FuseVersion, AgentVersion, Agent +27, 2.7.2, OSXFUSE +``` diff --git a/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/fuseprint/.gitignore b/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/fuseprint/.gitignore new file mode 100644 index 000000000..4778de0e4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/fuseprint/.gitignore @@ -0,0 +1 @@ +fuseprint diff --git a/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/fuseprint/README.md b/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/fuseprint/README.md new file mode 120000 index 000000000..32d46ee88 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/fuseprint/README.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/fuseprint/index.go b/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/fuseprint/index.go new file mode 100644 index 000000000..8e4e04aa6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/fuseprint/index.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "os" + + fuseversion "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-fuse-version" +) + +func main() { + sys, err := fuseversion.LocalFuseSystems() + if err != nil { + fmt.Fprintf(os.Stderr, "%s\n", err) + os.Exit(1) + } + + fmt.Printf("FuseVersion, AgentVersion, Agent\n") + for _, s := range *sys { + fmt.Printf("%s, %s, %s\n", s.FuseVersion, s.AgentVersion, s.AgentName) + } +} diff --git a/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version.go b/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version.go new file mode 100644 index 000000000..b46bd7db4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version.go @@ -0,0 +1,37 @@ +// package fuseversion simply exposes the version of FUSE installed +// in the user's machine. For reasoning, see: +// - https://github.com/jbenet/go-ipfs/issues/177 +// - https://github.com/jbenet/go-ipfs/issues/202 +// - https://github.com/osxfuse/osxfuse/issues/175#issuecomment-61888505 +package fuseversion + +type Systems map[string]FuseSystem + +type FuseSystem struct { + // FuseVersion is the version of the FUSE protocol + FuseVersion string + + // AgentName identifies the system implementing FUSE, or Agent + AgentName string + + // AgentVersion is the version of the Agent program + // (it fights for the user! Sometimes it fights the user...) + AgentVersion string +} + +// LocalFuseSystems returns a map of FuseSystems, keyed by name. +// For example: +// +// systems := fuseversion.LocalFuseSystems() +// for n, sys := range systems { +// fmt.Printf("%s, %s, %s", n, sys.FuseVersion, sys.AgentVersion) +// } +// // Outputs: +// // OSXFUSE, , 2.7.2 +// +func LocalFuseSystems() (*Systems, error) { + return getLocalFuseSystems() // implemented by each platform +} + +var notImplYet = `Error: not implemented for %s yet. :( +Please do it: https://github.com/jbenet/go-fuse-version` diff --git a/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_bsd.go b/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_bsd.go new file mode 100644 index 000000000..a1d2460c8 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_bsd.go @@ -0,0 +1,11 @@ +// +build dragonfly freebsd netbsd openbsd + +package fuseversion + +import ( + "runtime" +) + +func getLocalFuseSystems() (*Systems, error) { + return nil, fmt.Sprintf(notImplYet, runtime.GOARCH()) +} diff --git a/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_darwin.go b/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_darwin.go new file mode 100644 index 000000000..84325578b --- /dev/null +++ b/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_darwin.go @@ -0,0 +1,24 @@ +package fuseversion + +// #cgo CFLAGS: -I /usr/local/include/osxfuse/ -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=25 +// #cgo LDFLAGS: /usr/local/lib/libosxfuse.dylib +// +// #include +// #include +// #include +import "C" +import "fmt" + +func getLocalFuseSystems() (*Systems, error) { + sys := Systems{} + sys["OSXFUSE"] = getOSXFUSE() + return &sys, nil +} + +func getOSXFUSE() FuseSystem { + return FuseSystem{ + FuseVersion: fmt.Sprintf("%d", int(C.fuse_version())), + AgentName: "OSXFUSE", + AgentVersion: C.GoString(C.osxfuse_version()), + } +} diff --git a/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_linux.go b/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_linux.go new file mode 100644 index 000000000..e4944d1c0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_linux.go @@ -0,0 +1,9 @@ +package fuseversion + +import ( + "runtime" +) + +func getLocalFuseSystems() (*Systems, error) { + return nil, fmt.Sprintf(notImplYet, runtime.GOARCH()) +} diff --git a/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_windows.go b/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_windows.go new file mode 100644 index 000000000..e4944d1c0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_windows.go @@ -0,0 +1,9 @@ +package fuseversion + +import ( + "runtime" +) + +func getLocalFuseSystems() (*Systems, error) { + return nil, fmt.Sprintf(notImplYet, runtime.GOARCH()) +} From 538550f8f8e76ebaff39ea382fe16379a91c3dba Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Sat, 10 Jan 2015 00:55:53 -0800 Subject: [PATCH 3/3] fix osx mounting version checks --- core/commands/mount_darwin.go | 38 +++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/core/commands/mount_darwin.go b/core/commands/mount_darwin.go index 1b50f3173..f98c56de0 100644 --- a/core/commands/mount_darwin.go +++ b/core/commands/mount_darwin.go @@ -5,6 +5,8 @@ import ( "runtime" "strings" "syscall" + + fuseversion "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-fuse-version" ) func init() { @@ -18,11 +20,17 @@ func darwinFuseCheckVersion() error { return nil } - ov, err := syscall.Sysctl("osxfuse.version.number") + ov, err := tryGFV() if err != nil { - return err + log.Debug(err) + ov, err = trySysctl() + if err != nil { + log.Debug(err) + return fmt.Errorf("cannot determine osxfuse version. is it installed?") + } } + log.Debug("mount: osxfuse version:", ov) if strings.HasPrefix(ov, "2.7.") || strings.HasPrefix(ov, "2.8.") { return nil } @@ -31,3 +39,29 @@ func darwinFuseCheckVersion() error { "Older versions of osxfuse have kernel panic bugs; please upgrade!", "https://github.com/jbenet/go-ipfs/issues/177") } + +func tryGFV() (string, error) { + sys, err := fuseversion.LocalFuseSystems() + if err != nil { + log.Debug("mount: fuseversion:", "failed") + return "", err + } + + for _, s := range *sys { + v := s.AgentVersion + log.Debug("mount: fuseversion:", v) + return v, nil + } + + return "", fmt.Errorf("fuseversion: no system found") +} + +func trySysctl() (string, error) { + v, err := syscall.Sysctl("osxfuse.version.number") + if err != nil { + log.Debug("mount: sysctl osxfuse.version.number:", "failed") + return "", err + } + log.Debug("mount: sysctl osxfuse.version.number:", v) + return v, nil +}