• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang pathfs.NewDefaultFileSystem函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: NewStatFS

func NewStatFS() *StatFS {
	return &StatFS{
		FileSystem: pathfs.NewDefaultFileSystem(),
		entries:    make(map[string]*fuse.Attr),
		dirs:       make(map[string][]fuse.DirEntry),
	}
}
开发者ID:rfjakob,项目名称:go-fuse,代码行数:7,代码来源:statfs.go


示例3: New

// New initializes a new TagsFs that uses the given AWS client
func New(client *ec2.EC2, instanceID string) *TagsFs {
	return &TagsFs{
		FileSystem: pathfs.NewReadonlyFileSystem(pathfs.NewDefaultFileSystem()),
		Client:     client,
		InstanceID: instanceID,
	}
}
开发者ID:jszwedko,项目名称:ec2-metadatafs,代码行数:8,代码来源:tagsfs.go


示例4: 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


示例5: 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


示例6: newNotifyFs

func newNotifyFs() *NotifyFs {
	return &NotifyFs{
		FileSystem: pathfs.NewDefaultFileSystem(),
		sizeChan:   make(chan uint64, 1),
		existChan:  make(chan bool, 1),
	}
}
开发者ID:Richardphp,项目名称:noms,代码行数:7,代码来源:notify_linux_test.go


示例7: NewUnionFs

func NewUnionFs(fileSystems []pathfs.FileSystem, options UnionFsOptions) (pathfs.FileSystem, error) {
	g := &unionFS{
		options:     &options,
		fileSystems: fileSystems,
		FileSystem:  pathfs.NewDefaultFileSystem(),
	}

	writable := g.fileSystems[0]
	code := g.createDeletionStore()
	if !code.Ok() {
		return nil, fmt.Errorf("could not create deletion path %v: %v", options.DeletionDirName, code)
	}

	g.deletionCache = newDirCache(writable, options.DeletionDirName, options.DeletionCacheTTL)
	g.branchCache = NewTimedCache(
		func(n string) (interface{}, bool) { return g.getBranchAttrNoCache(n), true },
		options.BranchCacheTTL)

	g.hiddenFiles = make(map[string]bool)
	for _, name := range options.HiddenFiles {
		g.hiddenFiles[name] = true
	}

	return g, nil
}
开发者ID:eliq,项目名称:go-fuse,代码行数:25,代码来源:unionfs.go


示例8: 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


示例9: New

// New initializes a new MetadataFs that uses the given endpoint as the
// target of metadata requests
func New(endpoint string) *MetadataFs {
	return &MetadataFs{
		FileSystem: pathfs.NewReadonlyFileSystem(pathfs.NewDefaultFileSystem()),
		Client:     &http.Client{},
		Endpoint:   endpoint,
	}
}
开发者ID:jszwedko,项目名称:ec2-metadatafs,代码行数:9,代码来源:metadatafs.go


示例10: start

func start(dataset string, mount mount) {
	ds, err := spec.GetDataset(dataset)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Could not create dataset: %s\n", err)
		return
	}

	hv, ok := ds.MaybeHeadValue()
	if ok {
		if !types.IsSubtype(fsType, hv.Type()) {
			fmt.Fprintf(os.Stderr, "Invalid dataset head: expected type '%s' but found type '%s'\n", fsType.Desc.(types.StructDesc).Name, hv.Type().Desc.(types.StructDesc).Name)
			return
		}
	} else {
		rootAttr := makeAttr(0777) // create the root directory with maximally permissive permissions
		rootDir := types.NewStructWithType(directoryType, types.ValueSlice{types.NewMap()})
		rootInode := types.NewStructWithType(inodeType, types.ValueSlice{rootAttr, rootDir})
		hv = types.NewStructWithType(fsType, types.ValueSlice{rootInode})
	}

	mount(&nomsFS{
		FileSystem: pathfs.NewDefaultFileSystem(),
		ds:         ds,
		head:       hv.(types.Struct),
		mdLock:     &sync.Mutex{},
		nodes:      make(map[hash.Hash]*nNode),
	})
}
开发者ID:Richardphp,项目名称:noms,代码行数:28,代码来源:nomsfs.go


