Correct hardlinks for fuse directories
This commit is contained in:
parent
05cae4911d
commit
3047702ded
3 changed files with 21 additions and 0 deletions
|
@ -114,9 +114,25 @@ func (d *dir) Attr(ctx context.Context, a *fuse.Attr) error {
|
||||||
a.Atime = d.node.AccessTime
|
a.Atime = d.node.AccessTime
|
||||||
a.Ctime = d.node.ChangeTime
|
a.Ctime = d.node.ChangeTime
|
||||||
a.Mtime = d.node.ModTime
|
a.Mtime = d.node.ModTime
|
||||||
|
|
||||||
|
a.Nlink = d.calcNumberOfLinks()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *dir) calcNumberOfLinks() uint32 {
|
||||||
|
// a directory d has 2 hardlinks + the number
|
||||||
|
// of directories contained by d
|
||||||
|
var count uint32
|
||||||
|
count = 2
|
||||||
|
for _, node := range d.items {
|
||||||
|
if node.Type == "dir" {
|
||||||
|
count++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
func (d *dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
func (d *dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
||||||
debug.Log("called")
|
debug.Log("called")
|
||||||
ret := make([]fuse.Dirent, 0, len(d.items))
|
ret := make([]fuse.Dirent, 0, len(d.items))
|
||||||
|
|
|
@ -83,7 +83,9 @@ func (f *file) Attr(ctx context.Context, a *fuse.Attr) error {
|
||||||
a.Atime = f.node.AccessTime
|
a.Atime = f.node.AccessTime
|
||||||
a.Ctime = f.node.ChangeTime
|
a.Ctime = f.node.ChangeTime
|
||||||
a.Mtime = f.node.ModTime
|
a.Mtime = f.node.ModTime
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *file) getBlobAt(i int) (blob []byte, err error) {
|
func (f *file) getBlobAt(i int) (blob []byte, err error) {
|
||||||
|
|
|
@ -38,5 +38,8 @@ func (l *link) Attr(ctx context.Context, a *fuse.Attr) error {
|
||||||
a.Atime = l.node.AccessTime
|
a.Atime = l.node.AccessTime
|
||||||
a.Ctime = l.node.ChangeTime
|
a.Ctime = l.node.ChangeTime
|
||||||
a.Mtime = l.node.ModTime
|
a.Mtime = l.node.ModTime
|
||||||
|
|
||||||
|
a.Nlink = uint32(l.node.Links)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue