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

Golang fuse.OpenOut类代码示例

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

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



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

示例1: Open

func (constor *Constor) Open(input *fuse.OpenIn, out *fuse.OpenOut) (status fuse.Status) {
	pathl, err := constor.getPath(input.NodeId)
	if err != nil {
		constor.error("%s", err)
		return fuse.ToStatus(err)
	}
	inode, err := constor.inodemap.findInode(input.NodeId)
	if err != nil {
		constor.error("%s", err)
		return fuse.ToStatus(err)
	}
	constor.log("%s %d %d %d", pathl, input.Flags, input.Uid, input.Gid)
	fd, err := syscall.Open(pathl, int(input.Flags), 0)
	if err != nil {
		constor.error("%s", err)
		return fuse.ToStatus(err)
	}
	F := new(FD)
	F.fd = fd
	F.flags = int(input.Flags)
	F.layer = inode.layer
	constor.putfd(F)
	out.Fh = uint64(uintptr(unsafe.Pointer(F)))
	out.OpenFlags = 0
	constor.log("%d", out.Fh)
	return fuse.OK
}
开发者ID:krishnasrinivas,项目名称:constor,代码行数:27,代码来源:main.go


示例2: Open

func (constor *Constor) Open(input *fuse.OpenIn, out *fuse.OpenOut) (status fuse.Status) {
	inode := constor.inodemap.findInodePtr(input.NodeId)
	if inode == nil {
		return fuse.ENOENT
	}
	path := constor.getPath(inode.layer, inode.id)
	constor.log("%s %d", path, input.Flags)
	fd, err := syscall.Open(path, int(input.Flags), 0)
	if err != nil {
		constor.error("open failed %s : %s", path, err)
		return fuse.ToStatus(err)
	}
	F := new(FD)
	F.fd = fd
	F.flags = int(input.Flags)
	F.layer = inode.layer
	F.id = inode.id
	F.pid = input.Pid
	constor.putfd(F)
	out.Fh = uint64(uintptr(unsafe.Pointer(F)))
	if input.Flags&syscall.O_DIRECT != 0 {
		out.OpenFlags = fuse.FOPEN_DIRECT_IO
	} else {
		out.OpenFlags = fuse.FOPEN_KEEP_CACHE
	}

	constor.log("%d", out.Fh)
	return fuse.OK
}
开发者ID:krishnasrinivas,项目名称:confs,代码行数:29,代码来源:main.go


示例3: Open

func (c *rawBridge) Open(input *fuse.OpenIn, out *fuse.OpenOut) (status fuse.Status) {
	node := c.toInode(input.NodeId)
	f, code := node.fsInode.Open(input.Flags, &input.Context)
	if !code.Ok() || f == nil {
		return code
	}
	h, opened := node.mount.registerFileHandle(node, nil, f, input.Flags)
	out.OpenFlags = opened.FuseFlags
	out.Fh = h
	return fuse.OK
}
开发者ID:eliq,项目名称:go-fuse,代码行数:11,代码来源:fsops.go


示例4: OpenDir

func (c *rawBridge) OpenDir(input *fuse.OpenIn, out *fuse.OpenOut) (code fuse.Status) {
	node := c.toInode(input.NodeId)
	stream, err := node.fsInode.OpenDir(&input.Context)
	if err != fuse.OK {
		return err
	}
	stream = append(stream, node.getMountDirEntries()...)
	de := &connectorDir{
		node: node.Node(),
		stream: append(stream,
			fuse.DirEntry{Mode: fuse.S_IFDIR, Name: "."},
			fuse.DirEntry{Mode: fuse.S_IFDIR, Name: ".."}),
		rawFS: c,
	}
	h, opened := node.mount.registerFileHandle(node, de, nil, input.Flags)
	out.OpenFlags = opened.FuseFlags
	out.Fh = h
	return fuse.OK
}
开发者ID:eliq,项目名称:go-fuse,代码行数:19,代码来源:fsops.go


示例5: OpenDir

