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

Golang fuse.Status函数代码示例

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

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



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

示例1: Rmdir

func (me *UnionFs) Rmdir(path string, context *fuse.Context) (code fuse.Status) {
	r := me.getBranch(path)
	if r.code != fuse.OK {
		return r.code
	}
	if !r.attr.IsDir() {
		return fuse.Status(syscall.ENOTDIR)
	}

	stream, code := me.OpenDir(path, context)
	found := false
	for _ = range stream {
		found = true
	}
	if found {
		return fuse.Status(syscall.ENOTEMPTY)
	}

	if r.branch > 0 {
		code = me.putDeletion(path)
		return code
	}
	code = me.fileSystems[0].Rmdir(path, context)
	if code != fuse.OK {
		return code
	}

	r = me.branchCache.GetFresh(path).(branchResult)
	if r.branch > 0 {
		code = me.putDeletion(path)
	}
	return code
}
开发者ID:kicool,项目名称:go-fuse,代码行数:33,代码来源:unionfs.go


示例2: Rmdir

func (vfs FuseVfs) Rmdir(name string, context *fuse.Context) fuse.Status {
	log.Infof(2, "BEGIN Rmdir(%v)", name)
	defer log.Infof(2, "END Rmdir(%v)", name)

	path := vfs.splitPath(name)

	switch path[0] {
	case tagsDir:
		if len(path) != 2 {
			// can only remove top-level tag directories
			return fuse.EPERM
		}

		tagName := path[1]
		tag, err := vfs.store.TagByName(tagName)
		if err != nil {
			log.Fatalf("could not retrieve tag '%v': %v", tagName, err)
		}
		if tag == nil {
			return fuse.ENOENT
		}

		count, err := vfs.store.FileTagCountByTagId(tag.Id)
		if err != nil {
			log.Fatalf("could not retrieve file-tag count for tag '%v': %v", tagName, err)
		}
		if count > 0 {
			return fuse.Status(syscall.ENOTEMPTY)
		}

		if err := vfs.store.DeleteTag(tag.Id); err != nil {
			log.Fatalf("could not delete tag '%v': %v", tagName, err)
		}

		if err := vfs.store.Commit(); err != nil {
			log.Fatalf("could not commit transaction: %v", err)
		}

		return fuse.OK
	case queriesDir:
		if len(path) != 2 {
			// can only remove top-level queries directories
			return fuse.EPERM
		}

		text := path[1]

		if err := vfs.store.DeleteQuery(text); err != nil {
			log.Fatalf("could not remove tag '%v': %v", name, err)
		}

		if err := vfs.store.Commit(); err != nil {
			log.Fatalf("could not commit transaction: %v", err)
		}

		return fuse.OK
	}

	return fuse.ENOSYS
}
开发者ID:Konubinix,项目名称:tmsu,代码行数:60,代码来源:fusevfs.go


示例3: GetAttr

func (f *flipNode) GetAttr(out *fuse.Attr, file nodefs.File, c *fuse.Context) fuse.Status {
	select {
	case <-f.ok:
		// use a status that is easily recognizable.
		return fuse.Status(syscall.EXDEV)
	default:
	}
	return f.Node.GetAttr(out, file, c)
}
开发者ID:jszwedko,项目名称:ec2-metadatafs,代码行数:9,代码来源:delete_linux_test.go


示例4: Link

func (node *inMemNode) Link(name string, existing nodefs.Node, context *fuse.Context) (newNode *nodefs.Inode, code fuse.Status) {
	if node.Inode().GetChild(name) != nil {
		return nil, fuse.Status(syscall.EEXIST)
	}
	node.Inode().AddChild(name, existing.Inode())
	if inMemChild, ok := existing.(*inMemNode); ok {
		inMemChild.incrementLinks()
	}
	return existing.Inode(), fuse.OK
}
开发者ID:e-tothe-ipi,项目名称:inmemfs,代码行数:10,代码来源:main.go


示例5: Symlink

