1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
package fuse
import (
"os"
"strings"
)
type Backend string
const (
fuseTBackend = "FUSE-T"
osxfuseBackend = "OSXFUSE"
)
func (be Backend) IsFuseT() bool {
return be == fuseTBackend
}
func (be Backend) IsUnset() bool {
return be == ""
}
var forcedBackend Backend
func initForcedBackend() {
forcedBackend = getForcedBackend()
}
func getForcedBackend() (ret Backend) {
return Backend(strings.ToUpper(strings.TrimSpace(os.Getenv("FUSE_FORCE_BACKEND"))))
}
// Extra state to be managed per backend.
type backendState interface {
Drop()
}
// FUSE-T requires we hold on to some extra file descriptors for the duration of the connection.
type fuseTBackendState struct {
extraFiles []*os.File
}
func (bes fuseTBackendState) Drop() {
for _, f := range bes.extraFiles {
f.Close()
}
}
type nopBackendState struct{}
func (nopBackendState) Drop() {}
|