Ejemplo n.º 1
0
// LOCKS_EXCLUDED(fs.mu)
func (fs *fileSystem) ReadFile(
	op *fuseops.ReadFileOp) (err error) {
	// Find the inode.
	fs.mu.Lock()
	in := fs.inodes[op.Inode].(*inode.FileInode)
	fs.mu.Unlock()

	in.Lock()
	defer in.Unlock()

	// Serve the request.
	op.Data, err = in.Read(op.Context(), op.Offset, op.Size)

	return
}
Ejemplo n.º 2
0
func (fs *InterruptFS) ReadFile(
	op *fuseops.ReadFileOp) (err error) {
	// Signal that a read has been received.
	fs.mu.Lock()
	fs.readInFlight = true
	fs.readInFlightChanged.Broadcast()
	fs.mu.Unlock()

	// 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
}