func (n *configNode) Symlink(name string, content string, context *fuse.Context) (*nodefs.Inode, fuse.Status) {
	dir := content
	components := strings.Split(content, ":")
	if len(components) > 2 || len(components) == 0 {
		return nil, fuse.Status(syscall.EINVAL)
	}

	var root nodefs.Node
	if len(components) == 2 {
		dir = components[0]
	}

	if fi, err := os.Lstat(dir); err != nil {
		return nil, fuse.ToStatus(err)
	} else if !fi.IsDir() {
		return nil, fuse.Status(syscall.ENOTDIR)
	}

	var opts *nodefs.Options
	if len(components) == 1 {
		root = pathfs.NewPathNodeFs(pathfs.NewLoopbackFileSystem(content), nil).Root()
	} else {
		var err error
		root, err = NewGitFSRoot(content, n.fs.opts)
		if err != nil {
			log.Printf("NewGitFSRoot(%q): %v", content, err)
			return nil, fuse.ENOENT
		}
		opts = &nodefs.Options{
			EntryTimeout:    time.Hour,
			NegativeTimeout: time.Hour,
			AttrTimeout:     time.Hour,
			PortableInodes:  true,
		}
	}

	if code := n.fs.fsConn.Mount(n.corresponding.Inode(), name, root, opts); !code.Ok() {
		return nil, code
	}

	linkNode := newGitConfigNode(content)
	return n.Inode().NewChild(name, false, linkNode), fuse.OK
}
开发者ID:hanwen,项目名称:gitfs,代码行数:43,代码来源:multifs.go


示例6: Allocate

// Allocate - FUSE call for fallocate(2)
//
// mode=FALLOC_FL_KEEP_SIZE is implemented directly.
//
// mode=FALLOC_DEFAULT is implemented as a two-step process:
//
//   (1) Allocate the space using FALLOC_FL_KEEP_SIZE
//   (2) Set the file size using ftruncate (via truncateGrowFile)
//
// This allows us to reuse the file grow mechanics from Truncate as they are
// complicated and hard to get right.
//
// Other modes (hole punching, zeroing) are not supported.
func (f *file) Allocate(off uint64, sz uint64, mode uint32) fuse.Status {
	if mode != FALLOC_DEFAULT && mode != FALLOC_FL_KEEP_SIZE {
		f := func() {
			tlog.Warn.Print("fallocate: only mode 0 (default) and 1 (keep size) are supported")
		}
		allocateWarnOnce.Do(f)
		return fuse.Status(syscall.EOPNOTSUPP)
	}

	f.fdLock.RLock()
	defer f.fdLock.RUnlock()
	if f.released {
		return fuse.EBADF
	}
	f.fileTableEntry.writeLock.Lock()
	defer f.fileTableEntry.writeLock.Unlock()

	blocks := f.contentEnc.ExplodePlainRange(off, sz)
	firstBlock := blocks[0]
	lastBlock := blocks[len(blocks)-1]

	// Step (1): Allocate the space the user wants using FALLOC_FL_KEEP_SIZE.
	// This will fill file holes and/or allocate additional space past the end of
	// the file.
	cipherOff := firstBlock.BlockCipherOff()
	cipherSz := lastBlock.BlockCipherOff() - cipherOff +
		f.contentEnc.PlainSizeToCipherSize(lastBlock.Skip+lastBlock.Length)
	err := syscallcompat.Fallocate(f.intFd(), FALLOC_FL_KEEP_SIZE, int64(cipherOff), int64(cipherSz))
	tlog.Debug.Printf("Allocate off=%d sz=%d mode=%x cipherOff=%d cipherSz=%d\n",
		off, sz, mode, cipherOff, cipherSz)
	if err != nil {
		return fuse.ToStatus(err)
	}
	if mode == FALLOC_FL_KEEP_SIZE {
		// The user did not want to change the apparent size. We are done.
		return fuse.OK
	}
	// Step (2): Grow the apparent file size
	// We need the old file size to determine if we are growing the file at all.
	newPlainSz := off + sz
	oldPlainSz, err := f.statPlainSize()
	if err != nil {
		return fuse.ToStatus(err)
	}
	if newPlainSz <= oldPlainSz {
		// The new size is smaller (or equal). Fallocate with mode = 0 never
		// truncates a file, so we are done.
		return fuse.OK
	}
	// The file grows. The space has already been allocated in (1), so what is
	// left to do is to pad the first and last block and call truncate.
	// truncateGrowFile does just that.
	return f.truncateGrowFile(oldPlainSz, newPlainSz)
}
开发者ID:rfjakob,项目名称:gocryptfs,代码行数:67,代码来源:file_allocate_truncate.go


