| Index: src/pkg/crypto/rand/rand_plan9.go | 
| =================================================================== | 
| new file mode 100644 | 
| --- /dev/null | 
| +++ b/src/pkg/crypto/rand/rand_plan9.go | 
| @@ -0,0 +1,33 @@ | 
| +// Copyright 2010 The Go Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style | 
| +// license that can be found in the LICENSE file. | 
| + | 
| +package rand | 
| + | 
| +import ( | 
| + "io" | 
| + "os" | 
| + "sync" | 
| +) | 
| + | 
| +func init() { Reader = newReader(nil) } | 
| + | 
| +// A devReader satisfies reads by reading the file named name. | 
| +type devReader struct { | 
| + name string | 
| + f io.Reader | 
| + mu sync.Mutex | 
| +} | 
| + | 
| +func (r *devReader) Read(b []byte) (n int, err os.Error) { | 
| + r.mu.Lock() | 
| + defer r.mu.Unlock() | 
| + if r.f == nil { | 
| + f, err := os.Open(r.name) | 
| + if f == nil { | 
| + return 0, err | 
| + } | 
| + r.f = f | 
| + } | 
| + return r.f.Read(b) | 
| +} |