Skip to content

Commit

Permalink
fuse: move parseFuseFd() to unbreak darwin build
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rfjakob committed Aug 25, 2021
1 parent 74a933d commit 61df810
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
15 changes: 0 additions & 15 deletions fuse/mount_linux.go
Expand Up @@ -11,7 +11,6 @@ import (
"os"
"os/exec"
"path"
"strconv"
"strings"
"syscall"
"unsafe"
Expand Down Expand Up @@ -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) {
Expand Down
16 changes: 16 additions & 0 deletions fuse/server.go
Expand Up @@ -9,8 +9,10 @@ import (
"log"
"math"
"os"
"path"
"path/filepath"
"runtime"
"strconv"
"strings"
"sync"
"syscall"
Expand Down Expand Up @@ -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
}

0 comments on commit 61df810

Please sign in to comment.