Add option to use root as owner of files/dirs

This commit is contained in:
Alexander Neumann
2015-07-26 20:41:29 +02:00
parent bdcb2175c5
commit dde0fd8421
6 changed files with 59 additions and 36 deletions

View File

@@ -12,11 +12,12 @@ import (
var _ = fs.NodeReadlinker(&link{})
type link struct {
node *restic.Node
node *restic.Node
ownerIsRoot bool
}
func newLink(repo *repository.Repository, node *restic.Node) (*link, error) {
return &link{node: node}, nil
func newLink(repo *repository.Repository, node *restic.Node, ownerIsRoot bool) (*link, error) {
return &link{node: node, ownerIsRoot: ownerIsRoot}, nil
}
func (l *link) Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (string, error) {
@@ -26,8 +27,11 @@ func (l *link) Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (string,
func (l *link) Attr(ctx context.Context, a *fuse.Attr) error {
a.Inode = l.node.Inode
a.Mode = l.node.Mode
a.Uid = l.node.UID
a.Gid = l.node.GID
if !l.ownerIsRoot {
a.Uid = l.node.UID
a.Gid = l.node.GID
}
a.Atime = l.node.AccessTime
a.Ctime = l.node.ChangeTime
a.Mtime = l.node.ModTime