示例7: makeKnot

func (m *MNode) makeKnot(name string,isDir bool) (*nodefs.Inode,*MNode,fuse.Status) {
	m.obj.Lock()
	defer m.obj.Unlock()
	d,ok := m.obj.Obj.(*joinf.Directory)
	if !ok {
		return nil,nil,fuse.ENOTDIR
	}
	{
		c := m.Inode().GetChild(name)
		if c!=nil { return nil,nil,fuse.Status(syscall.EEXIST) }
		id,_ := d.Find(name)
		if id!="" { return nil,nil,fuse.Status(syscall.EEXIST) }
	}
	id := uuid.NewV4().String()
	if isDir {
		r := m.lm.Dirs(id)
		e := joinf.CreateDir(r)
		if e!=nil { return nil,nil,fuse.ToStatus(e) }
		e = d.Insert(name,id)
		if e!=nil {
			r.Delete()
			return nil,nil,fuse.ToStatus(e)
		}
		r.Dispose()
	}else{
		r := m.lm.Files(id)
		e := joinf.CreateFile(r)
		if e!=nil { return nil,nil,fuse.ToStatus(e) }
		e = d.Insert(name,id)
		if e!=nil {
			r.Delete()
			return nil,nil,fuse.ToStatus(e)
		}
		r.Dispose()
	}
	co := m.lm.Load(id)
	nin := &MNode{nodefs.NewDefaultNode(),m.lm,co}
	return m.Inode().NewChild(name,isDir,nin),nin,fuse.OK
}
开发者ID:maxymania,项目名称:metaclusterfs,代码行数:39,代码来源:node.go


示例8: Symlink

func (parent *inMemNode) Symlink(name string, content string, context *fuse.Context) (*nodefs.Inode, fuse.Status) {
	if parent.Inode().GetChild(name) != nil {
		return nil, fuse.Status(syscall.EEXIST)
	}
	node := parent.fs.createNode()
	node.attr.Mode = 0777 | fuse.S_IFLNK
	contentBytes := []byte(content)
	node.setSize(len(contentBytes))
	copy(node.contents, contentBytes)
	parent.Inode().NewChild(name, false, node)
	parent.incrementLinks()
	return node.Inode(), fuse.OK
}
开发者ID:e-tothe-ipi,项目名称:inmemfs,代码行数:13,代码来源:main.go


示例9: Lookup

func (constor *Constor) Lookup(header *fuse.InHeader, name string, out *fuse.EntryOut) fuse.Status {
	var stat syscall.Stat_t
	if len(name) > 255 {
		constor.error("name too long : %s", name)
		return fuse.Status(syscall.ENAMETOOLONG)
	}
	li := -1
	parent := constor.inodemap.findInodePtr(header.NodeId)
	if parent == nil {
		constor.error("Unable to find parent inode : %d", header.NodeId)
		return fuse.ENOENT
	}
	constor.log("%s(%s)", parent.id, name)
	id, err := constor.getid(-1, parent.id, name)
	if err != nil {
		// logging this error will produce too many logs as there will be too many
		// lookps on non-existant files
		return fuse.ToStatus(err)
	}
	inode := constor.inodemap.findInodeId(id)
	if inode != nil {
		li = inode.layer
	} else {
		li = constor.getLayer(id)
	}
	if li == -1 {
		constor.error("Unable to find inode for %s(%s) id %s", parent.id, name, id)
		return fuse.ENOENT
	}
	err = constor.Lstat(li, id, &stat)
	if err != nil {
		constor.error("Unable to Lstat inode for %s(%s) id %s", parent.id, name, id)
		return fuse.ToStatus(err)
	}
	if inode == nil {
		inode = NewInode(constor, id)
		inode.layer = li
		constor.inodemap.hashInode(inode)
	} else {
		inode.lookup()
	}
	attr := (*fuse.Attr)(&out.Attr)
	attr.FromStat(&stat)
	out.NodeId = uint64(uintptr(unsafe.Pointer(inode)))
	out.Ino = attr.Ino
	out.EntryValid = 1000
	out.AttrValid = 1000
	constor.log("%s", id)
	return fuse.OK
}
开发者ID:krishnasrinivas,项目名称:confs,代码行数:50,代码来源:main.go


示例10: Create

