Skip to content

Commit

Permalink
Force -noprealloc on Btrfs
Browse files Browse the repository at this point in the history
  • Loading branch information
rfjakob committed Aug 4, 2019
1 parent abb2f1f commit 1305527
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"syscall"
"time"

"golang.org/x/sys/unix"

"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse/nodefs"
"github.com/hanwen/go-fuse/fuse/pathfs"
Expand Down Expand Up @@ -95,6 +97,18 @@ func doMount(args *argContainer) {
}
}()
}
// Preallocation on Btrfs is broken ( https://github.com/rfjakob/gocryptfs/issues/395 )
// and slow ( https://github.com/rfjakob/gocryptfs/issues/63 ).
if !args.noprealloc {
var st unix.Statfs_t
err = unix.Statfs(args.cipherdir, &st)
if err == nil && st.Type == unix.BTRFS_SUPER_MAGIC {
tlog.Info.Printf(tlog.ColorYellow +
"Btrfs detected, forcing -noprealloc. See https://github.com/rfjakob/gocryptfs/issues/395 for why." +
tlog.ColorReset)
args.noprealloc = true
}
}
// We cannot use JSON for pretty-printing as the fields are unexported
tlog.Debug.Printf("cli args: %#v", args)
// Initialize gocryptfs (read config file, ask for password, ...)
Expand Down

0 comments on commit 1305527

Please sign in to comment.