make format

Run "make format" using
go version go1.19.4 linux/amd64
This commit is contained in:
Jakob Unterwurzacher 2022-12-29 15:00:24 +01:00
parent 99cdaa0b69
commit 856ccaac10
13 changed files with 67 additions and 62 deletions

View File

@ -6,10 +6,11 @@ import (
)
// SanitizePath adapts filepath.Clean for FUSE paths.
// 1) Leading slash(es) are dropped
// 2) It returns "" instead of "."
// 3) If the cleaned path points above CWD (start with ".."), an empty string
// is returned
// 1. Leading slash(es) are dropped
// 2. It returns "" instead of "."
// 3. If the cleaned path points above CWD (start with ".."), an empty string
// is returned
//
// See the TestSanitizePath testcases for examples.
func SanitizePath(path string) string {
// (1)

View File

@ -5,7 +5,7 @@
//
// Use like this:
//
// import _ "github.com/rfjakob/gocryptfs/v2/internal/ensurefds012"
// import _ "github.com/rfjakob/gocryptfs/v2/internal/ensurefds012"
//
// The import line MUST be in the alphabitcally first source code file of
// package main!
@ -13,17 +13,17 @@
// You can test if it works as expected by inserting a long sleep into main,
// startings gocryptfs with all fds closed like this,
//
// $ ./gocryptfs 0<&- 1>&- 2>&-
// $ ./gocryptfs 0<&- 1>&- 2>&-
//
// and then checking the open fds. It should look like this:
//
// $ ls -l /proc/$(pgrep gocryptfs)/fd
// total 0
// lrwx------. 1 jakob jakob 64 Jan 5 15:54 0 -> /dev/null
// lrwx------. 1 jakob jakob 64 Jan 5 15:54 1 -> /dev/null
// lrwx------. 1 jakob jakob 64 Jan 5 15:54 2 -> /dev/null
// l-wx------. 1 jakob jakob 64 Jan 5 15:54 3 -> /dev/null
// lrwx------. 1 jakob jakob 64 Jan 5 15:54 4 -> 'anon_inode:[eventpoll]'
// $ ls -l /proc/$(pgrep gocryptfs)/fd
// total 0
// lrwx------. 1 jakob jakob 64 Jan 5 15:54 0 -> /dev/null
// lrwx------. 1 jakob jakob 64 Jan 5 15:54 1 -> /dev/null
// lrwx------. 1 jakob jakob 64 Jan 5 15:54 2 -> /dev/null
// l-wx------. 1 jakob jakob 64 Jan 5 15:54 3 -> /dev/null
// lrwx------. 1 jakob jakob 64 Jan 5 15:54 4 -> 'anon_inode:[eventpoll]'
//
// See https://github.com/rfjakob/gocryptfs/issues/320 for details.
package ensurefds012

View File

@ -30,8 +30,8 @@ var allocateWarnOnce sync.Once
//
// mode=FALLOC_DEFAULT is implemented as a two-step process:
//
// (1) Allocate the space using FALLOC_FL_KEEP_SIZE
// (2) Set the file size using ftruncate (via truncateGrowFile)
// (1) Allocate the space using FALLOC_FL_KEEP_SIZE
// (2) Set the file size using ftruncate (via truncateGrowFile)
//
// This allows us to reuse the file grow mechanics from Truncate as they are
// complicated and hard to get right.

View File

@ -3,8 +3,8 @@
//
// Format of the returned inode numbers:
//
// [spill bit = 0][15 bit namespace id][48 bit passthru inode number]
// [spill bit = 1][63 bit spill inode number ]
// [spill bit = 0][15 bit namespace id][48 bit passthru inode number]
// [spill bit = 1][63 bit spill inode number ]
//
// Each (Dev, Tag) tuple gets a namespace id assigned. The original inode
// number is then passed through in the lower 48 bits.

View File

@ -12,17 +12,17 @@ import (
//
// Examples: On my desktop PC:
//
// $ grep "model name" /proc/cpuinfo
// model name : Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
// $ grep "model name" /proc/cpuinfo
// model name : Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
//
// --> Returns "Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz".
//
// On a Raspberry Pi 4:
//
// $ grep "model name" /proc/cpuinfo
// (empty)
// $ grep Hardware /proc/cpuinfo
// Hardware : BCM2835
// $ grep "model name" /proc/cpuinfo
// (empty)
// $ grep Hardware /proc/cpuinfo
// Hardware : BCM2835
//
// --> Returns "BCM2835"
func cpuModelName() string {

View File

@ -16,13 +16,13 @@
// However, OpenSSL has optimized assembly for almost all platforms, which Go
// does not. Example for a 32-bit ARM device (Odroid XU4):
//
// $ gocrypts -speed
// gocryptfs v2.1-68-gedf9d4c.stupidchacha; go-fuse v2.1.1-0.20210825171523-3ab5d95a30ae; 2021-09-04 go1.16.7 linux/arm
// AES-GCM-256-OpenSSL 56.84 MB/s (selected in auto mode)
// AES-GCM-256-Go 16.61 MB/s
// AES-SIV-512-Go 16.49 MB/s
// XChaCha20-Poly1305-Go 39.08 MB/s (use via -xchacha flag)
// XChaCha20-Poly1305-OpenSSL 141.82 MB/s
// $ gocrypts -speed
// gocryptfs v2.1-68-gedf9d4c.stupidchacha; go-fuse v2.1.1-0.20210825171523-3ab5d95a30ae; 2021-09-04 go1.16.7 linux/arm
// AES-GCM-256-OpenSSL 56.84 MB/s (selected in auto mode)
// AES-GCM-256-Go 16.61 MB/s
// AES-SIV-512-Go 16.49 MB/s
// XChaCha20-Poly1305-Go 39.08 MB/s (use via -xchacha flag)
// XChaCha20-Poly1305-OpenSSL 141.82 MB/s
//
// This package is "stupid" in the sense that it only supports a narrow set of
// key- and iv-lengths, and panics if it does not like what you pass it.
@ -33,7 +33,7 @@
// Corrupt ciphertexts never cause a panic. Instead, ErrAuth is returned on
// decryption.
//
// XChaCha20-Poly1305
// # XChaCha20-Poly1305
//
// The XChaCha20-Poly1305 implementation is more complicated than the others,
// because OpenSSL does not support XChaCha20-Poly1305 directly. Follow
@ -43,16 +43,16 @@
// Fortunately, XChaCha20-Poly1305 is just ChaCha20-Poly1305 with some key+iv
// mixing using HChaCha20 in front:
//
// key (32 bytes), iv (24 bytes)
// |
// v
// HChaCha20 (provided by golang.org/x/crypto/chacha20)
// |
// v
// key2 (32 bytes), iv2 (16 bytes)
// |
// v
// ChaCha20-Poly1305 (OpenSSL EVP_chacha20_poly1305)
// key (32 bytes), iv (24 bytes)
// |
// v
// HChaCha20 (provided by golang.org/x/crypto/chacha20)
// |
// v
// key2 (32 bytes), iv2 (16 bytes)
// |
// v
// ChaCha20-Poly1305 (OpenSSL EVP_chacha20_poly1305)
//
// As HChaCha20 is very fast, XChaCha20-Poly1305 gets almost the same throughput
// as ChaCha20-Poly1305 (for 4kiB blocks).

View File

@ -11,9 +11,9 @@ import (
//
// Go GCM is only faster if the CPU either:
//
// 1) Is X86_64 && has AES instructions && Go is v1.6 or higher
// 2) Is ARM64 && has AES instructions && Go is v1.11 or higher
// (commit https://github.com/golang/go/commit/4f1f503373cda7160392be94e3849b0c9b9ebbda)
// 1. Is X86_64 && has AES instructions && Go is v1.6 or higher
// 2. Is ARM64 && has AES instructions && Go is v1.11 or higher
// (commit https://github.com/golang/go/commit/4f1f503373cda7160392be94e3849b0c9b9ebbda)
//
// See https://github.com/rfjakob/gocryptfs/wiki/CPU-Benchmarks
// for benchmarks.

View File

@ -462,7 +462,9 @@ func TestPasswdPasswordIncorrect(t *testing.T) {
// Check that we correctly background on mount and close stderr and stdout.
// Something like
// gocryptfs a b | cat
//
// gocryptfs a b | cat
//
// must not hang ( https://github.com/rfjakob/gocryptfs/issues/130 ).
func TestMountBackground(t *testing.T) {
dir := test_helpers.InitFS(t)

View File

@ -204,7 +204,9 @@ func TestWrite0200File(t *testing.T) {
// TestMvWarnings:
// When xattr support was introduced, mv threw warnings like these:
// mv: preserving permissions for b/x: Operation not permitted
//
// mv: preserving permissions for b/x: Operation not permitted
//
// because we returned EPERM when it tried to set system.posix_acl_access.
// Now we return EOPNOTSUPP and mv is happy.
func TestMvWarnings(t *testing.T) {

View File

@ -134,7 +134,7 @@ func TestConcurrentReadCreate(t *testing.T) {
//
// So far, it only has triggered warnings like this
//
// go-fuse: warning: Inode.Path: inode i4201033 is orphaned, replacing segment with ".go-fuse.5577006791947779410/deleted"
// go-fuse: warning: Inode.Path: inode i4201033 is orphaned, replacing segment with ".go-fuse.5577006791947779410/deleted"
//
// but none of the "blocked waiting for FORGET".
func TestInoReuse(t *testing.T) {

View File

@ -92,10 +92,10 @@ func TestFiltered(t *testing.T) {
// Only works on filesystems that recycle inode numbers (ext4 does),
// and then the test causes a hang with these messages:
//
// go-fuse: blocked for 5 seconds waiting for FORGET on i4329366
// go-fuse: blocked for 11 seconds waiting for FORGET on i4329366
// go-fuse: blocked for 17 seconds waiting for FORGET on i4329366
// [...]
// go-fuse: blocked for 5 seconds waiting for FORGET on i4329366
// go-fuse: blocked for 11 seconds waiting for FORGET on i4329366
// go-fuse: blocked for 17 seconds waiting for FORGET on i4329366
// [...]
//
// The test runs with -plaintextnames because that makes it easier to manipulate
// cipherdir directly.

View File

@ -35,15 +35,15 @@ func findIno(dir string, ino uint64) string {
// TestVirtualFileIno creates a directory tree like this:
//
// TestVirtualFileIno <---- parent
// └── xxxxxxx[...] <---- child
// TestVirtualFileIno <---- parent
// └── xxxxxxx[...] <---- child
//
// Which looks like this encrypted:
//
// OLUKdPMg6l87EiKVlufgwIkQL8MD6JdUgOR3a8nEZ-w <---- parent
// ├── gocryptfs.diriv <---- diriv
// ├── gocryptfs.longname.e31v1ax4h_F0l4jhlN8kCjaWWMq8rO9VVBZ15IYsV50 <---- child
// └── gocryptfs.longname.e31v1ax4h_F0l4jhlN8kCjaWWMq8rO9VVBZ15IYsV50.name <---- name
// OLUKdPMg6l87EiKVlufgwIkQL8MD6JdUgOR3a8nEZ-w <---- parent
// ├── gocryptfs.diriv <---- diriv
// ├── gocryptfs.longname.e31v1ax4h_F0l4jhlN8kCjaWWMq8rO9VVBZ15IYsV50 <---- child
// └── gocryptfs.longname.e31v1ax4h_F0l4jhlN8kCjaWWMq8rO9VVBZ15IYsV50.name <---- name
//
// It verifies that the inode numbers match what we expect.
func TestVirtualFileIno(t *testing.T) {

View File

@ -67,10 +67,10 @@ func doInit() {
// ResetTmpDir deletes TmpDir, create new dir tree:
//
// TmpDir
// |-- DefaultPlainDir
// *-- DefaultCipherDir
// *-- gocryptfs.diriv
// TmpDir
// |-- DefaultPlainDir
// *-- DefaultCipherDir
// *-- gocryptfs.diriv
func ResetTmpDir(createDirIV bool) {
// Try to unmount and delete everything
entries, err := ioutil.ReadDir(TmpDir)
@ -138,7 +138,7 @@ func isExt4(path string) bool {
// InitFS creates a new empty cipherdir and calls
//
// gocryptfs -q -init -extpass "echo test" -scryptn=10 $extraArgs $cipherdir
// gocryptfs -q -init -extpass "echo test" -scryptn=10 $extraArgs $cipherdir
//
// It returns cipherdir without a trailing slash.
//