From b6c8960b01f9e5366814b0dada57a0b1e6a031d9 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Mon, 2 Apr 2018 18:32:30 +0200 Subject: fsck: clean up log output Make sure we get only 1 warning output per problem. Also, add new corruption types to broken_fs_v1.4. --- internal/contentenc/content.go | 2 +- internal/contentenc/file_header.go | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'internal/contentenc') diff --git a/internal/contentenc/content.go b/internal/contentenc/content.go index c4ba7c9..76b486d 100644 --- a/internal/contentenc/content.go +++ b/internal/contentenc/content.go @@ -186,7 +186,7 @@ func (be *ContentEnc) DecryptBlock(ciphertext []byte, blockNo uint64, fileID []b plaintext, err := be.cryptoCore.AEADCipher.Open(plaintext, nonce, ciphertext, aData) if err != nil { - tlog.Warn.Printf("DecryptBlock: %s, len=%d", err.Error(), len(ciphertextOrig)) + tlog.Debug.Printf("DecryptBlock: %s, len=%d", err.Error(), len(ciphertextOrig)) tlog.Debug.Println(hex.Dump(ciphertextOrig)) if be.forceDecode && err == stupidgcm.ErrAuth { return plaintext, err diff --git a/internal/contentenc/file_header.go b/internal/contentenc/file_header.go index 5e638ff..62d24cb 100644 --- a/internal/contentenc/file_header.go +++ b/internal/contentenc/file_header.go @@ -7,11 +7,10 @@ package contentenc import ( "bytes" "encoding/binary" + "fmt" "log" - "syscall" "github.com/rfjakob/gocryptfs/internal/cryptocore" - "github.com/rfjakob/gocryptfs/internal/tlog" ) const ( @@ -48,19 +47,16 @@ var allZeroFileID = make([]byte, headerIDLen) // ParseHeader - parse "buf" into fileHeader object func ParseHeader(buf []byte) (*FileHeader, error) { if len(buf) != HeaderLen { - tlog.Warn.Printf("ParseHeader: invalid length: want %d bytes, got %d. Returning EINVAL.", HeaderLen, len(buf)) - return nil, syscall.EINVAL + return nil, fmt.Errorf("ParseHeader: invalid length, want=%d have=%d", HeaderLen, len(buf)) } var h FileHeader h.Version = binary.BigEndian.Uint16(buf[0:headerVersionLen]) if h.Version != CurrentVersion { - tlog.Warn.Printf("ParseHeader: invalid version: want %d, got %d. Returning EINVAL.", CurrentVersion, h.Version) - return nil, syscall.EINVAL + return nil, fmt.Errorf("ParseHeader: invalid version, want=%d have=%d", CurrentVersion, h.Version) } h.ID = buf[headerVersionLen:] if bytes.Equal(h.ID, allZeroFileID) { - tlog.Warn.Printf("ParseHeader: file id is all-zero. Returning EINVAL.") - return nil, syscall.EINVAL + return nil, fmt.Errorf("ParseHeader: file id is all-zero") } return &h, nil } -- cgit v1.2.3