示例11: 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


示例12: NewMultiZipFs

func NewMultiZipFs() *MultiZipFs {
	m := &MultiZipFs{
		zips:          make(map[string]nodefs.Node),
		dirZipFileMap: make(map[string]string),
		FileSystem:    pathfs.NewDefaultFileSystem(),
	}
	return m
}
开发者ID:hoffoo,项目名称:go-fuse,代码行数:8,代码来源:multizip.go


示例13: NewDriver

func NewDriver(basepath, etcdendpoint string) dkvolume.Driver {
	e := etcDriver{
		etcdbackend: etcdfs.EtcdFs{FileSystem: pathfs.NewDefaultFileSystem(), EtcdEndpoint: etcdendpoint},
		mountpoints: make(map[string]*etcdFuseServer),
		basePath:    basepath,
	}
	return &e
}
开发者ID:ulrichSchreiner,项目名称:etcdriver,代码行数:8,代码来源:driver.go


示例14: NewFs

// NewKeywhizFs readies a KeywhizFs struct and its parent filesystem objects.
func NewFs(client *api.Client, owner keywhizfs.Ownership) (*fs, nodefs.Node) {
	defaultfs := pathfs.NewDefaultFileSystem()            // Returns ENOSYS by default
	readonlyfs := pathfs.NewReadonlyFileSystem(defaultfs) // R/W calls return EPERM

	kwfs := &fs{readonlyfs, client, owner}
	nfs := pathfs.NewPathNodeFs(kwfs, nil)
	nfs.SetDebug(true)
	return kwfs, nfs.Root()
}
开发者ID:pshouse,项目名称:global-hack-day-3,代码行数:10,代码来源:fs.go


示例15: MountFs

func MountFs(path string) {
	LoadSession()
	CacheInit()
	nfs := pathfs.NewPathNodeFs(&DropboxFs{FileSystem: pathfs.NewDefaultFileSystem()}, nil)
	server, _, err := nodefs.MountRoot(path, nfs.Root(), nil)
	if err != nil {
		log.Fatalf("Mount fail: %v\n", err)
	}
	server.Serve()
}
开发者ID:sgodbold,项目名称:dropbox-mnt-go,代码行数:10,代码来源:setup.go


示例16: main

//
//func (me *HelloFs) OpenDir(name string, context *fuse.Context) (c []fuse.DirEntry, code fuse.Status) {
//	if name == "" {
//		c = []fuse.DirEntry{{Name: "file.txt", Mode: fuse.S_IFREG}}
//		return c, fuse.OK
//	}
//	return nil, fuse.ENOENT
//}
//
//func (me *HelloFs) Open(name string, flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) {
//	if name != "file.txt" {
//		return nil, fuse.ENOENT
//	}
//	if flags&fuse.O_ANYWRITE != 0 {
//		return nil, fuse.EPERM
//	}
//	return nodefs.NewDataFile([]byte(name)), fuse.OK
//}
//
func main() {
	use_hammer2 := false
	flag.Parse()
	if len(flag.Args()) < 1 {
		log.Fatal("Usage:\n  hello MOUNTPOINT")
	}
	var nfs *pathfs.PathNodeFs
	if use_hammer2 {
		nfs = pathfs.NewPathNodeFs(&Hammer2Fs{FileSystem: pathfs.NewDefaultFileSystem()}, nil)
	} else {
		nfs = pathfs.NewPathNodeFs(&HammerFs{FileSystem: pathfs.NewDefaultFileSystem()}, nil)
	}
	fmt.Println("nfs ==", nfs)
	//	server, _, err := nodefs.MountFileSystem(flag.Arg(0), nfs, nil)
	//	if err != nil {
	//		log.Fatal("Mount fail: %v\n", err)
	//	}
	//	server.Serve()
}
开发者ID:varialus,项目名称:hammer,代码行数:38,代码来源:main.go


示例17: TestHelloWorld

