aboutsummaryrefslogtreecommitdiff
path: root/pathfs_frontend/file.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-10-04 14:36:20 +0200
committerJakob Unterwurzacher2015-10-04 14:49:47 +0200
commit89fef80d32708874c95742db0a7b593bcfd3b31d (patch)
treeadffeac51b1e945e32583b07ab0328a3c2539aad /pathfs_frontend/file.go
parent5bd08abf4095fb553355c9b007c8ae4a4314b970 (diff)
Run go fmt
Diffstat (limited to 'pathfs_frontend/file.go')
-rw-r--r--pathfs_frontend/file.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/pathfs_frontend/file.go b/pathfs_frontend/file.go
index cc8de17..43114b2 100644
--- a/pathfs_frontend/file.go
+++ b/pathfs_frontend/file.go
@@ -1,9 +1,9 @@
package pathfs_frontend
import (
- "io"
"bytes"
"fmt"
+ "io"
"os"
"sync"
"syscall"
@@ -40,10 +40,10 @@ func NewFile(fd *os.File, writeOnly bool, cfs *cryptfs.CryptFS) nodefs.File {
syscall.Fstat(int(fd.Fd()), &st)
return &file{
- fd: fd,
+ fd: fd,
writeOnly: writeOnly,
- cfs: cfs,
- ino: st.Ino,
+ cfs: cfs,
+ ino: st.Ino,
}
}
@@ -101,7 +101,7 @@ func (f *file) doRead(off uint64, length uint64) ([]byte, fuse.Status) {
lenHave := len(plaintext)
lenWant := skip + int(length)
if lenHave > lenWant {
- out = plaintext[skip:skip + int(length)]
+ out = plaintext[skip : skip+int(length)]
} else if lenHave > skip {
out = plaintext[skip:lenHave]
} else {
@@ -139,7 +139,7 @@ func (f *file) doWrite(data []byte, off int64) (uint32, fuse.Status) {
status := fuse.OK
dataBuf := bytes.NewBuffer(data)
blocks := f.cfs.SplitRange(uint64(off), uint64(len(data)))
- for _, b := range(blocks) {
+ for _, b := range blocks {
blockData := dataBuf.Next(int(b.Length))
@@ -180,7 +180,7 @@ func (f *file) doWrite(data []byte, off int64) (uint32, fuse.Status) {
// Write - FUSE call
func (f *file) Write(data []byte, off int64) (uint32, fuse.Status) {
- cryptfs.Debug.Printf("ino%d: FUSE Write %s: offset=%d length=%d\n", f.ino, off, len(data))
+ cryptfs.Debug.Printf("ino%d: FUSE Write: offset=%d length=%d\n", f.ino, off, len(data))
fi, err := f.fd.Stat()
if err != nil {
@@ -248,8 +248,8 @@ func (f *file) Truncate(newSize uint64) fuse.Status {
// File grows
if newSize > oldSize {
- blocks := f.cfs.SplitRange(oldSize, newSize - oldSize)
- for _, b := range(blocks) {
+ blocks := f.cfs.SplitRange(oldSize, newSize-oldSize)
+ for _, b := range blocks {
// First and last block may be partial
if b.IsPartial() {
off, _ := b.PlaintextRange()
@@ -261,7 +261,7 @@ func (f *file) Truncate(newSize uint64) fuse.Status {
} else {
off, length := b.CiphertextRange()
f.lock.Lock()
- err := syscall.Ftruncate(int(f.fd.Fd()), int64(off + length))
+ err := syscall.Ftruncate(int(f.fd.Fd()), int64(off+length))
f.lock.Unlock()
if err != nil {
cryptfs.Warn.Printf("grow Ftruncate returned error: %v", err)
@@ -270,7 +270,7 @@ func (f *file) Truncate(newSize uint64) fuse.Status {
}
}
return fuse.OK
- // File shrinks
+ // File shrinks
} else {
blockNo := f.cfs.BlockNoPlainOff(newSize)
lastBlockOff := blockNo * f.cfs.PlainBS()