Commit 61df8108 authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher

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-74a933d6/fuse/server.go:122:5: undefined: parseFuseFd
../../../../pkg/mod/github.com/hanwen/go-fuse/v2@v2.1.1-0.20210825070001-74a933d6/fuse/server.go:887:5: undefined: parseFuseFd

Move parseFuseFd() to build on all archs to unbreak the build.

Change-Id: Ice173cc70a6a95765b56b444623b68ed92382052
parent 74a933d6
...@@ -11,7 +11,6 @@ import ( ...@@ -11,7 +11,6 @@ import (
"os" "os"
"os/exec" "os/exec"
"path" "path"
"strconv"
"strings" "strings"
"syscall" "syscall"
"unsafe" "unsafe"
...@@ -119,20 +118,6 @@ func callFusermount(mountPoint string, opts *MountOptions) (fd int, err error) { ...@@ -119,20 +118,6 @@ func callFusermount(mountPoint string, opts *MountOptions) (fd int, err error) {
return 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 // Create a FUSE FS on the specified mount point. The returned
// mount point is always absolute. // mount point is always absolute.
func mount(mountPoint string, opts *MountOptions, ready chan<- error) (fd int, err error) { func mount(mountPoint string, opts *MountOptions, ready chan<- error) (fd int, err error) {
......
...@@ -9,8 +9,10 @@ import ( ...@@ -9,8 +9,10 @@ import (
"log" "log"
"math" "math"
"os" "os"
"path"
"path/filepath" "path/filepath"
"runtime" "runtime"
"strconv"
"strings" "strings"
"sync" "sync"
"syscall" "syscall"
...@@ -891,3 +893,17 @@ func (ms *Server) WaitMount() error { ...@@ -891,3 +893,17 @@ func (ms *Server) WaitMount() error {
} }
return pollHack(ms.mountPoint) 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
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment