aboutsummaryrefslogtreecommitdiff
path: root/fsck.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-04-02 20:25:59 +0200
committerJakob Unterwurzacher2018-04-02 20:25:59 +0200
commit8b443c8484f5fdcedbec2a689a7d66d2a277b26e (patch)
tree59c687437cf310b0aa615079bdf2a2974200f1fb /fsck.go
parent4407ca3a4da04c7c43bc6691819ae44f77625f16 (diff)
fsck: add xattr support
With testcases.
Diffstat (limited to 'fsck.go')
-rw-r--r--fsck.go21
1 files changed, 20 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")