Skip to content

Commit

Permalink
reverse: fix force_owner
Browse files Browse the repository at this point in the history
Fixes #809
  • Loading branch information
rfjakob committed Aug 23, 2024
1 parent 1db3808 commit f665be1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions internal/fusefrontend_reverse/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ func (n *Node) Lookup(ctx context.Context, cName string, out *fuse.EntryOut) (ch
n.translateSize(d.dirfd, cName, d.pName, &out.Attr)
}

if rn.args.ForceOwner != nil {
out.Owner = *rn.args.ForceOwner
}

// Usually we always create a new Node ID by always incrementing the generation
// number.
//
Expand Down
3 changes: 3 additions & 0 deletions internal/fusefrontend_reverse/node_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ func (n *Node) lookupConf(ctx context.Context, out *fuse.EntryOut) (ch *fs.Inode
// Get unique inode number
rn.inoMap.TranslateStat(&st)
out.Attr.FromStat(&st)
if rn.args.ForceOwner != nil {
out.Owner = *rn.args.ForceOwner
}
// Create child node
id := rn.uniqueStableAttr(uint32(st.Mode), st.Ino)
node := &VirtualConfNode{path: p}
Expand Down
9 changes: 9 additions & 0 deletions internal/fusefrontend_reverse/virtualconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ type VirtualConfNode struct {
path string
}

// rootNode returns the Root Node of the filesystem.
func (n *VirtualConfNode) rootNode() *RootNode {
return n.Root().Operations().(*RootNode)
}

func (n *VirtualConfNode) Open(ctx context.Context, flags uint32) (fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno) {
fd, err := syscall.Open(n.path, syscall.O_RDONLY, 0)
if err != nil {
Expand All @@ -35,6 +40,10 @@ func (n *VirtualConfNode) Getattr(ctx context.Context, fh fs.FileHandle, out *fu
return fs.ToErrno(err)
}
out.FromStat(&st)
rn := n.rootNode()
if rn.args.ForceOwner != nil {
out.Owner = *rn.args.ForceOwner
}
return 0
}

Expand Down
4 changes: 3 additions & 1 deletion internal/fusefrontend_reverse/virtualnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ func (n *Node) newVirtualMemNode(content []byte, parentStat *syscall.Stat_t, ino
st.Nlink = 1
var a fuse.Attr
a.FromStat(st)

if rn.args.ForceOwner != nil {
a.Owner = *rn.args.ForceOwner
}
vf = &VirtualMemNode{content: content, attr: a}
return
}
Expand Down

0 comments on commit f665be1

Please sign in to comment.