Commit d1c9d5a4 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

nodefs: provide Operations.Inode() as fluent interface

parent bece857c
......@@ -35,8 +35,8 @@
// infrastructure needs to lookup children of nodes to process client
// requests. For every new Operations, the filesystem infrastructure
// automatically builds new index node and links it in the filesystem
// tree. InodeOf can be used to get particular Inode associated with
// a Operations.
// tree. Operations.Inode() can be used to get particular Inode
// associated with a Operations.
//
// The kernel can evict inode data to free up memory. It does so by
// issuing FORGET calls. When a node has no children, and no kernel
......@@ -83,6 +83,11 @@ type Operations interface {
inode() *Inode
setInode(*Inode) bool
// Inode() is a convenience method, and is equivalent to
// InodeOf(ops) It is provided by DefaultOperations, and
// should not be reimplemented.
Inode() *Inode
// StatFs implements statistics for the filesystem that holds
// this Inode. DefaultNode implements this, because OSX
// filesystem must have a valid StatFs implementation.
......
......@@ -55,6 +55,11 @@ func (n *DefaultOperations) inode() *Inode {
(*unsafe.Pointer)(unsafe.Pointer(&n.inode_))))
}
// Inode is syntactic sugar for InodeOf(ops).
func (n *DefaultOperations) Inode() *Inode {
return n.inode()
}
// StatFs zeroes the out argument and returns OK. This is because OSX
// filesystems must define this, or the mount will not work.
func (n *DefaultOperations) StatFs(ctx context.Context, out *fuse.StatfsOut) fuse.Status {
......
......@@ -48,13 +48,13 @@ func (n *loopbackNode) renameExchange(name string, newparent *loopbackNode, newN
if err := syscall.Fstat(fd1, &st); err != nil {
return fuse.ToStatus(err)
}
if !InodeOf(n).IsRoot() && InodeOf(n).NodeAttr().Ino != n.rootNode.idFromStat(&st).Ino {
if !n.Inode().IsRoot() && InodeOf(n).NodeAttr().Ino != n.rootNode.idFromStat(&st).Ino {
return fuse.EBUSY
}
if err := syscall.Fstat(fd2, &st); err != nil {
return fuse.ToStatus(err)
}
if !InodeOf(newparent).IsRoot() && InodeOf(newparent).NodeAttr().Ino != n.rootNode.idFromStat(&st).Ino {
if !newparent.Inode().IsRoot() && InodeOf(newparent).NodeAttr().Ino != n.rootNode.idFromStat(&st).Ino {
return fuse.EBUSY
}
......
......@@ -529,7 +529,7 @@ func TestNotifyEntry(t *testing.T) {
t.Fatalf("got after %#v, want %#v", after, st)
}
if code := InodeOf(tc.loopback).NotifyEntry("file"); !code.Ok() {
if code := tc.loopback.Inode().NotifyEntry("file"); !code.Ok() {
t.Errorf("notify failed: %v", code)
}
......
......@@ -182,14 +182,14 @@ func (zr *zipRoot) OnAdd(ctx context.Context) {
}
ch := p.GetChild(component)
if ch == nil {
ch = InodeOf(zr).NewPersistentInode(ctx, &DefaultOperations{},
ch = p.NewPersistentInode(ctx, &DefaultOperations{},
NodeAttr{Mode: fuse.S_IFDIR})
p.AddChild(component, ch, true)
}
p = ch
}
ch := InodeOf(zr).NewPersistentInode(ctx, &zipFile{file: f}, NodeAttr{})
ch := p.NewPersistentInode(ctx, &zipFile{file: f}, NodeAttr{})
p.AddChild(base, ch, true)
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment