Commit 0f2f00b8 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

rename NodeAttr to StableAttr

parent 4e10c985
......@@ -51,7 +51,7 @@ func (r *StatFS) addFile(name string, a fuse.Attr) {
if ch == nil {
// Create a directory
ch = p.NewPersistentInode(context.Background(), &nodefs.Inode{},
nodefs.NodeAttr{Mode: syscall.S_IFDIR})
nodefs.StableAttr{Mode: syscall.S_IFDIR})
// Add it
p.AddChild(component, ch, true)
}
......@@ -63,7 +63,7 @@ func (r *StatFS) addFile(name string, a fuse.Attr) {
child := p.NewPersistentInode(context.Background(), &nodefs.MemRegularFile{
Data: make([]byte, a.Size),
Attr: a,
}, nodefs.NodeAttr{})
}, nodefs.StableAttr{})
// And add it
p.AddChild(base, child, true)
......
......@@ -27,7 +27,7 @@ func (r *HelloRoot) OnAdd(ctx context.Context) {
Attr: fuse.Attr{
Mode: 0644,
},
}, nodefs.NodeAttr{Ino: 2})
}, nodefs.StableAttr{Ino: 2})
r.AddChild("file.txt", ch, false)
}
......
......@@ -188,7 +188,7 @@ func (n *unionFSNode) Create(ctx context.Context, name string, flags uint32, mod
return nil, nil, 0, err.(syscall.Errno)
}
ch := n.NewInode(ctx, &unionFSNode{}, nodefs.NodeAttr{Mode: st.Mode, Ino: st.Ino})
ch := n.NewInode(ctx, &unionFSNode{}, nodefs.StableAttr{Mode: st.Mode, Ino: st.Ino})
out.FromStat(&st)
return ch, nodefs.NewLoopbackFile(fd), 0, 0
......@@ -238,7 +238,7 @@ func (n *unionFSNode) Lookup(ctx context.Context, name string, out *fuse.EntryOu
idx := n.root().getBranch(p, &st)
if idx >= 0 {
// XXX use idx in Ino?
ch := n.NewInode(ctx, &unionFSNode{}, nodefs.NodeAttr{Mode: st.Mode, Ino: st.Ino})
ch := n.NewInode(ctx, &unionFSNode{}, nodefs.StableAttr{Mode: st.Mode, Ino: st.Ino})
out.FromStat(&st)
out.Mode |= 0111
return ch, 0
......@@ -276,7 +276,7 @@ func (n *unionFSNode) Symlink(ctx context.Context, target, name string, out *fus
out.FromStat(&st)
ch := n.NewInode(ctx, &unionFSNode{}, nodefs.NodeAttr{
ch := n.NewInode(ctx, &unionFSNode{}, nodefs.StableAttr{
Mode: syscall.S_IFLNK,
Ino: st.Ino,
})
......
......@@ -40,7 +40,7 @@
//
// func (n *myNode) Lookup(ctx context.Context, name string, ... ) (*Inode, syscall.Errno) {
// child := myNode{}
// return n.NewInode(ctx, &myNode{}, NodeAttr{Mode: syscall.S_IFDIR}), 0
// return n.NewInode(ctx, &myNode{}, StableAttr{Mode: syscall.S_IFDIR}), 0
// }
//
// On mounting, the root InodeEmbedder is associated with root of the
......
......@@ -51,7 +51,7 @@ type rawBridge struct {
}
// newInode creates creates new inode pointing to ops.
func (b *rawBridge) newInodeUnlocked(ops InodeEmbedder, id NodeAttr, persistent bool) *Inode {
func (b *rawBridge) newInodeUnlocked(ops InodeEmbedder, id StableAttr, persistent bool) *Inode {
b.mu.Lock()
defer b.mu.Unlock()
......@@ -84,7 +84,7 @@ func (b *rawBridge) newInodeUnlocked(ops InodeEmbedder, id NodeAttr, persistent
// file
//
// dir1.Lookup("file") and dir2.Lookup("file") are executed
// simultaneously. The matching NodeAttrs ensure that we return the
// simultaneously. The matching StableAttrs ensure that we return the
// same node.
old := b.nodes[id.Ino]
if old != nil {
......@@ -101,7 +101,7 @@ func (b *rawBridge) newInodeUnlocked(ops InodeEmbedder, id NodeAttr, persistent
return ops.embed()
}
func (b *rawBridge) newInode(ctx context.Context, ops InodeEmbedder, id NodeAttr, persistent bool) *Inode {
func (b *rawBridge) newInode(ctx context.Context, ops InodeEmbedder, id StableAttr, persistent bool) *Inode {
ch := b.newInodeUnlocked(ops, id, persistent)
if ch != ops.embed() {
return ch
......@@ -183,7 +183,7 @@ func NewNodeFS(root InodeEmbedder, opts *Options) fuse.RawFileSystem {
}
initInode(root.embed(), root,
NodeAttr{
StableAttr{
Ino: 1,
Mode: fuse.S_IFDIR,
},
......@@ -792,7 +792,7 @@ func (b *rawBridge) getStream(ctx context.Context, inode *Inode) (DirStream, sys
for k, ch := range inode.Children() {
r = append(r, fuse.DirEntry{Mode: ch.Mode(),
Name: k,
Ino: ch.NodeAttr().Ino})
Ino: ch.StableAttr().Ino})
}
return NewListDirStream(r), 0
}
......
......@@ -78,13 +78,13 @@ func (r *keepCacheRoot) OnAdd(ctx context.Context) {
keepCache: true,
}
r.keep.setContent(0)
i.AddChild("keep", i.NewInode(ctx, r.keep, NodeAttr{}), true)
i.AddChild("keep", i.NewInode(ctx, r.keep, StableAttr{}), true)
r.nokeep = &keepCacheFile{
keepCache: false,
}
r.nokeep.setContent(0)
i.AddChild("nokeep", i.NewInode(ctx, r.nokeep, NodeAttr{}), true)
i.AddChild("nokeep", i.NewInode(ctx, r.nokeep, StableAttr{}), true)
}
// Test FOPEN_KEEP_CACHE. This is a little subtle: the automatic cache
......
......@@ -20,7 +20,7 @@ type dioRoot struct {
}
func (r *dioRoot) OnAdd(ctx context.Context) {
r.Inode.AddChild("file", r.Inode.NewInode(ctx, &dioFile{}, NodeAttr{}), false)
r.Inode.AddChild("file", r.Inode.NewInode(ctx, &dioFile{}, StableAttr{}), false)
}
// A file handle that pretends that every hole/data starts at
......
......@@ -22,8 +22,8 @@ type parentData struct {
parent *Inode
}
// NodeAttr holds immutable attributes of a object in the filesystem.
type NodeAttr struct {
// StableAttr holds immutable attributes of a object in the filesystem.
type StableAttr struct {
// Each Inode has a type, which does not change over the
// lifetime of the inode, for example fuse.S_IFDIR. The default (0)
// is interpreted as S_IFREG (regular file).
......@@ -43,8 +43,8 @@ type NodeAttr struct {
Gen uint64
}
// Reserved returns if the NodeAttr is using reserved Inode numbers.
func (i *NodeAttr) Reserved() bool {
// Reserved returns if the StableAttr is using reserved Inode numbers.
func (i *StableAttr) Reserved() bool {
return i.Ino == 1 || i.Ino == ^uint64(0)
}
......@@ -57,7 +57,7 @@ func (i *NodeAttr) Reserved() bool {
// copied. Inodes should be obtained by calling Inode.NewInode() or
// Inode.NewPersistentInode().
type Inode struct {
nodeAttr NodeAttr
nodeAttr StableAttr
ops InodeEmbedder
bridge *rawBridge
......@@ -108,7 +108,7 @@ func (n *Inode) EmbeddedInode() *Inode {
return n
}
func initInode(n *Inode, ops InodeEmbedder, attr NodeAttr, bridge *rawBridge, persistent bool) {
func initInode(n *Inode, ops InodeEmbedder, attr StableAttr, bridge *rawBridge, persistent bool) {
n.ops = ops
n.nodeAttr = attr
n.bridge = bridge
......@@ -126,8 +126,8 @@ func (n *Inode) setEntryOut(out *fuse.EntryOut) {
out.Mode = (out.Attr.Mode & 07777) | n.nodeAttr.Mode
}
// NodeAttr returns the (Ino, Gen) tuple for this node.
func (n *Inode) NodeAttr() NodeAttr {
// StableAttr returns the (Ino, Gen) tuple for this node.
func (n *Inode) StableAttr() NodeAttr {
return n.nodeAttr
}
......@@ -311,7 +311,7 @@ func (iparent *Inode) setEntry(name string, ichild *Inode) {
// NewPersistentInode returns an Inode whose lifetime is not in
// control of the kernel.
func (n *Inode) NewPersistentInode(ctx context.Context, node InodeEmbedder, id NodeAttr) *Inode {
func (n *Inode) NewPersistentInode(ctx context.Context, node InodeEmbedder, id StableAttr) *Inode {
return n.newInode(ctx, node, id, true)
}
......@@ -327,11 +327,11 @@ func (n *Inode) ForgetPersistent() {
// id.Ino argument is used to implement hard-links. If it is given,
// and another node with the same ID is known, that will node will be
// returned, and the passed-in `node` is ignored.
func (n *Inode) NewInode(ctx context.Context, node InodeEmbedder, id NodeAttr) *Inode {
func (n *Inode) NewInode(ctx context.Context, node InodeEmbedder, id StableAttr) *Inode {
return n.newInode(ctx, node, id, false)
}
func (n *Inode) newInode(ctx context.Context, ops InodeEmbedder, id NodeAttr, persistent bool) *Inode {
func (n *Inode) newInode(ctx context.Context, ops InodeEmbedder, id StableAttr, persistent bool) *Inode {
return n.bridge.newInode(ctx, ops, id, persistent)
}
......
......@@ -25,7 +25,7 @@ func (r *interruptRoot) Lookup(ctx context.Context, name string, out *fuse.Entry
if name != "file" {
return nil, syscall.ENOENT
}
ch := r.Inode.NewInode(ctx, &r.child, NodeAttr{
ch := r.Inode.NewInode(ctx, &r.child, StableAttr{
Ino: 2,
Gen: 1})
......
......@@ -162,7 +162,7 @@ func (n *loopbackNode) Rename(ctx context.Context, name string, newParent InodeE
return ToErrno(err)
}
func (r *loopbackRoot) idFromStat(st *syscall.Stat_t) NodeAttr {
func (r *loopbackRoot) idFromStat(st *syscall.Stat_t) StableAttr {
// We compose an inode number by the underlying inode, and
// mixing in the device number. In traditional filesystems,
// the inode numbers are small. The device numbers are also
......@@ -172,7 +172,7 @@ func (r *loopbackRoot) idFromStat(st *syscall.Stat_t) NodeAttr {
// the underlying filesystem
swapped := (uint64(st.Dev) << 32) | (uint64(st.Dev) >> 32)
swappedRootDev := (r.rootDev << 32) | (r.rootDev >> 32)
return NodeAttr{
return StableAttr{
Mode: uint32(st.Mode),
Gen: 1,
// This should work well for traditional backing FSes,
......
......@@ -52,7 +52,7 @@ func (n *loopbackNode) renameExchange(name string, newparent *loopbackNode, newN
// Double check that nodes didn't change from under us.
inode := &n.Inode
if inode.Root() != inode && inode.NodeAttr().Ino != n.root().idFromStat(&st).Ino {
if inode.Root() != inode && inode.StableAttr().Ino != n.root().idFromStat(&st).Ino {
return syscall.EBUSY
}
if err := syscall.Fstat(fd2, &st); err != nil {
......@@ -60,7 +60,7 @@ func (n *loopbackNode) renameExchange(name string, newparent *loopbackNode, newN
}
newinode := &newparent.Inode
if newinode.Root() != newinode && newinode.NodeAttr().Ino != n.root().idFromStat(&st).Ino {
if newinode.Root() != newinode && newinode.StableAttr().Ino != n.root().idFromStat(&st).Ino {
return syscall.EBUSY
}
......
......@@ -53,7 +53,7 @@ func TestDataFile(t *testing.T) {
Mode: 0464,
},
},
NodeAttr{})
StableAttr{})
n.AddChild("file", ch, false)
},
})
......@@ -106,7 +106,7 @@ func TestDataFileLargeRead(t *testing.T) {
Mode: 0464,
},
},
NodeAttr{})
StableAttr{})
n.AddChild("file", ch, false)
},
})
......@@ -130,7 +130,7 @@ func (s *SymlinkerRoot) Symlink(ctx context.Context, target, name string, out *f
Data: []byte(target),
}
ch := s.NewPersistentInode(ctx, l, NodeAttr{Mode: syscall.S_IFLNK})
ch := s.NewPersistentInode(ctx, l, StableAttr{Mode: syscall.S_IFLNK})
return ch, 0
}
......
......@@ -31,8 +31,8 @@ func TestDefaultPermissions(t *testing.T) {
mntDir, _, clean := testMount(t, root, &Options{
DefaultPermissions: true,
OnAdd: func(ctx context.Context) {
dir := root.NewPersistentInode(ctx, &Inode{}, NodeAttr{Mode: syscall.S_IFDIR})
file := root.NewPersistentInode(ctx, &Inode{}, NodeAttr{Mode: syscall.S_IFREG})
dir := root.NewPersistentInode(ctx, &Inode{}, StableAttr{Mode: syscall.S_IFDIR})
file := root.NewPersistentInode(ctx, &Inode{}, StableAttr{Mode: syscall.S_IFREG})
root.AddChild("dir", dir, false)
root.AddChild("file", file, false)
......
......@@ -107,7 +107,7 @@ func TestZipFSOnAdd(t *testing.T) {
mnt, _, clean := testMount(t, root, &Options{
OnAdd: func(ctx context.Context) {
root.AddChild("sub",
root.NewPersistentInode(ctx, zr, NodeAttr{Mode: syscall.S_IFDIR}), false)
root.NewPersistentInode(ctx, zr, StableAttr{Mode: syscall.S_IFDIR}), false)
},
})
defer clean()
......@@ -197,13 +197,13 @@ func (zr *zipRoot) OnAdd(ctx context.Context) {
ch := p.GetChild(component)
if ch == nil {
ch = p.NewPersistentInode(ctx, &Inode{},
NodeAttr{Mode: fuse.S_IFDIR})
StableAttr{Mode: fuse.S_IFDIR})
p.AddChild(component, ch, true)
}
p = ch
}
ch := p.NewPersistentInode(ctx, &zipFile{file: f}, NodeAttr{})
ch := p.NewPersistentInode(ctx, &zipFile{file: f}, StableAttr{})
p.AddChild(base, ch, true)
}
}
......@@ -235,7 +235,7 @@ func ExampleInode_NewPersistentInode() {
if ch == nil {
// Create a directory
ch = p.NewPersistentInode(ctx, &Inode{},
NodeAttr{Mode: syscall.S_IFDIR})
StableAttr{Mode: syscall.S_IFDIR})
// Add it
p.AddChild(component, ch, true)
}
......@@ -246,7 +246,7 @@ func ExampleInode_NewPersistentInode() {
// Create the file
child := p.NewPersistentInode(ctx, &MemRegularFile{
Data: []byte(content),
}, NodeAttr{})
}, StableAttr{})
// And add it
p.AddChild(base, child, true)
......
......@@ -29,7 +29,7 @@ type MultiZipFs struct {
}
func (fs *MultiZipFs) OnAdd(ctx context.Context) {
n := fs.NewPersistentInode(ctx, &configRoot{}, nodefs.NodeAttr{Mode: syscall.S_IFDIR})
n := fs.NewPersistentInode(ctx, &configRoot{}, nodefs.StableAttr{Mode: syscall.S_IFDIR})
fs.AddChild("config", n, false)
}
......@@ -72,12 +72,12 @@ func (r *configRoot) Symlink(ctx context.Context, target string, base string, ou
}
_, parent := r.Parent()
ch := r.NewPersistentInode(ctx, root, nodefs.NodeAttr{Mode: syscall.S_IFDIR})
ch := r.NewPersistentInode(ctx, root, nodefs.StableAttr{Mode: syscall.S_IFDIR})
parent.AddChild(base, ch, false)
link := r.NewPersistentInode(ctx, &nodefs.MemSymlink{
Data: []byte(target),
}, nodefs.NodeAttr{Mode: syscall.S_IFLNK})
}, nodefs.StableAttr{Mode: syscall.S_IFLNK})
r.AddChild(base, link, false)
return link, 0
}
......@@ -78,7 +78,7 @@ func (r *tarRoot) OnAdd(ctx context.Context) {
if ch == nil {
ch = p.NewPersistentInode(ctx,
&nodefs.Inode{},
nodefs.NodeAttr{Mode: syscall.S_IFDIR})
nodefs.StableAttr{Mode: syscall.S_IFDIR})
p.AddChild(comp, ch, false)
}
p = ch
......@@ -92,7 +92,7 @@ func (r *tarRoot) OnAdd(ctx context.Context) {
Data: []byte(hdr.Linkname),
}
l.Attr = attr
p.AddChild(base, r.NewPersistentInode(ctx, l, nodefs.NodeAttr{Mode: syscall.S_IFLNK}), false)
p.AddChild(base, r.NewPersistentInode(ctx, l, nodefs.StableAttr{Mode: syscall.S_IFLNK}), false)
case tar.TypeLink:
log.Println("don't know how to handle Typelink")
......@@ -100,25 +100,25 @@ func (r *tarRoot) OnAdd(ctx context.Context) {
case tar.TypeChar:
rf := &nodefs.MemRegularFile{}
rf.Attr = attr
p.AddChild(base, r.NewPersistentInode(ctx, rf, nodefs.NodeAttr{Mode: syscall.S_IFCHR}), false)
p.AddChild(base, r.NewPersistentInode(ctx, rf, nodefs.StableAttr{Mode: syscall.S_IFCHR}), false)
case tar.TypeBlock:
rf := &nodefs.MemRegularFile{}
rf.Attr = attr
p.AddChild(base, r.NewPersistentInode(ctx, rf, nodefs.NodeAttr{Mode: syscall.S_IFBLK}), false)
p.AddChild(base, r.NewPersistentInode(ctx, rf, nodefs.StableAttr{Mode: syscall.S_IFBLK}), false)
case tar.TypeDir:
rf := &nodefs.MemRegularFile{}
rf.Attr = attr
p.AddChild(base, r.NewPersistentInode(ctx, rf, nodefs.NodeAttr{Mode: syscall.S_IFDIR}), false)
p.AddChild(base, r.NewPersistentInode(ctx, rf, nodefs.StableAttr{Mode: syscall.S_IFDIR}), false)
case tar.TypeFifo:
rf := &nodefs.MemRegularFile{}
rf.Attr = attr
p.AddChild(base, r.NewPersistentInode(ctx, rf, nodefs.NodeAttr{Mode: syscall.S_IFIFO}), false)
p.AddChild(base, r.NewPersistentInode(ctx, rf, nodefs.StableAttr{Mode: syscall.S_IFIFO}), false)
case tar.TypeReg, tar.TypeRegA:
df := &nodefs.MemRegularFile{
Data: buf.Bytes(),
}
df.Attr = attr
p.AddChild(base, r.NewPersistentInode(ctx, df, nodefs.NodeAttr{}), false)
p.AddChild(base, r.NewPersistentInode(ctx, df, nodefs.StableAttr{}), false)
default:
log.Printf("entry %q: unsupported type '%c'", hdr.Name, hdr.Typeflag)
}
......
......@@ -66,13 +66,13 @@ func (zr *zipRoot) OnAdd(ctx context.Context) {
ch := p.GetChild(component)
if ch == nil {
ch = p.NewPersistentInode(ctx, &nodefs.Inode{},
nodefs.NodeAttr{Mode: fuse.S_IFDIR})
nodefs.StableAttr{Mode: fuse.S_IFDIR})
p.AddChild(component, ch, true)
}
p = ch
}
ch := p.NewPersistentInode(ctx, &zipFile{file: f}, nodefs.NodeAttr{})
ch := p.NewPersistentInode(ctx, &zipFile{file: f}, nodefs.StableAttr{})
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