当前位置: 首页>>代码示例>>Golang>>正文


Golang pathfs.NewPathNodeFs函数代码示例

本文整理汇总了Golang中github.com/hanwen/go-fuse/fuse/pathfs.NewPathNodeFs函数的典型用法代码示例。如果您正苦于以下问题:Golang NewPathNodeFs函数的具体用法?Golang NewPathNodeFs怎么用?Golang NewPathNodeFs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewPathNodeFs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestNonseekable

func TestNonseekable(t *testing.T) {
	fs := &nonseekFs{FileSystem: pathfs.NewDefaultFileSystem()}
	fs.Length = 200 * 1024

	dir := testutil.TempDir()
	defer os.RemoveAll(dir)
	nfs := pathfs.NewPathNodeFs(fs, nil)
	opts := nodefs.NewOptions()
	opts.Debug = testutil.VerboseTest()
	state, _, err := nodefs.MountRoot(dir, nfs.Root(), opts)
	if err != nil {
		t.Fatalf("failed: %v", err)
	}
	defer state.Unmount()

	go state.Serve()
	if err := state.WaitMount(); err != nil {
		t.Fatal("WaitMount", err)
	}

	f, err := os.Open(dir + "/file")
	if err != nil {
		t.Fatalf("failed: %v", err)
	}
	defer f.Close()

	b := make([]byte, 200)
	n, err := f.ReadAt(b, 20)
	if err == nil || n > 0 {
		t.Errorf("file was opened nonseekable, but seek successful")
	}
}
开发者ID:jszwedko,项目名称:ec2-metadatafs,代码行数:32,代码来源:cache_test.go

示例2: main

func main() {
	if len(os.Args) != 2 {
		fmt.Println("Usage: %s <mountpath>")
		os.Exit(1)
	}
	root := os.Args[1]

	hfs := &HelloFs{FileSystem: pathfs.NewDefaultFileSystem()}

	nfs := pathfs.NewPathNodeFs(hfs, nil)
	fuseSrv, _, err := nodefs.MountRoot(root, nfs.Root(), nil)
	if err != nil {
		log.Fatal(err)
	}
	go fuseSrv.Serve()
	l, err := net.Listen("tcp", "127.0.0.1:50000")
	if err != nil {
		log.Fatal(err)
	}
	s := grpc.NewServer()
	pb.RegisterPathFSServer(s, server.New(hfs))
	go s.Serve(l)
	log.Printf("Listen on %s for dir %s", l.Addr(), root)
	sigCh := make(chan os.Signal)
	signal.Notify(sigCh, os.Interrupt)
	for range sigCh {
		fuseSrv.Unmount()
		s.Stop()
		os.Exit(0)
	}
}
开发者ID:LK4D4,项目名称:grfuse,代码行数:31,代码来源:server.go

示例3: TestNonseekable

func TestNonseekable(t *testing.T) {
	fs := &nonseekFs{FileSystem: pathfs.NewDefaultFileSystem()}
	fs.Length = 200 * 1024

	dir, err := ioutil.TempDir("", "go-fuse-cache_test")
	if err != nil {
		t.Fatalf("failed: %v", err)
	}
	defer os.RemoveAll(dir)
	nfs := pathfs.NewPathNodeFs(fs, nil)
	state, _, err := nodefs.MountRoot(dir, nfs.Root(), nil)
	if err != nil {
		t.Fatalf("failed: %v", err)
	}
	state.SetDebug(VerboseTest())
	defer state.Unmount()

	go state.Serve()

	f, err := os.Open(dir + "/file")
	if err != nil {
		t.Fatalf("failed: %v", err)
	}
	defer f.Close()

	b := make([]byte, 200)
	n, err := f.ReadAt(b, 20)
	if err == nil || n > 0 {
		t.Errorf("file was opened nonseekable, but seek successful")
	}
}
开发者ID:freakmac,项目名称:adbfs,代码行数:31,代码来源:cache_test.go

示例4: New

