Golang bazil-org-fuse.LocalVolume类(方法)实例源码

下面列出了Golang bazil-org-fuse.LocalVolume 类(方法)源码代码实例,从而了解它的用法。

作者: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
}

作者: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
}

作者: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)
	}
}

作者: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")
}

作者:suffus    项目:go-suffus   
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
}

作者: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)
	}
}

作者: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)
	}
}

作者: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
	}
}

作者:read-late    项目:fus   
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
}

作者:dankomiocevi    项目:mulif   
// 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
}

作者:chzye    项目:simsat   
func process(c *Config) (conn *fuse.Conn, err error) {
	if err = fuse.Unmount(c.Base); err == nil {
		logex.Info("last not unmount")
		time.Sleep(1000 * time.Millisecond)
		err = nil
	} else {
		err = nil
	}

	ops := []fuse.MountOption{
		fuse.AllowOther(),
		fuse.FSName(FsName),
		fuse.LocalVolume(),
	}
	conn, err = fuse.Mount(c.Base, ops...)
	if err != nil {
		return nil, logex.Trace(err)
	}
	go fs.Serve(conn, NewTree("/", c.Target))
	logex.Info("connected.")
	return conn, nil
}

作者:chenchu    项目:cgroupf   
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
}

作者:solarn    项目:jpgf   
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)
	}
}

作者:a2sd    项目:etcf   
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)
	}
}

作者:pg    项目:singlepl   
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)
	}
}

作者:wrees    项目:cfs-binary-releas   
//.........这里部分代码省略.........
				ws := mb.NewFileSystemAPIClient(conn)
				result, err := ws.LookupAddrFS(context.Background(), &mb.LookupAddrFSRequest{FSid: fsNum, Addr: c.String("addr")})
				if err != nil {
					log.Fatalf("Bad Request: %v", err)
					conn.Close()
					os.Exit(1)
				}
				conn.Close()
				log.Printf("Result: %s\n", result.Status)
			},
		},
		{
			Name:      "mount",
			Usage:     "mount a file system",
			ArgsUsage: "<region>://<file system uuid> <mount point> -o [OPTIONS]",
			Flags: []cli.Flag{
				cli.StringFlag{
					Name:  "o",
					Value: "",
					Usage: "mount options",
				},
			},
			Action: func(c *cli.Context) {
				if !c.Args().Present() {
					fmt.Println("Invalid syntax for revoke.")
					os.Exit(1)
				}
				serverAddr, fsNum, _ = parseurl(c.Args().Get(0), "8445")
				fsnum, err := uuid.FromString(fsNum)
				if err != nil {
					fmt.Print("File System id is not valid: ", err)
				}
				mountpoint := c.Args().Get(1)
				// check mountpoint exists
				if _, ferr := os.Stat(mountpoint); os.IsNotExist(ferr) {
					log.Printf("Mount point %s does not exist\n\n", mountpoint)
					os.Exit(1)
				}
				fusermountPath()
				// process file system options
				if c.String("o") != "" {
					clargs := getArgs(c.String("o"))
					// crapy debug log handling :)
					if debug, ok := clargs["debug"]; ok {
						if debug == "false" {
							log.SetFlags(0)
							log.SetOutput(ioutil.Discard)
						}
					} else {
						log.SetFlags(0)
						log.SetOutput(ioutil.Discard)
					}
				}
				// Setup grpc
				var opts []grpc.DialOption
				creds := credentials.NewTLS(&tls.Config{
					InsecureSkipVerify: true,
				})
				opts = append(opts, grpc.WithTransportCredentials(creds))
				conn, err := grpc.Dial(serverAddr, opts...)
				if err != nil {
					log.Fatalf("failed to dial: %v", err)
				}
				defer conn.Close()
				// Work with fuse
				cfs, err := fuse.Mount(
					mountpoint,
					fuse.FSName("cfs"),
					fuse.Subtype("cfs"),
					fuse.LocalVolume(),
					fuse.VolumeName("CFS"),
					fuse.AllowOther(),
					fuse.DefaultPermissions(),
				)
				if err != nil {
					log.Fatal(err)
				}
				defer cfs.Close()

				rpc := newrpc(conn)
				fs := newfs(cfs, rpc, fsnum.String())
				err = fs.InitFs()
				if err != nil {
					log.Fatal(err)
				}
				srv := newserver(fs)

				if err := srv.serve(); err != nil {
					log.Fatal(err)
				}

				<-cfs.Ready
				if err := cfs.MountError; err != nil {
					log.Fatal(err)
				}
			},
		},
	}
	app.Run(os.Args)
}

作者:aaronlehman    项目:continuit   
}

		provider := continuityfs.NewFSFileContentProvider(source, driver)

		contfs, err := continuityfs.NewFSFromManifest(m, mountpoint, provider)
		if err != nil {
			logrus.Fatal(err)
		}

		c, err := fuse.Mount(
			mountpoint,
			fuse.ReadOnly(),
			fuse.FSName(manifestName),
			fuse.Subtype("continuity"),
			// OSX Only options
			fuse.LocalVolume(),
			fuse.VolumeName("Continuity FileSystem"),
		)
		if err != nil {
			logrus.Fatal(err)
		}

		<-c.Ready
		if err := c.MountError; err != nil {
			c.Close()
			logrus.Fatal(err)
		}

		errChan := make(chan error, 1)
		go func() {
			// TODO: Create server directory to use context


问题


面经


文章

微信
公众号

扫码关注公众号