func (constor *Constor) OpenDir(input *fuse.OpenIn, out *fuse.OpenOut) (code fuse.Status) {
	constor.log("%d", input.NodeId)
	path, err := constor.dentrymap.getPath(input.NodeId)
	if err != nil {
		return fuse.ToStatus(err)
	}
	entries := map[string]DirEntry{}
	for li, layer := range constor.layers {
		f, err := os.Open(Path.Join(layer, path))
		if err != nil {
			continue
		}
		infos, _ := f.Readdir(0)
		for i := range infos {
			// workaround forhttps://code.google.com/p/go/issues/detail?id=5960
			if infos[i] == nil {
				continue
			}
			name := infos[i].Name()
			if _, ok := entries[name]; ok {
				// skip if the file was in upper layer
				continue
			}

			mode := infos[i].Mode()
			stat := infos[i].Sys().(*syscall.Stat_t)
			d := DirEntry{
				Name: name,
				Mode: uint32(mode),
				Ino:  stat.Ino,
			}
			if li == 0 {
				err := constor.Lstat(Path.Join(path, name), stat)
				if err == nil {
					d.Ino = stat.Ino
				}
			}
			d.Stat = *stat
			pathl := Path.Join(constor.layers[li], path, name)
			if constor.isdeleted(pathl) {
				d.Deleted = true
			}
			entries[name] = d
		}
		f.Close()
	}
	output := make([]DirEntry, 0, 500)

	for _, d := range entries {
		if d.Deleted {
			continue
		}
		output = append(output, d)
	}
	stat := syscall.Stat_t{}
	err = constor.Lstat(path, &stat)
	d := DirEntry{
		Name: ".",
		Mode: stat.Mode,
		Ino:  stat.Ino,
	}
	output = append(output, d)

	err = constor.Lstat(Path.Join(path, ".."), &stat)
	d = DirEntry{
		Name: "..",
		Mode: stat.Mode,
		Ino:  stat.Ino,
	}
	output = append(output, d)

	for i, _ := range output {
		output[i].Offset = uint64(i) + 1
	}
	F := new(FD)
	F.stream = output
	constor.putfd(F)
	out.Fh = uint64(uintptr(unsafe.Pointer(F)))
	out.OpenFlags = 0
	return fuse.OK
}
开发者ID:krishnasrinivas,项目名称:constor,代码行数:81,代码来源:main.go


示例6: OpenDir

func (constor *Constor) OpenDir(input *fuse.OpenIn, out *fuse.OpenOut) (code fuse.Status) {
	inode := constor.inodemap.findInodePtr(input.NodeId)
	if inode == nil {
		constor.log("inode == nil for %d", input.NodeId)
		return fuse.ENOENT
	}
	constor.log("%s", inode.id)
	entries := map[string]DirEntry{}
	for li, _ := range constor.layers {
		path := constor.getPath(li, inode.id)
		stat := syscall.Stat_t{}
		err := syscall.Lstat(path, &stat)
		if err != nil {
			// continue aggregating upper layers
			continue
		}
		if (stat.Mode & syscall.S_IFMT) != syscall.S_IFDIR {
			constor.error("Not a dir: %s", path)
			break
		}

		f, err := os.Open(path)
		if err != nil {
			constor.error("Open failed on %s", path)
			break
		}
		infos, _ := f.Readdir(0) // reads all entries except "." and ".."
		for i := range infos {
			// workaround forhttps://code.google.com/p/go/issues/detail?id=5960
			if infos[i] == nil {
				continue
			}
			name := infos[i].Name()
			if _, ok := entries[name]; ok {
				// skip if the file was in upper layer
				continue
			}
			d := DirEntry{
				Name: name,
				Mode: uint32(infos[i].Mode()),
			}
			if constor.isdeleted(Path.Join(path, name), infos[i].Sys().(*syscall.Stat_t)) {
				d.Deleted = true
			} else {
				id, err := constor.getid(li, inode.id, name)
				if err != nil {
					constor.error("getid failed on %d %s %s", li, inode.id, name)
					continue
				}
				d.Ino = idtoino(id)

			}
			entries[name] = d
		}
		f.Close()
	}
	output := make([]DirEntry, 0, 500)

	for _, d := range entries {
		if d.Deleted {
			continue
		}
		output = append(output, d)
	}
	d := DirEntry{
		Name: ".",
		Mode: syscall.S_IFDIR,
		Ino:  idtoino(inode.id),
	}
	output = append(output, d)

	// FIXME: take care of ".." entry
	// err = constor.Lstat(Path.Join(path, ".."), &stat)
	// d = DirEntry{
	// 	Name: "..",
	// 	Mode: syscall.S_IFDIR,
	// }
	// output = append(output, d)

	for i, _ := range output {
		output[i].Offset = uint64(i) + 1
	}
	fmt.Println(output)
	F := new(FD)
	if F == nil {
		return fuse.ToStatus(syscall.ENOMEM)
	}
	F.stream = output
	constor.putfd(F)
	out.Fh = uint64(uintptr(unsafe.Pointer(F)))
	out.OpenFlags = 0
	return fuse.OK
}
开发者ID:krishnasrinivas,项目名称:confs,代码行数:93,代码来源:main.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang nodefs.MountFileSystem函数代码示例发布时间:2022-05-23
下一篇:
Golang fuse.MountOptions类代码示例发布时间: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