aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-10-17 23:03:58 +0200
committerJakob Unterwurzacher2020-10-17 23:03:58 +0200
commit95ea7383f9aeef83e6ce7a06d49d0f24857ef30a (patch)
tree2b2f59ef3bc916374cae050cd57d8f910663e3b8
parent83a324a46bec3332c078abc3a1986969c0f94fd2 (diff)
fsck: make sure we unmount in all cases
-rw-r--r--fsck.go8
-rw-r--r--main.go4
2 files changed, 6 insertions, 6 deletions
diff --git a/fsck.go b/fsck.go
index 6d9ca4a..5b32a5e 100644
--- a/fsck.go
+++ b/fsck.go
@@ -253,7 +253,7 @@ func (ck *fsckObj) xattrs(relPath string) {
}
}
-func fsck(args *argContainer) {
+func fsck(args *argContainer) (exitcode int) {
if args.reverse {
tlog.Fatal.Printf("Running -fsck with -reverse is not supported")
os.Exit(exitcodes.Usage)
@@ -296,17 +296,17 @@ func fsck(args *argContainer) {
wipeKeys()
if ck.abort {
tlog.Info.Printf("fsck: aborted")
- return
+ return exitcodes.Other
}
if len(ck.corruptList) == 0 && len(ck.skippedList) == 0 {
tlog.Info.Printf("fsck summary: no problems found\n")
- return
+ return 0
}
if len(ck.skippedList) > 0 {
tlog.Warn.Printf("fsck: re-run this program as root to check all files!\n")
}
fmt.Printf("fsck summary: %d corrupt files, %d files skipped\n", len(ck.corruptList), len(ck.skippedList))
- os.Exit(exitcodes.FsckErrors)
+ return exitcodes.FsckErrors
}
type sortableDirEntries []fuse.DirEntry
diff --git a/main.go b/main.go
index 61dffb2..edd61ff 100644
--- a/main.go
+++ b/main.go
@@ -329,7 +329,7 @@ func main() {
}
// "-fsck"
if args.fsck {
- fsck(&args)
- os.Exit(0)
+ code := fsck(&args)
+ os.Exit(code)
}
}