예제 #1
0
파일: main.go 프로젝트: Reisender/acdfuse
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)
	}
}
예제 #2
0
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
}
예제 #3
0
파일: hello.go 프로젝트: dmcgowan/fuse
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)
	}
}
예제 #4
0
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
}
예제 #5
0
파일: fs.go 프로젝트: ncw/rclone
// 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
}
예제 #6
0
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
}
예제 #7
0
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)
	}
}
예제 #8
0
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
}
예제 #9
0
파일: fs.go 프로젝트: rfjakob/cluefs
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
}
예제 #10
0
파일: main.go 프로젝트: cjlucas/unitefs
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)
	}
}
예제 #11
0
파일: main.go 프로젝트: moul/fuse-snmp
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")
}
예제 #12
0
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
}
예제 #13
0
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)
	}
}
예제 #14
0
// 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
}
예제 #15
0
파일: mounter.go 프로젝트: bereal/pachyderm
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
}
예제 #16
0
파일: mount.go 프로젝트: disorganizer/brig
// 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
}
예제 #17
0
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.")
}
예제 #18
0
파일: clockfs.go 프로젝트: marete/restic
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)
	}
}
예제 #19
0
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
}
예제 #20
0
파일: main.go 프로젝트: SimpleWebFS/fuse
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
	}
}
예제 #21
0
파일: filesystem.go 프로젝트: postfix/otaru
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
}
예제 #22
0
파일: clockfs.go 프로젝트: read-later/fuse
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
}
예제 #23
0
// 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
}
예제 #24
0
파일: mount.go 프로젝트: ovh/svfs
func mountOptions(device string) (options []fuse.MountOption) {
	if svfs.AllowOther {
		options = append(options, fuse.AllowOther())
	}
	if svfs.AllowRoot {
		options = append(options, fuse.AllowRoot())
	}
	if svfs.DefaultPermissions {
		options = append(options, fuse.DefaultPermissions())
	}
	if svfs.ReadOnly {
		options = append(options, fuse.ReadOnly())
	}

	options = append(options, fuse.MaxReadahead(uint32(svfs.ReadAheadSize)))
	options = append(options, fuse.Subtype("svfs"))
	options = append(options, fuse.FSName(device))

	return options
}
예제 #25
0
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)
	}
}
예제 #26
0
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
}
예제 #27
0
파일: jpgfs.go 프로젝트: solarnz/jpgfs
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)
	}
}
예제 #28
0
파일: etcfs.go 프로젝트: a2sdl/etcfs
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)
	}
}
예제 #29
0
파일: logfs.go 프로젝트: ligadous/logfs
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")
}
예제 #30
0
파일: fs.go 프로젝트: pgm/singleply
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)
	}
}