From 0b00132020d0d97276d708a12cd7ff1fa14367aa Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Mon, 4 May 2015 21:56:43 +1000 Subject: [PATCH] InterruptFS.ReadFile --- samples/interruptfs/interrupt_fs.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/samples/interruptfs/interrupt_fs.go b/samples/interruptfs/interrupt_fs.go index 822d673..2229bf3 100644 --- a/samples/interruptfs/interrupt_fs.go +++ b/samples/interruptfs/interrupt_fs.go @@ -136,3 +136,22 @@ func (fs *InterruptFS) OpenFile( return } + +func (fs *InterruptFS) ReadFile( + op *fuseops.ReadFileOp) { + var err error + defer fuseutil.RespondToOp(op, &err) + + // Wait for cancellation. + done := op.Context().Done() + if done == nil { + panic("Expected non-nil channel.") + } + + <-done + + // Return the context's error. + err = op.Context().Err() + + return +}