コード例 #1
0
ファイル: fs.go プロジェクト: mbookman/gcsfuse
// 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
}
コード例 #2
0
ファイル: interrupt_fs.go プロジェクト: BanzaiMan/gcsfuse
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
}