aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-04-29 14:50:58 +0200
committerJakob Unterwurzacher2017-04-29 14:50:58 +0200
commitedb3e19cb5543c580261052395d461fa47c7cf58 (patch)
tree293271bda453e8120fe271d2d146a73d852b90ca
parent7d38f80a78644c8ec4900cc990bfb894387112ed (diff)
fix golint complaints
-rwxr-xr-xgolint.bash3
-rw-r--r--internal/cryptocore/cryptocore.go2
-rw-r--r--internal/exitcodes/exitcodes.go5
-rw-r--r--internal/fusefrontend/file_allocate_truncate.go8
-rw-r--r--internal/fusefrontend/fs.go2
-rw-r--r--internal/fusefrontend_reverse/rfs.go8
-rw-r--r--internal/serialize_reads/sr.go20
-rw-r--r--internal/siv_aead/siv_aead.go4
-rw-r--r--internal/speed/speed.go1
9 files changed, 31 insertions, 22 deletions
diff --git a/golint.bash b/golint.bash
index 4ab0e8c..6da72c8 100755
--- a/golint.bash
+++ b/golint.bash
@@ -3,4 +3,5 @@
golint ./... | \
grep -v "don't use an underscore in package name" | \
grep -v "don't use ALL_CAPS in Go names; use CamelCase" |
- grep -v "struct field allow_other should be allowOther"
+ grep -v "struct field allow_other should be allowOther" |
+ grep -v "struct field serialize_reads should be serializeReads"
diff --git a/internal/cryptocore/cryptocore.go b/internal/cryptocore/cryptocore.go
index 2c352c2..2e02c3a 100644
--- a/internal/cryptocore/cryptocore.go
+++ b/internal/cryptocore/cryptocore.go
@@ -15,7 +15,7 @@ import (
"github.com/rfjakob/gocryptfs/internal/stupidgcm"
)
-// BackendTypeEnum indicates the type of AEAD backend in use.
+// AEADTypeEnum indicates the type of AEAD backend in use.
type AEADTypeEnum int
const (
diff --git a/internal/exitcodes/exitcodes.go b/internal/exitcodes/exitcodes.go
index 908e714..ae00118 100644
--- a/internal/exitcodes/exitcodes.go
+++ b/internal/exitcodes/exitcodes.go
@@ -10,12 +10,13 @@ import (
const (
// Other error - please inspect the message
Other = 11
- // The password was incorrect
+ // PasswordIncorrect - the password was incorrect
PasswordIncorrect = 12
// TODO several other exit codes are defined in main.go. These will be
// ported over here.
)
+// Err wraps and error with an associated numeric exit code
type Err struct {
error
code int
@@ -29,6 +30,8 @@ func NewErr(msg string, code int) Err {
}
}
+// Exit extracts the numeric exit code from "err" (if available) and exits the
+// application.
func Exit(err error) {
err2, ok := err.(Err)
if !ok {
diff --git a/internal/fusefrontend/file_allocate_truncate.go b/internal/fusefrontend/file_allocate_truncate.go
index 0e12981..ae3dd41 100644
--- a/internal/fusefrontend/file_allocate_truncate.go
+++ b/internal/fusefrontend/file_allocate_truncate.go
@@ -187,13 +187,13 @@ func (f *file) truncateGrowFile(oldPlainSz uint64, newPlainSz uint64) fuse.Statu
if oldPlainSz > 0 {
n1 = f.contentEnc.PlainOffToBlockNo(oldPlainSz - 1)
}
- newEofOffset := newPlainSz - 1
- n2 := f.contentEnc.PlainOffToBlockNo(newEofOffset)
+ newEOFOffset := newPlainSz - 1
+ n2 := f.contentEnc.PlainOffToBlockNo(newEOFOffset)
// The file is grown within one block, no need to pad anything.
// Write a single zero to the last byte and let doWrite figure out the RMW.
if n1 == n2 {
buf := make([]byte, 1)
- _, status := f.doWrite(buf, int64(newEofOffset))
+ _, status := f.doWrite(buf, int64(newEOFOffset))
return status
}
// The truncate creates at least one new block.
@@ -224,6 +224,6 @@ func (f *file) truncateGrowFile(oldPlainSz uint64, newPlainSz uint64) fuse.Statu
// The new size is NOT aligned, so we need to write a partial block.
// Write a single zero to the last byte and let doWrite figure it out.
buf := make([]byte, 1)
- _, status := f.doWrite(buf, int64(newEofOffset))
+ _, status := f.doWrite(buf, int64(newEOFOffset))
return status
}
diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go
index 4aa4ffd..b38e362 100644
--- a/internal/fusefrontend/fs.go
+++ b/internal/fusefrontend/fs.go
@@ -45,7 +45,7 @@ func NewFS(args Args) *FS {
nameTransform := nametransform.New(cryptoCore.EMECipher, args.LongNames, args.Raw64)
if args.SerializeReads {
- serialize_reads.Init()
+ serialize_reads.InitSerializer()
}
return &FS{
diff --git a/internal/fusefrontend_reverse/rfs.go b/internal/fusefrontend_reverse/rfs.go
index 3c52244..06bbfe9 100644
--- a/internal/fusefrontend_reverse/rfs.go
+++ b/internal/fusefrontend_reverse/rfs.go
@@ -182,13 +182,13 @@ func (rfs *ReverseFS) GetAttr(relPath string, context *fuse.Context) (*fuse.Attr
// Access - FUSE call
func (rfs *ReverseFS) Access(relPath string, mode uint32, context *fuse.Context) fuse.Status {
if rfs.isTranslatedConfig(relPath) || rfs.isDirIV(relPath) || rfs.isNameFile(relPath) {
+ // access(2) R_OK flag for checking if the file is readable, always 4 as defined in POSIX.
+ ROK := uint32(0x4)
// Virtual files can always be read and never written
- var R_OK uint32 = 4
- if mode == R_OK || mode == 0 {
+ if mode == ROK || mode == 0 {
return fuse.OK
- } else {
- return fuse.EPERM
}
+ return fuse.EPERM
}
absPath, err := rfs.abs(rfs.decryptPath(relPath))
if err != nil {
diff --git a/internal/serialize_reads/sr.go b/internal/serialize_reads/sr.go
index 0f623d3..9b45bf6 100644
--- a/internal/serialize_reads/sr.go
+++ b/internal/serialize_reads/sr.go
@@ -8,7 +8,8 @@ import (
"github.com/rfjakob/gocryptfs/internal/tlog"
)
-type SerializerStruct struct {
+// serializerState is used by the Wait and Done functions
+type serializerState struct {
// we get submissions through the "input" channel
input chan *submission
// q = Queue
@@ -37,7 +38,7 @@ type submission struct {
size int
}
-func (sr *SerializerStruct) wait(offset int64, size int) {
+func (sr *serializerState) wait(offset int64, size int) {
ch := make(chan struct{})
sb := &submission{
ch: ch,
@@ -52,7 +53,7 @@ func (sr *SerializerStruct) wait(offset int64, size int) {
// push returns true if the queue is full after the element has been stored.
// It panics if it did not have space to store the element.
-func (sr *SerializerStruct) push(sb *submission) (full bool) {
+func (sr *serializerState) push(sb *submission) (full bool) {
free := 0
stored := false
for i, v := range sr.q {
@@ -77,7 +78,7 @@ func (sr *SerializerStruct) push(sb *submission) (full bool) {
}
// pop the submission with the lowest offset off the queue
-func (sr *SerializerStruct) pop() *submission {
+func (sr *serializerState) pop() *submission {
var winner *submission
var winnerIndex int
for i, v := range sr.q {
@@ -101,7 +102,7 @@ func (sr *SerializerStruct) pop() *submission {
return winner
}
-func (sr *SerializerStruct) eventLoop() {
+func (sr *serializerState) eventLoop() {
sr.input = make(chan *submission)
empty := true
for {
@@ -128,7 +129,7 @@ func (sr *SerializerStruct) eventLoop() {
}
// Unblock a submission and wait for completion
-func (sr *SerializerStruct) unblockOne() (empty bool) {
+func (sr *serializerState) unblockOne() (empty bool) {
winner := sr.pop()
if winner == nil {
return true
@@ -139,10 +140,11 @@ func (sr *SerializerStruct) unblockOne() (empty bool) {
return false
}
-var serializer SerializerStruct
+var serializer serializerState
-// Called by fusefrontend.NewFS
-func Init() {
+// InitSerializer sets up the internal serializer state and starts the event loop.
+// Called by fusefrontend.NewFS.
+func InitSerializer() {
serializer.input = make(chan *submission)
serializer.q = make([]*submission, 10)
go serializer.eventLoop()
diff --git a/internal/siv_aead/siv_aead.go b/internal/siv_aead/siv_aead.go
index d5df4ac..9b85fde 100644
--- a/internal/siv_aead/siv_aead.go
+++ b/internal/siv_aead/siv_aead.go
@@ -16,13 +16,15 @@ type sivAead struct {
var _ cipher.AEAD = &sivAead{}
const (
+ // KeyLen is the required key length. The SIV algorithm supports other lengths,
+ // but we only support 64.
KeyLen = 64
)
// New returns a new cipher.AEAD implementation.
func New(key []byte) cipher.AEAD {
if len(key) != KeyLen {
- // SIV supports more 32, 48 or 64-byte keys, but in gocryptfs we
+ // SIV supports 32, 48 or 64-byte keys, but in gocryptfs we
// exclusively use 64.
log.Panicf("Key must be %d byte long (you passed %d)", KeyLen, len(key))
}
diff --git a/internal/speed/speed.go b/internal/speed/speed.go
index 8732576..f020fca 100644
--- a/internal/speed/speed.go
+++ b/internal/speed/speed.go
@@ -17,6 +17,7 @@ import (
"github.com/rfjakob/gocryptfs/internal/stupidgcm"
)
+// Run - run the speed the test and print the results.
func Run() {
bTable := []struct {
name string