func New(config *conf.Fuse, logger log_driver.Logger) (*GitFs, error) {
	gitfsDir, err := gitfsDir(logger)
	if err != nil {
		return nil, err
	}

	defaultfs := pathfs.NewDefaultFileSystem()
	gitfs := &GitFs{FileSystem: pathfs.NewReadonlyFileSystem(defaultfs), GitRepoDir: config.GitRepoDir, GitFsDir: gitfsDir, logger: logger}
	fs := pathfs.NewPathNodeFs(gitfs, nil)
	server, _, err := nodefs.MountRoot(gitfsDir, fs.Root(), nil)
	if err != nil {
		logger.Errorf("Failed to mount GitFS on %s due to %s", gitfsDir, err)
		return nil, err
	}
	logger.Debugf("Mount GitFs on %s", gitfsDir)
	gitfs.server = server
	server.SetDebug(config.Debug)

	gitfs.cache, err = cache.New(1024)
	if err != nil {
		logger.Errorf("Failed to initialize object cache due to %s\n", err)
		return nil, err
	}

	return gitfs, nil
}
开发者ID:bachue,项目名称:pages,代码行数:26,代码来源:gitfuse.go

示例5: main

func main() {
	if len(os.Args) != 2 {
		fmt.Println("Usage: %s <mountpath>")
		os.Exit(1)
	}
	root := os.Args[1]

	dialOpts := []grpc.DialOption{grpc.WithInsecure()}
	conn, err := grpc.Dial("127.0.0.1:50000", dialOpts...)
	if err != nil {
		log.Fatal(err)
	}
	cli := pb.NewPathFSClient(conn)
	fs := grpcfs.New(cli)
	nfs := pathfs.NewPathNodeFs(fs, nil)
	server, _, err := nodefs.MountRoot(root, nfs.Root(), nil)
	if err != nil {
		log.Fatal(err)
	}
	go server.Serve()
	log.Printf("Fs mounted to root %s", root)
	sigCh := make(chan os.Signal)
	signal.Notify(sigCh, os.Interrupt)
	for range sigCh {
		server.Unmount()
		os.Exit(0)
	}
}
开发者ID:LK4D4,项目名称:grfuse,代码行数:28,代码来源:client.go

示例6: setupFs

func setupFs(fs pathfs.FileSystem) (string, func()) {
	opts := &nodefs.Options{
		EntryTimeout:    0.0,
		AttrTimeout:     0.0,
		NegativeTimeout: 0.0,
	}
	mountPoint, _ := ioutil.TempDir("", "stat_test")
	nfs := pathfs.NewPathNodeFs(fs, nil)
	state, _, err := nodefs.MountRoot(mountPoint, nfs.Root(), opts)
	if err != nil {
		panic(fmt.Sprintf("cannot mount %v", err)) // ugh - benchmark has no error methods.
	}
	lmap := NewLatencyMap()

	state.RecordLatencies(lmap)
	// state.SetDebug(true)
	go state.Serve()

	return mountPoint, func() {
		lc, lns := lmap.Get("LOOKUP")
		gc, gns := lmap.Get("GETATTR")
		fmt.Printf("GETATTR %v/call n=%d, LOOKUP %v/call n=%d\n",
			gns/time.Duration(gc), gc,
			lns/time.Duration(lc), lc)

		err := state.Unmount()
		if err != nil {
			log.Println("error during unmount", err)
		} else {
			os.RemoveAll(mountPoint)
		}
	}
}
开发者ID:carriercomm,项目名称:go-fuse,代码行数:33,代码来源:stat_test.go

示例7: Create

func (d *etcDriver) Create(rq dkvolume.Request) dkvolume.Response {
	var res dkvolume.Response
	if !strings.HasPrefix(rq.Name, "@") {
		return responseErrorString("a etcd path has to start with a @")
	}
	d.mux.Lock()
	defer d.mux.Unlock()

	_, ok := d.mountpoints[rq.Name]
	if ok {
		return res
	}

	pt := d.createPath(rq.Name)
	if err := os.MkdirAll(pt, 0755); err != nil {
		return responseError(fmt.Errorf("cannot mkdir: %s", err))
	}
	rootfs := "/" + d.asEtcdRoot(rq.Name)
	root := pathfs.NewPrefixFileSystem(&d.etcdbackend, rootfs)
	nfs := pathfs.NewPathNodeFs(root, nil)
	server, _, err := nodefs.MountRoot(pt, nfs.Root(), nil)

	if err != nil {
		return responseError(fmt.Errorf("cannot mount root : %s", err))
	}
	es := etcdFuseServer{pt, server, 0}
	d.mountpoints[rq.Name] = &es

	go server.Serve()
	return res
}
开发者ID:ulrichSchreiner,项目名称:etcdriver,代码行数:31,代码来源:driver.go

示例8: Start

