Commit 9b950aa9 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

nodefs: use S_IFREG (regular file) as default for NodeAttr

parent 804ff7cc
......@@ -73,6 +73,10 @@ func (b *rawBridge) newInode(ops Operations, id NodeAttr, persistent bool) *Inod
return old
}
id.Mode = id.Mode &^ 07777
if id.Mode == 0 {
id.Mode = fuse.S_IFREG
}
switch id.Mode {
case fuse.S_IFDIR:
_ = ops.(DirOperations)
......
......@@ -71,13 +71,13 @@ func (r *keepCacheRoot) OnAdd() {
keepCache: true,
}
f1.setContent(0)
i.AddChild("keep", i.NewInode(f1, NodeAttr{Mode: fuse.S_IFREG}), true)
i.AddChild("keep", i.NewInode(f1, NodeAttr{}), true)
f2 := &keepCacheFile{
keepCache: false,
}
f2.setContent(0)
i.AddChild("nokeep", i.NewInode(f2, NodeAttr{Mode: fuse.S_IFREG}), true)
i.AddChild("nokeep", i.NewInode(f2, NodeAttr{}), true)
}
func TestKeepCache(t *testing.T) {
......
......@@ -23,7 +23,8 @@ type parentData struct {
// NodeAttr holds immutable attributes of a object in the filesystem.
type NodeAttr struct {
// Each Inode has a type, which does not change over the
// lifetime of the inode, for example fuse.S_IFDIR.
// lifetime of the inode, for example fuse.S_IFDIR. The default (0)
// is interpreted as S_IFREG (regular file).
Mode uint32
// The inode number must be unique among the currently live
......
......@@ -30,9 +30,8 @@ func (r *interruptRoot) Lookup(ctx context.Context, name string, out *fuse.Entry
return nil, fuse.ENOENT
}
ch := InodeOf(r).NewInode(&r.child, NodeAttr{
Mode: fuse.S_IFREG,
Ino: 2,
Gen: 1})
Ino: 2,
Gen: 1})
return ch, fuse.OK
}
......
......@@ -189,7 +189,7 @@ func (zr *zipRoot) OnAdd() {
p = ch
}
ch := InodeOf(zr).NewPersistentInode(&zipFile{file: f}, NodeAttr{Mode: fuse.S_IFREG})
ch := InodeOf(zr).NewPersistentInode(&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