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 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() { 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 }
func (self *Mount) Serve() error { c, err := fuse.Mount(self.mount, fuse.FSName("vault-mount"), fuse.VolumeName("vault")) if err != nil { return err } self.conn = c filesys := &FS{ client: self.client, } 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 }