// Start takes a path to the directory where the goinfo file system
// should be mounted. If the directory does not exist, it will be
// created. Start will return an error if the directory cannot be
// created or if the file system cannot be mounted at this location
// for any reason.
func Start(mountpoint string) error {
	//already mounted there
	if _, found := servers[mountpoint]; found {
		return nil
	}

	if _, err := os.Stat(mountpoint); os.IsNotExist(err) {
		if err = os.Mkdir(mountpoint, 0755); err != nil {
			return err
		}
	}

	nfs := pathfs.NewPathNodeFs(gfs, nil)
	conn := nodefs.NewFileSystemConnector(nfs.Root(), nil)
	server, err := fuse.NewServer(conn.RawFS(), mountpoint, &fuse.MountOptions{AllowOther: true})
	if err != nil {
		return errors.New("Failed to mount monitoring fs at " + mountpoint + ": " + err.Error())
	}

	servers[mountpoint] = server

	//start handling the fs calls
	go server.Serve()

	return nil
}
开发者ID:jmptrader,项目名称:goinfo,代码行数:31,代码来源:info.go

示例9: NewNotifyTest

func NewNotifyTest(t *testing.T) *NotifyTest {
	me := &NotifyTest{}
	me.fs = newNotifyFs()
	var err error
	me.dir, err = ioutil.TempDir("", "go-fuse-notify_test")
	if err != nil {
		t.Fatalf("TempDir failed: %v", err)
	}
	entryTtl := 100 * time.Millisecond
	opts := &nodefs.Options{
		EntryTimeout:    entryTtl,
		AttrTimeout:     entryTtl,
		NegativeTimeout: entryTtl,
		Debug:           VerboseTest(),
	}

	me.pathfs = pathfs.NewPathNodeFs(me.fs, nil)
	me.state, me.connector, err = nodefs.MountRoot(me.dir, me.pathfs.Root(), opts)
	if err != nil {
		t.Fatalf("MountNodeFileSystem failed: %v", err)
	}
	go me.state.Serve()
	if err := me.state.WaitMount(); err != nil {
		t.Fatal("WaitMount", err)
	}

	return me
}
开发者ID:Richardphp,项目名称:noms,代码行数:28,代码来源:notify_linux_test.go

示例10: setupCacheTest

func setupCacheTest(t *testing.T) (string, *pathfs.PathNodeFs, func()) {
	dir, err := ioutil.TempDir("", "go-fuse-cachetest")
	if err != nil {
		t.Fatalf("TempDir failed: %v", err)
	}
	os.Mkdir(dir+"/mnt", 0755)
	os.Mkdir(dir+"/orig", 0755)

	fs := &cacheFs{
		pathfs.NewLoopbackFileSystem(dir + "/orig"),
	}
	pfs := pathfs.NewPathNodeFs(fs, nil)
	state, conn, err := nodefs.MountRoot(dir+"/mnt", pfs.Root(), nil)
	if err != nil {
		t.Fatalf("MountNodeFileSystem failed: %v", err)
	}
	state.SetDebug(VerboseTest())
	conn.SetDebug(VerboseTest())
	pfs.SetDebug(VerboseTest())
	go state.Serve()

	return dir, pfs, func() {
		err := state.Unmount()
		if err == nil {
			os.RemoveAll(dir)
		}
	}
}
开发者ID:freakmac,项目名称:adbfs,代码行数:28,代码来源:cache_test.go

示例11: setupFAttrTest

func setupFAttrTest(t *testing.T, fs pathfs.FileSystem) (dir string, clean func()) {
	dir, err := ioutil.TempDir("", "go-fuse-fsetattr_test")
	if err != nil {
		t.Fatalf("TempDir failed: %v", err)
	}
	nfs := pathfs.NewPathNodeFs(fs, nil)
	opts := nodefs.NewOptions()
	opts.Debug = VerboseTest()

	state, _, err := nodefs.MountRoot(dir, nfs.Root(), opts)
	if err != nil {
		t.Fatalf("MountNodeFileSystem failed: %v", err)
	}

	go state.Serve()
	if err := state.WaitMount(); err != nil {
		t.Fatal("WaitMount", err)
	}

	if state.KernelSettings().Flags&fuse.CAP_FILE_OPS == 0 {
		t.Skip("Mount does not support file operations")
	}

	return dir, func() {
		if err := state.Unmount(); err != nil {
			t.Errorf("cleanup: Unmount: %v", err)
		} else {
			os.RemoveAll(dir)
		}
	}
}
开发者ID:Richardphp,项目名称:noms,代码行数:31,代码来源:fsetattr_test.go

示例12: setupFAttrTest