func (parent *inMemNode) Create(name string, flags uint32, mode uint32, context *fuse.Context) (file nodefs.File, child *nodefs.Inode, code fuse.Status) {
	if parent.Inode().GetChild(name) != nil {
		return nil, nil, fuse.Status(syscall.EEXIST)
	}
	node := parent.fs.createNode()
	node.attr.Mode = mode | fuse.S_IFREG
	parent.Inode().NewChild(name, false, node)
	parent.incrementLinks()
	f, openStatus := node.Open(flags, context)
	if openStatus != fuse.OK {
		return nil, nil, openStatus
	}
	return f, node.Inode(), fuse.OK
}
开发者ID:e-tothe-ipi,项目名称:inmemfs,代码行数:14,代码来源:main.go


示例11: createDeletionStore

func (me *UnionFs) createDeletionStore() (code fuse.Status) {
	writable := me.fileSystems[0]
	fi, code := writable.GetAttr(me.options.DeletionDirName, nil)
	if code == fuse.ENOENT {
		code = writable.Mkdir(me.options.DeletionDirName, 0755, nil)
		if code.Ok() {
			fi, code = writable.GetAttr(me.options.DeletionDirName, nil)
		}
	}

	if !code.Ok() || !fi.IsDir() {
		code = fuse.Status(syscall.EROFS)
	}

	return code
}
开发者ID:kicool,项目名称:go-fuse,代码行数:16,代码来源:unionfs.go


示例12: Symlink

func (fs *autoUnionFs) Symlink(pointedTo string, linkName string, context *fuse.Context) (code fuse.Status) {
	comps := strings.Split(linkName, "/")
	if len(comps) != 2 {
		return fuse.EPERM
	}

	if comps[0] == _CONFIG {
		roots := fs.getRoots(pointedTo)
		if roots == nil {
			return fuse.Status(syscall.ENOTDIR)
		}

		name := comps[1]
		return fs.addFs(name, roots)
	}
	return fuse.EPERM
}
开发者ID:rfjakob,项目名称:go-fuse,代码行数:17,代码来源:autounion.go


示例13: Read

func (f *androidFile) Read(dest []byte, off int64) (fuse.ReadResult, fuse.Status) {
	if off >= f.node.Size {
		// ENXIO = no such address.
		return nil, fuse.Status(int(syscall.ENXIO))
	}

	if off+int64(len(dest)) > f.node.Size {
		dest = dest[:f.node.Size-off]
	}
	b := bytes.NewBuffer(dest[:0])
	err := f.node.fs.dev.AndroidGetPartialObject64(f.node.Handle(), b, off, uint32(len(dest)))
	if err != nil {
		log.Println("AndroidGetPartialObject64 failed:", err)
		return nil, fuse.EIO
	}

	return &fuse.ReadResultData{dest[:b.Len()]}, fuse.OK
}
开发者ID:sneezer,项目名称:go-mtpfs,代码行数:18,代码来源:android.go


示例14: Mkdir

func (parent *AppendFSNode) Mkdir(name string, mode uint32, context *fuse.Context) (newNode *nodefs.Inode, code fuse.Status) {
	if parent.Inode().GetChild(name) != nil {
		return nil, fuse.Status(syscall.EEXIST)
	}
	node := CreateNode(parent)
	node.attr.Mode = mode | fuse.S_IFDIR
	node.attr.Nlink = 2
	node.name = name
	inode := parent.inode.NewChild(name, true, node)
	parent.incrementLinks()

	err := node.fs.AppendMetadata(node.AsNodeMetadata())
	if err != nil {
		return nil, fuse.EIO
	}

	return inode, fuse.OK
}
开发者ID:e-tothe-ipi,项目名称:appendfs,代码行数:18,代码来源:appendfsnode.go


示例15: isDeleted

// The isDeleted() method tells us if a path has a marker in the deletion store.
// It may return an error code if the store could not be accessed.
func (me *UnionFs) isDeleted(name string) (deleted bool, code fuse.Status) {
	marker := me.deletionPath(name)
	haveCache, found := me.deletionCache.HasEntry(filepath.Base(marker))
	if haveCache {
		return found, fuse.OK
	}

	_, code = me.fileSystems[0].GetAttr(marker, nil)

	if code == fuse.OK {
		return true, code
	}
	if code == fuse.ENOENT {
		return false, fuse.OK
	}

	log.Println("error accessing deletion marker:", marker)
	return false, fuse.Status(syscall.EROFS)
}
开发者ID:kicool,项目名称:go-fuse,代码行数:21,代码来源:unionfs.go


