mirror of
https://github.com/restic/restic.git
synced 2024-12-23 08:16:36 +00:00
Merge pull request #800 from restic/jgfrm-hardlinks-fuse
fuse: correct nlink count for directories
This commit is contained in:
commit
c83e608cce
4 changed files with 26 additions and 0 deletions
|
@ -426,6 +426,11 @@ Don't forget to umount after quitting!
|
|||
|
||||
Mounting repositories via FUSE is not possible on Windows and OpenBSD.
|
||||
|
||||
Restic supports storage and preservation of hard links. However, since hard links
|
||||
exist in the scope of a filesystem by definition, restoring hard links from a fuse
|
||||
mount should be done by a program that preserves hard links. A program that does so
|
||||
is rsync, used with the option --hard-links.
|
||||
|
||||
# Create an SFTP repository
|
||||
|
||||
In order to backup data via SFTP, you must first set up a server with SSH and
|
||||
|
|
|
@ -114,9 +114,25 @@ func (d *dir) Attr(ctx context.Context, a *fuse.Attr) error {
|
|||
a.Atime = d.node.AccessTime
|
||||
a.Ctime = d.node.ChangeTime
|
||||
a.Mtime = d.node.ModTime
|
||||
|
||||
a.Nlink = d.calcNumberOfLinks()
|
||||
|
||||
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) {
|
||||
debug.Log("called")
|
||||
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.Ctime = f.node.ChangeTime
|
||||
a.Mtime = f.node.ModTime
|
||||
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
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.Ctime = l.node.ChangeTime
|
||||
a.Mtime = l.node.ModTime
|
||||
|
||||
a.Nlink = uint32(l.node.Links)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue