aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fsck.go21
-rw-r--r--tests/fsck/broken_fs_v1.4/6nGs4Ugr3EAHd0KzkyLZ-Q0
-rw-r--r--tests/fsck/broken_fs_v1.4/CMyUifVTjW5fsgXonWBT_RDkvLkdGrLttkZ45T3Oi3A0
-rw-r--r--tests/fsck/broken_fs_v1.4/b00sbnGXGToadr01GHZaYQn8tjyRhe1OXNBZoQtMlcQ0
-rw-r--r--tests/fsck/fsck_test.go16
5 files changed, 36 insertions, 1 deletions
diff --git a/fsck.go b/fsck.go
index 1954fa5..9eff72e 100644
--- a/fsck.go
+++ b/fsck.go
@@ -28,6 +28,7 @@ func (ck *fsckObj) markCorrupt(path string) {
// Recursively check dir for corruption
func (ck *fsckObj) dir(path string) {
//fmt.Printf("ck.dir %q\n", path)
+ ck.xattrs(path)
entries, status := ck.fs.OpenDir(path, nil)
if !status.Ok() {
ck.markCorrupt(path)
@@ -53,7 +54,7 @@ func (ck *fsckObj) dir(path string) {
case syscall.S_IFIFO, syscall.S_IFSOCK, syscall.S_IFBLK, syscall.S_IFCHR:
// nothing to check
default:
- fmt.Printf("fsck: unhandle file type %x\n", filetype)
+ fmt.Printf("fsck: unhandled file type %x\n", filetype)
}
}
}
@@ -69,6 +70,7 @@ func (ck *fsckObj) symlink(path string) {
// check file for corruption
func (ck *fsckObj) file(path string) {
//fmt.Printf("ck.file %q\n", path)
+ ck.xattrs(path)
f, status := ck.fs.Open(path, syscall.O_RDONLY, nil)
if !status.Ok() {
ck.markCorrupt(path)
@@ -93,6 +95,23 @@ func (ck *fsckObj) file(path string) {
}
}
+// Check xattrs on file/dir at path
+func (ck *fsckObj) xattrs(path string) {
+ attrs, status := ck.fs.ListXAttr(path, nil)
+ if !status.Ok() {
+ fmt.Printf("fsck: error listing xattrs on %q: %v\n", path, status)
+ ck.markCorrupt(path)
+ return
+ }
+ for _, a := range attrs {
+ _, status := ck.fs.GetXAttr(path, a, nil)
+ if !status.Ok() {
+ fmt.Printf("fsck: error reading xattr %q from %q: %v\n", a, path, status)
+ ck.markCorrupt(path)
+ }
+ }
+}
+
func fsck(args *argContainer) {
if args.reverse {
tlog.Fatal.Printf("Running -fsck with -reverse is not supported")
diff --git a/tests/fsck/broken_fs_v1.4/6nGs4Ugr3EAHd0KzkyLZ-Q b/tests/fsck/broken_fs_v1.4/6nGs4Ugr3EAHd0KzkyLZ-Q
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/fsck/broken_fs_v1.4/6nGs4Ugr3EAHd0KzkyLZ-Q
diff --git a/tests/fsck/broken_fs_v1.4/CMyUifVTjW5fsgXonWBT_RDkvLkdGrLttkZ45T3Oi3A b/tests/fsck/broken_fs_v1.4/CMyUifVTjW5fsgXonWBT_RDkvLkdGrLttkZ45T3Oi3A
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/fsck/broken_fs_v1.4/CMyUifVTjW5fsgXonWBT_RDkvLkdGrLttkZ45T3Oi3A
diff --git a/tests/fsck/broken_fs_v1.4/b00sbnGXGToadr01GHZaYQn8tjyRhe1OXNBZoQtMlcQ b/tests/fsck/broken_fs_v1.4/b00sbnGXGToadr01GHZaYQn8tjyRhe1OXNBZoQtMlcQ
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/fsck/broken_fs_v1.4/b00sbnGXGToadr01GHZaYQn8tjyRhe1OXNBZoQtMlcQ
diff --git a/tests/fsck/fsck_test.go b/tests/fsck/fsck_test.go
index 77f94c3..657ce89 100644
--- a/tests/fsck/fsck_test.go
+++ b/tests/fsck/fsck_test.go
@@ -6,11 +6,27 @@ import (
"strings"
"testing"
+ "github.com/pkg/xattr"
+
"github.com/rfjakob/gocryptfs/internal/exitcodes"
"github.com/rfjakob/gocryptfs/tests/test_helpers"
)
func TestBrokenFsV14(t *testing.T) {
+ // git does not save extended attributes, so we apply them here.
+ // xattr_good
+ xattr.Set("broken_fs_v1.4/6nGs4Ugr3EAHd0KzkyLZ-Q",
+ "user.gocryptfs.0a5e7yWl0SGUGeWB0Sy2Kg",
+ []byte("hxnZvXSkDicfwVS9w4r1yYkFF61Qou6NaL-VhObYEdu6kuM"))
+ // xattr_corrupt_name
+ xattr.Set("broken_fs_v1.4/CMyUifVTjW5fsgXonWBT_RDkvLkdGrLttkZ45T3Oi3A",
+ "user.gocryptfs.0a5e7yWl0SGUGeWB0Sy2K0",
+ []byte("QHUMDTgbnl8Sv_A2dFQic_G2vN4_gmDna3651JAhF7OZ-YI"))
+ // xattr_corrupt_value
+ xattr.Set("broken_fs_v1.4/b00sbnGXGToadr01GHZaYQn8tjyRhe1OXNBZoQtMlcQ",
+ "user.gocryptfs.0a5e7yWl0SGUGeWB0Sy2Kg",
+ []byte("A0hvCePeKpL8bCpijhDKtf7cIijXYQsPnEbNJ84M2ONW0dd"))
+
cmd := exec.Command(test_helpers.GocryptfsBinary, "-fsck", "-extpass", "echo test", "broken_fs_v1.4")
outBin, err := cmd.CombinedOutput()
out := string(outBin)