示例16: Symlink

func (parent *AppendFSNode) Symlink(name string, content string, context *fuse.Context) (*nodefs.Inode, fuse.Status) {
	if parent.Inode().GetChild(name) != nil {
		return nil, fuse.Status(syscall.EEXIST)
	}
	node := CreateNode(parent)
	node.attr.Mode = 0777 | fuse.S_IFLNK
	contentBytes := []byte(content)
	node.setSize(uint64(len(contentBytes)))
	node.symlink = contentBytes
	node.name = name
	parent.Inode().NewChild(name, false, node)
	parent.incrementLinks()

	err := node.fs.AppendMetadata(node.AsNodeMetadata())
	if err != nil {
		return nil, fuse.EIO
	}

	return node.Inode(), fuse.OK
}
开发者ID:e-tothe-ipi,项目名称:appendfs,代码行数:20,代码来源:appendfsnode.go


示例17: GetXAttr

func (fs *nomsFS) GetXAttr(path string, attribute string, context *fuse.Context) ([]byte, fuse.Status) {
	fs.mdLock.Lock()
	defer fs.mdLock.Unlock()
	np, code := fs.getPath(path)
	if code != fuse.OK {
		return nil, code
	}

	xattr := np.inode.Get("attr").(types.Struct).Get("xattr").(types.Map)

	v, found := xattr.MaybeGet(types.String(attribute))
	if !found {
		return nil, fuse.Status(93) // syscall.ENOATTR
	}

	blob := v.(types.Blob)

	data := make([]byte, blob.Len())
	blob.Reader().Read(data)

	return data, fuse.OK
}
开发者ID:Richardphp,项目名称:noms,代码行数:22,代码来源:nomsfs.go


示例18: Create

func (parent *AppendFSNode) Create(name string, flags uint32, mode uint32, context *fuse.Context) (file nodefs.File, child *nodefs.Inode, code fuse.Status) {
	if parent.Inode().GetChild(name) != nil {
		return nil, nil, fuse.Status(syscall.EEXIST)
	}
	node := CreateNode(parent)
	node.attr.Mode = mode | fuse.S_IFREG
	node.attr.Uid = context.Uid
	node.attr.Gid = context.Gid
	node.name = name
	parent.Inode().NewChild(name, false, node)
	parent.incrementLinks()

	err := node.fs.AppendMetadata(node.AsNodeMetadata())
	if err != nil {
		return nil, nil, fuse.EIO
	}

	f, openStatus := node.Open(flags, context)
	if openStatus != fuse.OK {
		return nil, nil, openStatus
	}
	return f, node.Inode(), fuse.OK
}
开发者ID:e-tothe-ipi,项目名称:appendfs,代码行数:23,代码来源:appendfsnode.go


示例19: Mkdir

func (me *UnionFs) Mkdir(path string, mode uint32, context *fuse.Context) (code fuse.Status) {
	deleted, code := me.isDeleted(path)
	if !code.Ok() {
		return code
	}

	if !deleted {
		r := me.getBranch(path)
		if r.code != fuse.ENOENT {
			return fuse.Status(syscall.EEXIST)
		}
	}

	code = me.promoteDirsTo(path)
	if code.Ok() {
		code = me.fileSystems[0].Mkdir(path, mode, context)
	}
	if code.Ok() {
		me.removeDeletion(path)
		attr := &fuse.Attr{
			Mode: fuse.S_IFDIR | mode,
		}
		me.branchCache.Set(path, branchResult{attr, fuse.OK, 0})
	}

	var stream chan fuse.DirEntry
	stream, code = me.OpenDir(path, context)
	if code.Ok() {
		// This shouldn't happen, but let's be safe.
		for entry := range stream {
			me.putDeletion(filepath.Join(path, entry.Name))
		}
	}

	return code
}
开发者ID:kicool,项目名称:go-fuse,代码行数:36,代码来源:unionfs.go


示例20: Bytes

func (e errorReadResult) Bytes(buf []byte) ([]byte, fuse.Status) {
	return nil, fuse.Status(e)
}
开发者ID:freakmac,项目名称:adbfs,代码行数:3,代码来源:error_read_result.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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