作者:Reisende
项目:acdfus
func Run(c *cli.Context) {
println("Amazon Cloud Drive mount at", c.String("mountpoint"))
mountpoint := c.String("mountpoint")
if mountpoint == "" {
log.Fatal("no mountpoint! try running \"acdfuse help\"")
}
fuseCtx, err := fuse.Mount(
c.String("mountpoint"),
fuse.FSName("helloworld"),
fuse.Subtype("hellofs"),
fuse.LocalVolume(),
fuse.VolumeName("Hello world!"),
)
if err != nil {
log.Fatal(err)
}
defer fuseCtx.Close()
err = fs.Serve(fuseCtx, acdfs.FS{})
if err != nil {
log.Fatal(err)
}
// check if the mount process has an error to report
<-fuseCtx.Ready
if err := fuseCtx.MountError; err != nil {
log.Fatal(err)
}
}
作者:ehazlet
项目:docker-volume-libsecre
func (f *FS) Mount(volumeName string) error {
log.Debugf("setting up fuse: volume=%s", volumeName)
c, err := fuse.Mount(
f.mountpoint,
fuse.FSName("libsecret"),
fuse.Subtype("libsecretfs"),
fuse.LocalVolume(),
fuse.VolumeName(volumeName),
)
if err != nil {
return err
}
srv := fs.New(c, nil)
f.server = srv
f.volumeName = volumeName
f.conn = c
go func() {
err = f.server.Serve(f)
if err != nil {
f.errChan <- err
}
}()
// check if the mount process has an error to report
log.Debug("waiting for mount")
<-c.Ready
if err := c.MountError; err != nil {
return err
}
return nil
}
作者:dmcgowa
项目:fus
func main() {
flag.Usage = usage
flag.Parse()
if flag.NArg() != 1 {
usage()
os.Exit(2)
}
mountpoint := flag.Arg(0)
c, err := fuse.Mount(
mountpoint,
fuse.FSName("helloworld"),
fuse.Subtype("hellofs"),
fuse.LocalVolume(),
fuse.VolumeName("Hello world!"),
)
if err != nil {
log.Fatal(err)
}
defer c.Close()
err = fs.Serve(c, FS{})
if err != nil {
log.Fatal(err)
}
// check if the mount process has an error to report
<-c.Ready
if err := c.MountError; err != nil {
log.Fatal(err)
}
}
作者:henrylee2c
项目:pachyder
func (m *mounter) Mount(apiClient pfs.ApiClient, repositoryName string, mountPoint string, shard uint64, modulus uint64) (retErr error) {
if err := os.MkdirAll(mountPoint, 0777); err != nil {
return err
}
conn, err := fuse.Mount(
mountPoint,
fuse.FSName(namePrefix+repositoryName),
fuse.VolumeName(namePrefix+repositoryName),
fuse.Subtype(subtype),
fuse.WritebackCache(),
fuse.MaxReadahead(1<<32-1),
)
if err != nil {
return err
}
defer func() {
if err := conn.Close(); err != nil && retErr == nil {
retErr = err
}
}()
close(m.ready)
if err := fs.Serve(conn, &filesystem{apiClient, repositoryName, shard, modulus}); err != nil {
return err
}
// check if the mount process has an error to report
<-conn.Ready
return conn.MountError
}
作者:nc
项目:rclon
// mountOptions configures the options from the command line flags
func mountOptions(device string) (options []fuse.MountOption) {
options = []fuse.MountOption{
fuse.MaxReadahead(uint32(maxReadAhead)),
fuse.Subtype("rclone"),
fuse.FSName(device), fuse.VolumeName(device),
fuse.NoAppleDouble(),
fuse.NoAppleXattr(),
// Options from benchmarking in the fuse module
//fuse.MaxReadahead(64 * 1024 * 1024),
//fuse.AsyncRead(), - FIXME this causes
// ReadFileHandle.Read error: read /home/files/ISOs/xubuntu-15.10-desktop-amd64.iso: bad file descriptor
// which is probably related to errors people are having
//fuse.WritebackCache(),
}
if allowNonEmpty {
options = append(options, fuse.AllowNonEmptyMount())
}
if allowOther {
options = append(options, fuse.AllowOther())
}
if allowRoot {
options = append(options, fuse.AllowRoot())
}
if defaultPermissions {
options = append(options, fuse.DefaultPermissions())
}
if readOnly {
options = append(options, fuse.ReadOnly())
}
if writebackCache {
options = append(options, fuse.WritebackCache())
}
return options
}
作者:mehulsbhat
项目:pachyder
func (m *mounter) Mount(
address string,
mountPoint string,
shard uint64,
modulus uint64,
) (retErr error) {
// TODO: should we make the caller do this?
if err := os.MkdirAll(mountPoint, 0777); err != nil {
return err
}
name := namePrefix + address
conn, err := fuse.Mount(
mountPoint,
fuse.FSName(name),
fuse.VolumeName(name),
fuse.Subtype(subtype),
fuse.AllowOther(),
fuse.WritebackCache(),
fuse.MaxReadahead(1<<32-1),
)
if err != nil {
return err
}
defer func() {
if err := conn.Close(); err != nil && retErr == nil {
retErr = err
}
}()
if err := fs.Serve(conn, newFilesystem(m.apiClient, shard, modulus)); err != nil {
return err
}
<-conn.Ready
return conn.MountError
}
作者:pellaeo
项目:fus
func TestMountOptionSubtype(t *testing.T) {
if runtime.GOOS == "darwin" {
t.Skip("OS X does not support Subtype")
}
if runtime.GOOS == "freebsd" {
t.Skip("FreeBSD does not support Subtype")
}
t.Parallel()
const name = "FuseTestMarker"
mnt, err := fstestutil.MountedT(t, fstestutil.SimpleFS{fstestutil.Dir{}},
fuse.Subtype(name),
)
if err != nil {
t.Fatal(err)
}
defer mnt.Close()
info, err := fstestutil.GetMountInfo(mnt.Dir)
if err != nil {
t.Fatal(err)
}
if g, e := info.Type, "fuse."+name; g != e {
t.Errorf("wrong Subtype: %q != %q", g, e)
}
}
作者:port
项目:simple-network-fus
func Mount(host, mountpoint string) error {
conn, err := net.Dial("tcp", host)
if err != nil {
return err
}
defer conn.Close()
log.Println("Connected")
c, err := fuse.Mount(
mountpoint,
fuse.FSName("simple-network-fuse"),
fuse.Subtype("rofl"),
)
if err != nil {
return err
}
defer c.Close()
fsConn := connection{
enc: gob.NewEncoder(conn),
dec: gob.NewDecoder(conn),
}
err = fs.Serve(c, &FS{fsConn})
if err != nil {
return err
}
<-c.Ready
if err := c.MountError; err != nil {
return err
}
return nil
}
作者:rfjako
项目:cluef
func (fs *ClueFS) MountAndServe(mountpoint string, readonly bool) error {
// Mount the file system
fs.mountDir = mountpoint
if IsDebugActive() {
fuse.Debug = FuseDebug
}
mountOpts := []fuse.MountOption{
fuse.FSName(programName),
fuse.Subtype(programName),
fuse.VolumeName(programName),
fuse.LocalVolume(),
}
if readonly {
mountOpts = append(mountOpts, fuse.ReadOnly())
}
conn, err := fuse.Mount(mountpoint, mountOpts...)
if err != nil {
return err
}
defer conn.Close()
// Start serving requests
if err = fusefs.Serve(conn, fs); err != nil {
return err
}
// Check for errors when mounting the file system
<-conn.Ready
if err = conn.MountError; err != nil {
return err
}
return nil
}
作者:cjluca
项目:unitef
func main() {
ufs := unitefs.NewFS()
for i := 1; i < len(os.Args)-1; i++ {
println(os.Args[i])
ufs.RegisterSubtree(os.Args[i])
}
c, err := fuse.Mount(
os.Args[len(os.Args)-1],
fuse.FSName("unitefs"),
fuse.Subtype("unitefs"),
fuse.LocalVolume(),
fuse.VolumeName("unitefs"),
)
if err != nil {
log.Fatal(err)
}
defer c.Close()
fmt.Println("FS mounted")
err = fs.Serve(c, ufs)
if err != nil {
log.Fatal(err)
}
// check if the mount process has an error to report
<-c.Ready
if err := c.MountError; err != nil {
log.Fatal(err)
}
}
作者:mou
项目:fuse-snm
func main() {
var err error
// getopt
flag.Usage = usage
flag.Parse()
if flag.NArg() != 2 {
usage()
os.Exit(2)
}
mountpoint := flag.Arg(0)
snmpServer := flag.Arg(1)
// connect snmp
snmp.client, err = gosnmp.NewGoSNMP(snmpServer, "public", gosnmp.Version2c, 5)
if err != nil {
logrus.Fatalf("gosnmp.NewGoSNMP: %v", err)
}
//snmp.client.SetDebug(true)
//snmp.client.SetVerbose(true)
snmp.currentId = 1
snmp.cache = make(map[string]SnmpCacheEntry)
snmp.cacheMap = make(map[uint64]string)
// preload initial cache
err = snmp.LoadWalk(".1.3.6.1")
if err != nil {
logrus.Fatalf("snmp.LoadWalk: %v", err)
}
// mount fuse
c, err := fuse.Mount(
mountpoint,
fuse.FSName("fuse-snmp"),
fuse.Subtype("snmpfs"),
fuse.LocalVolume(),
fuse.VolumeName("Fuse SNMP"),
)
if err != nil {
logrus.Fatalf("fuse.Mount: %v", err)
}
defer c.Close()
// map fuse
err = fs.Serve(c, FS{})
if err != nil {
logrus.Fatalf("fs.Serve: %v", err)
}
// wait for fuse close
<-c.Ready
if err := c.MountError; err != nil {
logrus.Fatalf("c.MountError: %v", err)
}
logrus.Fatalf("BYEBYE")
}
作者:saakaifoundr
项目:pachyder
func (m *mounter) Mount(
mountPoint string,
shard *pfsclient.Shard,
commitMounts []*CommitMount,
ready chan bool,
debug bool,
) (retErr error) {
var once sync.Once
defer once.Do(func() {
if ready != nil {
close(ready)
}
})
name := namePrefix + m.address
conn, err := fuse.Mount(
mountPoint,
fuse.FSName(name),
fuse.VolumeName(name),
fuse.Subtype(subtype),
fuse.AllowOther(),
fuse.WritebackCache(),
fuse.MaxReadahead(1<<32-1),
)
if err != nil {
return err
}
defer func() {
if err := conn.Close(); err != nil && retErr == nil {
retErr = err
}
}()
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt)
go func() {
<-sigChan
m.Unmount(mountPoint)
}()
once.Do(func() {
if ready != nil {
close(ready)
}
})
config := &fs.Config{}
if debug {
config.Debug = func(msg interface{}) { lion.Printf("%+v", msg) }
}
if err := fs.New(conn, config).Serve(newFilesystem(m.apiClient, shard, commitMounts)); err != nil {
return err
}
<-conn.Ready
return conn.MountError
}
作者:Gambatte-kudasa
项目:momf
func main() {
flag.Usage = Usage
flag.Parse()
if flag.NArg() != 2 {
Usage()
os.Exit(2)
}
mountpoint := flag.Arg(0)
c, err := fuse.Mount(
mountpoint,
fuse.FSName("MomFS"),
fuse.Subtype("momfs"),
fuse.LocalVolume(),
fuse.VolumeName("Mom file system"),
)
if err != nil {
log.Fatal(err)
}
defer c.Close()
sigintCh := make(chan os.Signal, 1)
signal.Notify(sigintCh, os.Interrupt)
go func() {
<-sigintCh
log.Printf("Program interrupted. Trying to unmount file system.\n")
err := fuse.Unmount(mountpoint)
if err != nil {
log.Println(err)
log.Println("Failed to unmount file system. Trying again..")
for {
<-time.Tick(1 * time.Second)
fuse.Unmount(mountpoint)
}
}
}()
err = fs.Serve(c, NewOrgFS())
if err != nil {
log.Fatal(err)
}
// check if the mount process has an error to report
<-c.Ready
if err := c.MountError; err != nil {
log.Fatal(err)
}
}
作者:Microsof
项目:hdfs-moun
// Mounts the filesystem
func (this *FileSystem) Mount() (*fuse.Conn, error) {
conn, err := fuse.Mount(
this.MountPoint,
fuse.FSName("hdfs"),
fuse.Subtype("hdfs"),
fuse.VolumeName("HDFS filesystem"),
fuse.AllowOther(),
fuse.WritebackCache(),
fuse.MaxReadahead(1024*64)) //TODO: make configurable
if err != nil {
return nil, err
}
this.Mounted = true
return conn, nil
}
作者:berea
项目:pachyder
func (m *mounter) Mount(
repositoryName string,
commitID string,
mountPoint string,
shard uint64,
modulus uint64,
) (retErr error) {
// TODO(pedge): should we make the caller do this?
if err := os.MkdirAll(mountPoint, 0777); err != nil {
return err
}
name := namePrefix + repositoryName
if commitID != "" {
name = name + "-" + commitID
}
conn, err := fuse.Mount(
mountPoint,
fuse.FSName(name),
fuse.VolumeName(name),
fuse.Subtype(subtype),
fuse.AllowOther(),
fuse.WritebackCache(),
fuse.MaxReadahead(1<<32-1),
)
if err != nil {
return err
}
errChan := make(chan error, 1)
m.lock.Lock()
if _, ok := m.mountpointToErrChan[mountPoint]; ok {
m.lock.Unlock()
return fmt.Errorf("mountpoint %s already exists", mountPoint)
}
m.mountpointToErrChan[mountPoint] = errChan
m.lock.Unlock()
go func() {
err := fs.Serve(conn, newFilesystem(m.apiClient, repositoryName, commitID, shard, modulus))
closeErr := conn.Close()
if err != nil {
errChan <- err
} else {
errChan <- closeErr
}
}()
<-conn.Ready
return conn.MountError
}
作者:disorganize
项目:bri
// NewMount mounts a fuse endpoint at `mountpoint` retrieving data from `store`.
func NewMount(store *store.Store, mountpoint string) (*Mount, error) {
conn, err := fuse.Mount(
mountpoint,
fuse.FSName("brigfs"),
fuse.Subtype("brig"),
fuse.AllowNonEmptyMount(),
)
if err != nil {
return nil, err
}
filesys := &Filesystem{Store: store}
mnt := &Mount{
Conn: conn,
Server: fs.New(conn, nil),
FS: filesys,
Dir: mountpoint,
Store: store,
done: make(chan util.Empty),
errors: make(chan error),
}
go func() {
defer close(mnt.done)
log.Debugf("Serving FUSE at %v", mountpoint)
mnt.errors <- mnt.Server.Serve(filesys)
mnt.done <- util.Empty{}
log.Debugf("Stopped serving FUSE at %v", mountpoint)
}()
select {
case <-mnt.Conn.Ready:
if err := mnt.Conn.MountError; err != nil {
return nil, err
}
case err = <-mnt.errors:
// Serve quit early
if err != nil {
return nil, err
}
return nil, errors.New("Serve exited early")
}
return mnt, nil
}
作者:jk-tod
项目:syncthing-fus
func MountFuse(mountpoint string, m *model.Model) {
c, err := fuse.Mount(
mountpoint,
fuse.FSName("syncthingfuse"),
fuse.Subtype("syncthingfuse"),
fuse.LocalVolume(),
fuse.VolumeName("Syncthing FUSE"),
)
if err != nil {
l.Warnln(err)
}
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
doneServe := make(chan error, 1)
go func() {
doneServe <- fs.Serve(c, FS{m: m})
}()
select {
case err := <-doneServe:
l.Infoln("conn.Serve returned", err)
// check if the mount process has an error to report
<-c.Ready
if err := c.MountError; err != nil {
l.Warnln("conn.MountError:", err)
}
case sig := <-sigc:
l.Infoln("Signal", sig, "received, shutting down.")
}
time.AfterFunc(3*time.Second, func() {
os.Exit(1)
})
l.Infoln("Unmounting...")
err = Unmount(mountpoint)
if err == nil {
l.Infoln("Unmounted")
} else {
l.Infoln("Unmount failed:", err)
}
l.Infoln("syncthing FUSE process ending.")
}
作者:maret
项目:resti
func main() {
flag.Usage = usage
flag.Parse()
if flag.NArg() != 1 {
usage()
os.Exit(2)
}
mountpoint := flag.Arg(0)
c, err := fuse.Mount(
mountpoint,
fuse.FSName("clock"),
fuse.Subtype("clockfsfs"),
fuse.LocalVolume(),
fuse.VolumeName("Clock filesystem"),
)
if err != nil {
log.Fatal(err)
}
defer c.Close()
srv := fs.New(c, nil)
filesys := &FS{
// We pre-create the clock node so that it's always the same
// object returned from all the Lookups. You could carefully
// track its lifetime between Lookup&Forget, and have the
// ticking & invalidation happen only when active, but let's
// keep this example simple.
clockFile: &File{
fuse: srv,
},
}
filesys.clockFile.tick()
// This goroutine never exits. That's fine for this example.
go filesys.clockFile.update()
if err := srv.Serve(filesys); err != nil {
log.Fatal(err)
}
// Check if the mount process has an error to report.
<-c.Ready
if err := c.MountError; err != nil {
log.Fatal(err)
}
}
作者:angelabier
项目:pachyder
func (m *mounter) Mount(
mountPoint string,
shard *pfs.Shard,
commitMounts []*CommitMount,
ready chan bool,
) (retErr error) {
var once sync.Once
defer once.Do(func() {
if ready != nil {
close(ready)
}
})
// TODO: should we make the caller do this?
if err := os.MkdirAll(mountPoint, 0777); err != nil {
return err
}
name := namePrefix + m.address
conn, err := fuse.Mount(
mountPoint,
fuse.FSName(name),
fuse.VolumeName(name),
fuse.Subtype(subtype),
fuse.AllowOther(),
fuse.WritebackCache(),
fuse.MaxReadahead(1<<32-1),
)
if err != nil {
return err
}
defer func() {
if err := conn.Close(); err != nil && retErr == nil {
retErr = err
}
}()
once.Do(func() {
if ready != nil {
close(ready)
}
})
if err := fs.Serve(conn, newFilesystem(m.apiClient, shard, commitMounts)); err != nil {
return err
}
<-conn.Ready
return conn.MountError
}
作者:SimpleWebF
项目:fus
func main() {
flag.Usage = usage
flag.Parse()
if flag.NArg() < 2 {
usage()
os.Exit(2)
}
origin := "http://" + flag.Arg(0) + "/"
url := "ws://" + flag.Arg(0) + "/fs"
mountpoint := flag.Arg(1)
c, err := fuse.Mount(
mountpoint,
fuse.FSName(url),
fuse.Subtype("simplewebfs"),
fuse.LocalVolume(),
fuse.VolumeName("Hello world!"),
)
if err != nil {
log.Fatal(err)
}
defer c.Close()
con := simplewebfs.New(url, origin)
srv := fs.New(c, nil)
filesys := &FS{
c: &con,
}
filesys.cache = make(map[string]fileserver.RPCDirlistingReply)
err = srv.Serve(filesys)
if err != nil {
log.Fatal(err)
return
}
// check if the mount process has an error to report
<-c.Ready
if err := c.MountError; err != nil {
log.Fatal(err)
return
}
}