var ErrLimitReached … // ConsistentRead repeatedly reads a file until it gets the same content twice. // This is useful when reading files in /proc that are larger than page size // and kernel may modify them between individual read() syscalls. // It returns InconsistentReadError when it cannot get a consistent read in // given nr. of attempts. Caller should retry, kernel is probably under heavy // mount/unmount load. func ConsistentRead(filename string, attempts int) ([]byte, error) { … } // consistentReadSync is the main functionality of ConsistentRead but // introduces a sync callback that can be used by the tests to mutate the file // from which the test data is being read func consistentReadSync(filename string, attempts int, sync func(int)) ([]byte, error) { … } type InconsistentReadError … func (i InconsistentReadError) Error() string { … } var _ … func IsInconsistentReadError(err error) bool { … } // ReadAtMost reads up to `limit` bytes from `r`, and reports an error // when `limit` bytes are read. func ReadAtMost(r io.Reader, limit int64) ([]byte, error) { … }