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 }
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 }
// 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 }
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) } }
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) } }
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) } }
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 }
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 }
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") }
func getFuseMountOptions(conf *SfsConfig) []fuse.MountOption { mount_opts := []fuse.MountOption{fuse.FSName("suffuse")} mount_opts = append(mount_opts, PlatformOptions()...) if conf.VolName != "" { mount_opts = append(mount_opts, fuse.LocalVolume(), fuse.VolumeName(conf.VolName), ) } return mount_opts }
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 }
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) } }
// 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 }
// Mount the FS at the given mountpoint func (v *VaultFS) Mount() error { var err error v.conn, err = fuse.Mount( v.mountpoint, fuse.FSName("vault"), fuse.VolumeName("vault"), ) logrus.Debug("created conn") if err != nil { return err } logrus.Debug("starting to serve") return fs.Serve(v.conn, v) }
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 }
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.") }
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) } }
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 }
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 } }
func ServeFUSE(bucketName string, mountpoint string, ofs *otaru.FileSystem, ready chan<- bool) error { fsName := fmt.Sprintf("otaru+gs://%s", bucketName) volName := fmt.Sprintf("Otaru %s", bucketName) c, err := bfuse.Mount( mountpoint, bfuse.FSName(fsName), bfuse.Subtype("otarufs"), bfuse.VolumeName(volName), ) if err != nil { return fmt.Errorf("bfuse.Mount failed: %v", err) } defer c.Close() serveC := make(chan error) go func() { if err := bfs.Serve(c, FileSystem{ofs}); err != nil { serveC <- err close(serveC) return } close(serveC) }() // check if the mount process has an error to report <-c.Ready if err := c.MountError; err != nil { return err } logger.Infof(mylog, "Mountpoint \"%s\" should be ready now!", mountpoint) if ready != nil { close(ready) } if err := <-serveC; err != nil { return nil } if err := ofs.Sync(); err != nil { return fmt.Errorf("Failed to Sync fs: %v", err) } return nil }
func run(mountpoint string) error { c, err := fuse.Mount( mountpoint, fuse.FSName("clock"), fuse.Subtype("clockfsfs"), fuse.LocalVolume(), fuse.VolumeName("Clock filesystem"), ) if err != nil { return err } defer c.Close() if p := c.Protocol(); !p.HasInvalidate() || true { return fmt.Errorf("kernel FUSE support is too old to have invalidations: version %v", p) } 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 { return err } // Check if the mount process has an error to report. <-c.Ready if err := c.MountError; err != nil { return err } return nil }
// mount calls the fuse library to specify // the details of the mounted filesystem. func mount(path, mountpoint string) error { // TODO: Check that there is no folder named mountOptions := []fuse.MountOption{ fuse.FSName("MuLi"), fuse.Subtype("MuLiFS"), fuse.LocalVolume(), fuse.VolumeName("Music Library"), } if config_params.allow_users { mountOptions = append(mountOptions, fuse.AllowOther()) } else { if config_params.allow_root { mountOptions = append(mountOptions, fuse.AllowRoot()) } } // playlist or drop in the path. c, err := fuse.Mount( mountpoint, mountOptions...) if err != nil { return err } defer c.Close() filesys := &FS{ mPoint: path, } if err := fs.Serve(c, filesys); err != nil { return err } // check if the mount process has an error to report <-c.Ready if err := c.MountError; err != nil { return err } return nil }
func main() { flag.Usage = usage flag.Parse() if *mount == "" || *mirror == "" { usage() os.Exit(2) } c, err := fuse.Mount( *mount, fuse.FSName("mirrorfs"), fuse.Subtype("mirrorfs"), fuse.VolumeName("Mirror FS"), // fuse.LocalVolume(), fuse.AllowOther(), ) if err != nil { log.Fatal(err) } defer c.Close() cfg := &fs.Config{} if *debug { cfg.Debug = debugLog } srv := fs.New(c, cfg) filesys := mirrorfs.NewMirrorFS(*mirror) 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) } }
func Serve(mountPoint, cgroupDir string) error { c, err := fuse.Mount( mountPoint, fuse.FSName("cgroupfs"), fuse.Subtype("cgroupfs"), fuse.LocalVolume(), fuse.VolumeName("cgroup volume"), fuse.AllowOther(), ) if err != nil { return err } defer c.Close() go handleStopSignals(mountPoint) var srv *fusefs.Server if os.Getenv("FUSE_DEBUG") != "" { srv = fusefs.New(c, &fusefs.Config{ Debug: func(msg interface{}) { fmt.Printf("%s\n", msg) }, }) } else { srv = fusefs.New(c, nil) } err = srv.Serve(fs.FS{cgroupDir}) if err != nil { return err } // check if the mount process has an error to report <-c.Ready if err := c.MountError; err != nil { return err } return nil }
func main() { flag.Usage = Usage flag.Parse() if flag.NArg() != 2 { Usage() os.Exit(2) } source := flag.Arg(0) mountpoint := flag.Arg(1) filesystem := FS{} walker := Walker{Path: source, CachePath: "/home/chris/.cache/jpgfs/"} filesystem.tree = walker.Walk() c, err := fuse.Mount( mountpoint, fuse.FSName(source), fuse.Subtype("jpgfs"), fuse.LocalVolume(), fuse.VolumeName("jpgfs"), ) if err != nil { log.Fatal(err) } defer c.Close() err = fs.Serve(c, filesystem) 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) } }
func getPlatformSpecificMountOptions(dir string) ([]fuse.MountOption, error) { options := []fuse.MountOption{} // Add kbfuse support. kbfusePath := fuse.OSXFUSEPaths{ DevicePrefix: "/dev/kbfuse", Load: "/Library/Filesystems/kbfuse.fs/Contents/Resources/load_kbfuse", Mount: "/Library/Filesystems/kbfuse.fs/Contents/Resources/mount_kbfuse", DaemonVar: "MOUNT_KBFUSE_DAEMON_PATH", } // Allow both kbfuse and osxfuse 3.x locations by default. options = append(options, fuse.OSXFUSELocations(kbfusePath, fuse.OSXFUSELocationV3)) // Volume name option is only used on OSX (ignored on other platforms). volName, err := volumeName(dir) if err != nil { return nil, err } options = append(options, fuse.VolumeName(volName)) return options, nil }
func main() { mountpoint := "/Users/gtarcea/fuse/nginx" fuse.Unmount(mountpoint) conn, err := fuse.Mount( mountpoint, fuse.FSName("etcfs"), fuse.Subtype("etcfs"), fuse.LocalVolume(), fuse.VolumeName("etcfs"), ) if err != nil { log.Fatal(err) } defer conn.Close() err = fs.Serve(conn, etcfs.FS{}) <-conn.Ready if conn.MountError != nil { log.Fatal(conn.MountError) } }
func getPlatformSpecificMountOptions(dir string, platformParams PlatformParams) ([]fuse.MountOption, error) { options := []fuse.MountOption{} var locationOption fuse.MountOption if platformParams.UseSystemFuse { // Only allow osxfuse 3.x. locationOption = fuse.OSXFUSELocations(fuse.OSXFUSELocationV3) } else { // Only allow kbfuse. locationOption = fuse.OSXFUSELocations(kbfusePath) } options = append(options, locationOption) // Volume name option is only used on OSX (ignored on other platforms). volName, err := volumeName(dir) if err != nil { return nil, err } options = append(options, fuse.VolumeName(volName)) return options, nil }
func main() { flag.Usage = usage flag.Parse() if *mount == "" || *folder == "" { usage() os.Exit(2) } c, err := fuse.Mount( *mount, fuse.FSName("logfs"), fuse.Subtype("logfs"), fuse.VolumeName("Log FS"), //fuse.AllowOther(), ) if err != nil { log.Fatal(err) } defer c.Close() cfg := &fs.Config{} srv := fs.New(c, cfg) filesys := logfs.NewLogFS(*folder) if err := srv.Serve(filesys); err != nil { log.Fatal(err) } // Verify mount error <-c.Ready if err := c.MountError; err != nil { log.Fatal(err) } log.Println("Log FS unmounted") }
func StartMount(mountpoint string, filesystem *FS) { c, err := fuse.Mount( mountpoint, fuse.FSName("pliantfuse"), fuse.Subtype("pliant"), fuse.LocalVolume(), fuse.VolumeName("pliant"), ) if err != nil { log.Fatal(err) } defer c.Close() err = fs.Serve(c, filesystem) 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) } }