func TestHelloWorld(t *testing.T) {
	tmpSrv, err := ioutil.TempDir("", "fuse-server-")
	if err != nil {
		t.Fatal(err)
	}
	defer os.RemoveAll(tmpSrv)
	hfs := &HelloFs{FileSystem: pathfs.NewDefaultFileSystem()}
	hsrv, err := startServer(tmpSrv, hfs)
	if err != nil {
		t.Fatal(err)
	}
	defer hsrv.Close()
	tmpCli, err := ioutil.TempDir("", "fuse-client-")
	if err != nil {
		t.Fatal(err)
	}
	defer os.RemoveAll(tmpCli)
	cliFs, err := startFs(tmpCli, hsrv.addr.String())
	if err != nil {
		t.Fatal(err)
	}
	defer cliFs.Close()
	fis, err := ioutil.ReadDir(tmpCli)
	if err != nil {
		t.Fatal(err)
	}
	if len(fis) != 1 {
		t.Fatalf("expected to find one file, got %d", len(fis))
	}
	fi := fis[0]
	if fi.IsDir() {
		t.Fatal("should be a file, got dir")
	}
	if fi.Name() != "file.txt" {
		t.Fatalf("file should be \"file.txt\", got %s", fi.Name())
	}
	f, err := os.Open(filepath.Join(tmpCli, fi.Name()))
	if err != nil {
		t.Fatal(err)
	}
	defer f.Close()
	data, err := ioutil.ReadAll(f)
	if err != nil {
		t.Fatal(err)
	}
	if string(data) != "file.txt" {
		t.Fatalf("file content expected to be \"file.txt\", got %s", data)
	}
	if f, err := os.Open("whatever"); !os.IsNotExist(err) {
		if err == nil {
			f.Close()
		}
		t.Fatalf("error from open should be not exist, got %v", err)
	}
}
开发者ID:LK4D4,项目名称:grfuse,代码行数:55,代码来源:hellofs_test.go


示例18: NewObjectFileSystem

func NewObjectFileSystem(c *config.Config, mapper *mapper.ObjectMapper) *objectFileSystem {
	fs := &objectFileSystem{
		containerName:   c.ContainerName,
		createContainer: c.CreateContainer,
		mapper:          mapper,
		lock:            sync.Mutex{},

		FileSystem: pathfs.NewDefaultFileSystem(),
	}
	return fs
}
开发者ID:hironobu-s,项目名称:swiftfs,代码行数:11,代码来源:filesystem.go


示例19: NewKeywhizFs

// NewKeywhizFs readies a KeywhizFs struct and its parent filesystem objects.
func NewKeywhizFs(client *Client, ownership Ownership, timeouts Timeouts, logConfig log.Config) (kwfs *KeywhizFs, root nodefs.Node, err error) {
	logger := log.New("kwfs", logConfig)
	cache := NewCache(client, timeouts, logConfig)

	defaultfs := pathfs.NewDefaultFileSystem()            // Returns ENOSYS by default
	readonlyfs := pathfs.NewReadonlyFileSystem(defaultfs) // R/W calls return EPERM

	kwfs = &KeywhizFs{readonlyfs, logger, client, cache, time.Now(), ownership}
	nfs := pathfs.NewPathNodeFs(kwfs, nil)
	nfs.SetDebug(logConfig.Debug)
	return kwfs, nfs.Root(), nil
}
开发者ID:rxacevedo,项目名称:keywhiz-fs,代码行数:13,代码来源:fs.go


示例20: main

func main() {
	flag.Parse()
	if len(flag.Args()) < 1 {
		log.Fatal("Usage:\n  hello MOUNTPOINT")
	}
	nfs := pathfs.NewPathNodeFs(&HelloFs{FileSystem: pathfs.NewDefaultFileSystem()}, nil)
	server, _, err := nodefs.MountRoot(flag.Arg(0), nfs.Root(), nil)
	if err != nil {
		log.Fatalf("Mount fail: %v\n", err)
	}
	server.Serve()
}
开发者ID:rfjakob,项目名称:go-fuse,代码行数:12,代码来源:main.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang pathfs.NewLoopbackFileSystem函数代码示例发布时间:2022-05-23
下一篇:
Golang nodefs.Node类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap