fsck: sort files alphabetically again
This makes fsck runs deterministic again.
Sorting (commit quoted below) got lost while
moving to go-fuse v2 api.
commit e6caf56ea4
Author: Jakob Unterwurzacher <jakobunt@gmail.com>
Date: Mon Apr 2 16:56:29 2018 +0200
fsck: sort files alphabetically
This makes fsck runs deterministic.
This commit is contained in:
parent
8ee595dd48
commit
f3d927e590
18
fsck.go
18
fsck.go
@ -8,7 +8,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sort"
|
||||
"sync"
|
||||
"syscall"
|
||||
|
||||
@ -96,6 +96,8 @@ func (ck *fsckObj) dir(relPath string) {
|
||||
ck.markCorrupt(relPath)
|
||||
return
|
||||
}
|
||||
// Sort alphabetically to make fsck runs deterministic
|
||||
sort.Strings(entries)
|
||||
for _, entry := range entries {
|
||||
if ck.abort {
|
||||
return
|
||||
@ -321,20 +323,6 @@ func fsck(args *argContainer) (exitcode int) {
|
||||
return exitcodes.FsckErrors
|
||||
}
|
||||
|
||||
type sortableDirEntries []fuse.DirEntry
|
||||
|
||||
func (s sortableDirEntries) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
func (s sortableDirEntries) Swap(i, j int) {
|
||||
s[i], s[j] = s[j], s[i]
|
||||
}
|
||||
|
||||
func (s sortableDirEntries) Less(i, j int) bool {
|
||||
return strings.Compare(s[i].Name, s[j].Name) < 0
|
||||
}
|
||||
|
||||
func inum(f *os.File) uint64 {
|
||||
var st syscall.Stat_t
|
||||
err := syscall.Fstat(int(f.Fd()), &st)
|
||||
|
Loading…
Reference in New Issue
Block a user