summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2021-08-19 08:22:52 +0200
committerJakob Unterwurzacher2021-08-19 08:34:49 +0200
commitf3d927e590c1e9fc3a0ef9402d9c83b972981232 (patch)
tree3140119573746d4e4b1ec2135baedea5b0d0b1ed
parent8ee595dd484919b98bd9908900fbece2585a334d (diff)
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 e6caf56ea4ab10e747aa5dfc0a768cb8176ebe6a Author: Jakob Unterwurzacher <jakobunt@gmail.com> Date: Mon Apr 2 16:56:29 2018 +0200 fsck: sort files alphabetically This makes fsck runs deterministic.
-rw-r--r--fsck.go18
1 files changed, 3 insertions, 15 deletions
diff --git a/fsck.go b/fsck.go
index 1f40514..388071f 100644
--- a/fsck.go
+++ b/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)