本文整理匯總了Golang中github.com/hanwen/go-fuse/fuse.Status函數的典型用法代碼示例。如果您正苦於以下問題:Golang Status函數的具體用法?Golang Status怎麽用?Golang Status使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Status函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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
}
示例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
}
示例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)
}
示例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
}
示例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
}
示例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)
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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)
}