summaryrefslogtreecommitdiff
path: root/internal/fusefrontend
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-04-02 18:32:30 +0200
committerJakob Unterwurzacher2018-04-02 18:32:30 +0200
commitb6c8960b01f9e5366814b0dada57a0b1e6a031d9 (patch)
tree6a65255c30c7bcd086523fd4e0970d3b59b230de /internal/fusefrontend
parente6caf56ea4ab10e747aa5dfc0a768cb8176ebe6a (diff)
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.
Diffstat (limited to 'internal/fusefrontend')
-rw-r--r--internal/fusefrontend/file.go18
-rw-r--r--internal/fusefrontend/fs.go9
-rw-r--r--internal/fusefrontend/fs_dir.go13
3 files changed, 17 insertions, 23 deletions
diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go
index e1ce6a9..af13170 100644
--- a/internal/fusefrontend/file.go
+++ b/internal/fusefrontend/file.go
@@ -97,7 +97,7 @@ func (f *file) readFileID() ([]byte, error) {
n, err := f.fd.ReadAt(buf, 0)
if err != nil {
if err == io.EOF && n != 0 {
- tlog.Warn.Printf("ino%d: readFileID: incomplete file, got %d instead of %d bytes",
+ tlog.Warn.Printf("readFileID %d: incomplete file, got %d instead of %d bytes",
f.qIno.Ino, n, readLen)
}
return nil, err
@@ -156,7 +156,8 @@ func (f *file) doRead(dst []byte, off uint64, length uint64) ([]byte, fuse.Statu
}
if err != nil {
f.fileTableEntry.HeaderLock.Unlock()
- return nil, fuse.ToStatus(err)
+ tlog.Warn.Printf("doRead %d: corrupt header: %v", f.qIno.Ino, err)
+ return nil, fuse.EIO
}
f.fileTableEntry.ID = tmpID
// Downgrade the lock.
@@ -200,11 +201,11 @@ func (f *file) doRead(dst []byte, off uint64, length uint64) ([]byte, fuse.Statu
if f.fs.args.ForceDecode && err == stupidgcm.ErrAuth {
// We do not have the information which block was corrupt here anymore,
// but DecryptBlocks() has already logged it anyway.
- tlog.Warn.Printf("ino%d: doRead off=%d len=%d: returning corrupt data due to forcedecode",
+ tlog.Warn.Printf("doRead %d: off=%d len=%d: returning corrupt data due to forcedecode",
f.qIno.Ino, off, length)
} else {
curruptBlockNo := firstBlockNo + f.contentEnc.PlainOffToBlockNo(uint64(len(plaintext)))
- tlog.Warn.Printf("ino%d: doRead: corrupt block #%d: %v", f.qIno.Ino, curruptBlockNo, err)
+ tlog.Warn.Printf("doRead %d: corrupt block #%d: %v", f.qIno.Ino, curruptBlockNo, err)
return nil, fuse.EIO
}
}
@@ -233,29 +234,20 @@ func (f *file) Read(buf []byte, off int64) (resultData fuse.ReadResult, code fus
tlog.Warn.Printf("Read: rejecting oversized request with EMSGSIZE, len=%d", len(buf))
return nil, fuse.Status(syscall.EMSGSIZE)
}
-
f.fdLock.RLock()
defer f.fdLock.RUnlock()
tlog.Debug.Printf("ino%d: FUSE Read: offset=%d length=%d", f.qIno.Ino, len(buf), off)
-
if f.fs.args.SerializeReads {
serialize_reads.Wait(off, len(buf))
}
-
out, status := f.doRead(buf[:0], uint64(off), uint64(len(buf)))
-
if f.fs.args.SerializeReads {
serialize_reads.Done()
}
-
- if status == fuse.EIO {
- tlog.Warn.Printf("ino%d: Read: returning EIO, offset=%d, length=%d", f.qIno.Ino, len(buf), off)
- }
if status != fuse.OK {
return nil, status
}
-
tlog.Debug.Printf("ino%d: Read: status %v, returning %d bytes", f.qIno.Ino, status, len(out))
return fuse.ReadResultData(out), status
}
diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go
index e246264..5f84541 100644
--- a/internal/fusefrontend/fs.go
+++ b/internal/fusefrontend/fs.go
@@ -365,12 +365,13 @@ func (fs *FS) decryptSymlinkTarget(cData64 string) (string, error) {
}
// Readlink implements pathfs.Filesystem.
-func (fs *FS) Readlink(path string, context *fuse.Context) (out string, status fuse.Status) {
- cPath, err := fs.getBackingPath(path)
+func (fs *FS) Readlink(relPath string, context *fuse.Context) (out string, status fuse.Status) {
+ cPath, err := fs.encryptPath(relPath)
if err != nil {
return "", fuse.ToStatus(err)
}
- cTarget, err := os.Readlink(cPath)
+ cAbsPath := filepath.Join(fs.args.Cipherdir, cPath)
+ cTarget, err := os.Readlink(cAbsPath)
if err != nil {
return "", fuse.ToStatus(err)
}
@@ -380,7 +381,7 @@ func (fs *FS) Readlink(path string, context *fuse.Context) (out string, status f
// Symlinks are encrypted like file contents (GCM) and base64-encoded
target, err := fs.decryptSymlinkTarget(cTarget)
if err != nil {
- tlog.Warn.Printf("Readlink: %v", err)
+ tlog.Warn.Printf("Readlink %q: decrypting target failed: %v", cPath, err)
return "", fuse.EIO
}
return string(target), fuse.OK
diff --git a/internal/fusefrontend/fs_dir.go b/internal/fusefrontend/fs_dir.go
index fcfdbb5..e13afed 100644
--- a/internal/fusefrontend/fs_dir.go
+++ b/internal/fusefrontend/fs_dir.go
@@ -286,12 +286,13 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f
cachedIV, err = nametransform.ReadDirIV(cDirAbsPath)
if err != nil {
fs.dirIVLock.RUnlock()
- // This can happen during normal operation when the directory has
- // been deleted concurrently. But it can also mean that the
- // gocryptfs.diriv is missing due to an error, so log the event
- // at "info" level.
- tlog.Info.Printf("OpenDir: %v", err)
- return nil, fuse.ToStatus(err)
+ // The directory itself does not exist
+ if err == syscall.ENOENT {
+ return nil, fuse.ENOENT
+ }
+ // Any other problem warrants an error message
+ tlog.Warn.Printf("OpenDir %q: could not read gocryptfs.diriv: %v", cDirName, err)
+ return nil, fuse.EIO
}
fs.nameTransform.DirIVCache.Store(dirName, cachedIV, cDirName)
fs.dirIVLock.RUnlock()