func setupFAttrTest(t *testing.T, fs pathfs.FileSystem) (dir string, clean func()) {
	dir, err := ioutil.TempDir("", "go-fuse-fsetattr_test")
	if err != nil {
		t.Fatalf("TempDir failed: %v", err)
	}
	nfs := pathfs.NewPathNodeFs(fs, nil)
	state, _, err := nodefs.MountRoot(dir, nfs.Root(), nil)
	if err != nil {
		t.Fatalf("MountNodeFileSystem failed: %v", err)
	}
	state.SetDebug(VerboseTest())

	go state.Serve()

	// Trigger INIT.
	os.Lstat(dir)
	if state.KernelSettings().Flags&fuse.CAP_FILE_OPS == 0 {
		t.Log("Mount does not support file operations")
	}

	return dir, func() {
		if state.Unmount() == nil {
			os.RemoveAll(dir)
		}
	}
}
开发者ID:yeonsh,项目名称:go-fuse,代码行数:26,代码来源:fsetattr_test.go

示例13: setupCacheTest

func setupCacheTest(t *testing.T) (string, *pathfs.PathNodeFs, func()) {
	dir := testutil.TempDir()
	os.Mkdir(dir+"/mnt", 0755)
	os.Mkdir(dir+"/orig", 0755)

	fs := &cacheFs{
		pathfs.NewLoopbackFileSystem(dir + "/orig"),
	}
	pfs := pathfs.NewPathNodeFs(fs, &pathfs.PathNodeFsOptions{Debug: testutil.VerboseTest()})

	opts := nodefs.NewOptions()
	opts.Debug = testutil.VerboseTest()
	state, _, err := nodefs.MountRoot(dir+"/mnt", pfs.Root(), opts)
	if err != nil {
		t.Fatalf("MountNodeFileSystem failed: %v", err)
	}
	go state.Serve()
	if err := state.WaitMount(); err != nil {
		t.Fatal("WaitMount", err)
	}
	return dir, pfs, func() {
		err := state.Unmount()
		if err == nil {
			os.RemoveAll(dir)
		}
	}
}
开发者ID:jszwedko,项目名称:ec2-metadatafs,代码行数:27,代码来源:cache_test.go

示例14: defaultReadTest

func defaultReadTest(t *testing.T) (root string, cleanup func()) {
	fs := &DefaultReadFS{
		FileSystem: pathfs.NewDefaultFileSystem(),
		size:       22,
	}

	var err error
	dir, err := ioutil.TempDir("", "go-fuse")
	if err != nil {
		t.Fatalf("TempDir failed: %v", err)
	}
	pathfs := pathfs.NewPathNodeFs(fs, nil)
	opts := nodefs.NewOptions()
	opts.Debug = VerboseTest()

	state, _, err := nodefs.MountRoot(dir, pathfs.Root(), opts)
	if err != nil {
		t.Fatalf("MountNodeFileSystem failed: %v", err)
	}
	go state.Serve()
	if err := state.WaitMount(); err != nil {
		t.Fatal("WaitMount", err)
	}
	return dir, func() {
		state.Unmount()
		os.Remove(dir)
	}
}
开发者ID:Richardphp,项目名称:noms,代码行数:28,代码来源:defaultread_test.go

示例15: setup

func setup(t *testing.T) (workdir string, cleanup func()) {
	wd, _ := ioutil.TempDir("", "")
	err := os.Mkdir(wd+"/mnt", 0700)
	if err != nil {
		t.Fatalf("Mkdir failed: %v", err)
	}

	err = os.Mkdir(wd+"/store", 0700)
	if err != nil {
		t.Fatalf("Mkdir failed: %v", err)
	}

	os.Mkdir(wd+"/ro", 0700)
	if err != nil {
		t.Fatalf("Mkdir failed: %v", err)
	}
	WriteFile(t, wd+"/ro/file1", "file1")
	WriteFile(t, wd+"/ro/file2", "file2")

	fs := NewAutoUnionFs(wd+"/store", testAOpts)

	nfs := pathfs.NewPathNodeFs(fs, nil)
	state, _, err := nodefs.MountRoot(wd+"/mnt", nfs.Root(), &testAOpts.Options)
	if err != nil {
		t.Fatalf("MountNodeFileSystem failed: %v", err)
	}
	fs.SetDebug(VerboseTest())
	go state.Serve()

	return wd, func() {
		state.Unmount()
		os.RemoveAll(wd)
	}
}
开发者ID:eliq,项目名称:go-fuse,代码行数:34,代码来源:autounion_test.go


注:本文中的github.com/hanwen/go-fuse/fuse/pathfs.NewPathNodeFs函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。