fuse: show correct uid and gid

This commit is contained in:
Alexander Neumann 2015-07-21 22:11:30 +02:00
parent 05e2afba0b
commit bdcb2175c5
3 changed files with 28 additions and 2 deletions

View file

@ -19,6 +19,7 @@ type dir struct {
repo *repository.Repository
items map[string]*restic.Node
inode uint64
node *restic.Node
}
func newDir(repo *repository.Repository, node *restic.Node) (*dir, error) {
@ -33,6 +34,7 @@ func newDir(repo *repository.Repository, node *restic.Node) (*dir, error) {
return &dir{
repo: repo,
node: node,
items: items,
inode: node.Inode,
}, nil
@ -49,7 +51,15 @@ func newDirFromSnapshot(repo *repository.Repository, snapshot SnapshotWithId) (*
}
return &dir{
repo: repo,
repo: repo,
node: &restic.Node{
UID: uint32(os.Getuid()),
GID: uint32(os.Getgid()),
AccessTime: snapshot.Time,
ModTime: snapshot.Time,
ChangeTime: snapshot.Time,
Mode: os.ModeDir | 0555,
},
items: items,
inode: inodeFromBackendId(snapshot.ID),
}, nil
@ -57,7 +67,13 @@ func newDirFromSnapshot(repo *repository.Repository, snapshot SnapshotWithId) (*
func (d *dir) Attr(ctx context.Context, a *fuse.Attr) error {
a.Inode = d.inode
a.Mode = os.ModeDir | 0555
a.Mode = os.ModeDir | d.node.Mode
a.Uid = d.node.UID
a.Gid = d.node.GID
a.Atime = d.node.AccessTime
a.Ctime = d.node.ChangeTime
a.Mtime = d.node.ModTime
return nil
}

View file

@ -62,6 +62,11 @@ func (f *file) Attr(ctx context.Context, a *fuse.Attr) error {
a.Inode = f.node.Inode
a.Mode = f.node.Mode
a.Size = f.node.Size
a.Uid = f.node.UID
a.Gid = f.node.GID
a.Atime = f.node.AccessTime
a.Ctime = f.node.ChangeTime
a.Mtime = f.node.ModTime
return nil
}

View file

@ -26,5 +26,10 @@ 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
a.Atime = l.node.AccessTime
a.Ctime = l.node.ChangeTime
a.Mtime = l.node.ModTime
return nil
}