From 61df81086038f52fbf3e25ff97373336c83cd3ae Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Wed, 25 Aug 2021 12:45:46 +0200 Subject: [PATCH] fuse: move parseFuseFd() to unbreak darwin build Unfortunately, I broke darwin with the last commit: + GOOS=darwin + GOARCH=amd64 + go build -tags without_openssl -o /dev/null ../../../../pkg/mod/github.com/hanwen/go-fuse/v2@v2.1.1-0.20210825070001-74a933d6e856/fuse/server.go:122:5: undefined: parseFuseFd ../../../../pkg/mod/github.com/hanwen/go-fuse/v2@v2.1.1-0.20210825070001-74a933d6e856/fuse/server.go:887:5: undefined: parseFuseFd Move parseFuseFd() to build on all archs to unbreak the build. Change-Id: Ice173cc70a6a95765b56b444623b68ed92382052 --- fuse/mount_linux.go | 15 --------------- fuse/server.go | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/fuse/mount_linux.go b/fuse/mount_linux.go index 4b8774bad..c8efd201f 100644 --- a/fuse/mount_linux.go +++ b/fuse/mount_linux.go @@ -11,7 +11,6 @@ import ( "os" "os/exec" "path" - "strconv" "strings" "syscall" "unsafe" @@ -119,20 +118,6 @@ func callFusermount(mountPoint string, opts *MountOptions) (fd int, err error) { return } -// parseFuseFd checks if `mountPoint` is the special form /dev/fd/N (with N >= 0), -// and returns N in this case. Returns -1 otherwise. -func parseFuseFd(mountPoint string) (fd int) { - dir, file := path.Split(mountPoint) - if dir != "/dev/fd/" { - return -1 - } - fd, err := strconv.Atoi(file) - if err != nil || fd <= 0 { - return -1 - } - return fd -} - // Create a FUSE FS on the specified mount point. The returned // mount point is always absolute. func mount(mountPoint string, opts *MountOptions, ready chan<- error) (fd int, err error) { diff --git a/fuse/server.go b/fuse/server.go index 2c09d380c..68d00fcab 100644 --- a/fuse/server.go +++ b/fuse/server.go @@ -9,8 +9,10 @@ import ( "log" "math" "os" + "path" "path/filepath" "runtime" + "strconv" "strings" "sync" "syscall" @@ -891,3 +893,17 @@ func (ms *Server) WaitMount() error { } return pollHack(ms.mountPoint) } + +// parseFuseFd checks if `mountPoint` is the special form /dev/fd/N (with N >= 0), +// and returns N in this case. Returns -1 otherwise. +func parseFuseFd(mountPoint string) (fd int) { + dir, file := path.Split(mountPoint) + if dir != "/dev/fd/" { + return -1 + } + fd, err := strconv.Atoi(file) + if err != nil || fd <= 0 { + return -1 + } + return fd +}