summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-07-01 15:48:53 +0200
committerJakob Unterwurzacher2018-07-01 20:56:22 +0200
commit1a18d8e6098633f27c228f6ebce8881a061df54c (patch)
tree971092918f01b2754d0e13ebfa6a3c3cc8587378 /internal
parent283184dd5aed89b19c15cbc9ca9ec23d96784049 (diff)
fsck: rename "CorruptItems" channel to "MitigatedCorruptions"
Make it clear that this channel is only used to report corruptions that are transparently mitigated and do not return an error to the user.
Diffstat (limited to 'internal')
-rw-r--r--internal/fusefrontend/file.go2
-rw-r--r--internal/fusefrontend/fs.go24
-rw-r--r--internal/fusefrontend/fs_dir.go4
-rw-r--r--internal/fusefrontend/xattr.go2
4 files changed, 20 insertions, 12 deletions
diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go
index 72319e9..2041154 100644
--- a/internal/fusefrontend/file.go
+++ b/internal/fusefrontend/file.go
@@ -100,7 +100,7 @@ func (f *file) readFileID() ([]byte, error) {
if err == io.EOF && n != 0 {
tlog.Warn.Printf("readFileID %d: incomplete file, got %d instead of %d bytes",
f.qIno.Ino, n, readLen)
- f.fs.reportCorruptItem(fmt.Sprint(f.qIno.Ino))
+ f.fs.reportMitigatedCorruption(fmt.Sprint(f.qIno.Ino))
}
return nil, err
}
diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go
index 582e6a1..f66e6d4 100644
--- a/internal/fusefrontend/fs.go
+++ b/internal/fusefrontend/fs.go
@@ -38,11 +38,15 @@ type FS struct {
// This lock is used by openWriteOnlyFile() to block concurrent opens while
// it relaxes the permissions on a file.
openWriteOnlyLock sync.RWMutex
- // CorruptItems is filled with file or xattr names that have been
- // skipped (ignored) because they were corrupt. This is used by fsck
- // to inform the user.
- // Use the reportCorruptItem() function to push an item.
- CorruptItems chan string
+ // MitigatedCorruptions is used to report data corruption that is internally
+ // mitigated by ignoring the corrupt item. For example, when OpenDir() finds
+ // a corrupt filename, we still return the other valid filenames.
+ // The corruption is logged to syslog to inform the user, and in addition,
+ // the corrupt filename is logged to this channel via
+ // reportMitigatedCorruption().
+ // "gocryptfs -fsck" reads from the channel to also catch these transparently-
+ // mitigated corruptions.
+ MitigatedCorruptions chan string
}
var _ pathfs.FileSystem = &FS{} // Verify that interface is implemented.
@@ -607,12 +611,16 @@ func (fs *FS) Access(path string, mode uint32, context *fuse.Context) (code fuse
return fuse.ToStatus(syscall.Access(cPath, mode))
}
-func (fs *FS) reportCorruptItem(item string) {
- if fs.CorruptItems == nil {
+// reportMitigatedCorruption is used to report a corruption that was transparently
+// mitigated and did not return an error to the user. Pass the name of the corrupt
+// item (filename for OpenDir(), xattr name for ListXAttr() etc).
+// See the MitigatedCorruptions channel for more info.
+func (fs *FS) reportMitigatedCorruption(item string) {
+ if fs.MitigatedCorruptions == nil {
return
}
select {
- case fs.CorruptItems <- item:
+ case fs.MitigatedCorruptions <- item:
case <-time.After(1 * time.Second):
tlog.Warn.Printf("BUG: reportCorruptItem: timeout")
//debug.PrintStack()
diff --git a/internal/fusefrontend/fs_dir.go b/internal/fusefrontend/fs_dir.go
index 089429e..b7bc790 100644
--- a/internal/fusefrontend/fs_dir.go
+++ b/internal/fusefrontend/fs_dir.go
@@ -326,7 +326,7 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f
if err != nil {
tlog.Warn.Printf("OpenDir %q: invalid entry %q: Could not read .name: %v",
cDirName, cName, err)
- fs.reportCorruptItem(cName)
+ fs.reportMitigatedCorruption(cName)
errorCount++
continue
}
@@ -339,7 +339,7 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f
if err != nil {
tlog.Warn.Printf("OpenDir %q: invalid entry %q: %v",
cDirName, cName, err)
- fs.reportCorruptItem(cName)
+ fs.reportMitigatedCorruption(cName)
if runtime.GOOS == "darwin" && cName == dsStoreName {
// MacOS creates lots of these files. Log the warning but don't
// increment errorCount - does not warrant returning EIO.
diff --git a/internal/fusefrontend/xattr.go b/internal/fusefrontend/xattr.go
index eea67ad..30f417e 100644
--- a/internal/fusefrontend/xattr.go
+++ b/internal/fusefrontend/xattr.go
@@ -106,7 +106,7 @@ func (fs *FS) ListXAttr(path string, context *fuse.Context) ([]string, fuse.Stat
name, err := fs.decryptXattrName(curName)
if err != nil {
tlog.Warn.Printf("ListXAttr: invalid xattr name %q: %v", curName, err)
- fs.reportCorruptItem(curName)
+ fs.reportMitigatedCorruption(curName)
continue
}
names = append(names, name)