import "syscall"
// wrapSyscallError takes an error and a syscall name. If the error is
-// a syscall.Errno, it wraps it in a os.SyscallError using the syscall name.
+// a syscall.Errno, it wraps it in an os.SyscallError using the syscall name.
func wrapSyscallError(name string, err error) error {
if _, ok := err.(syscall.Errno); ok {
err = NewSyscallError(name, err)
var ErrWriteAtInAppendMode = errWriteAtInAppendMode
var TestingForceReadDirLstat = &testingForceReadDirLstat
var ErrPatternHasSeparator = errPatternHasSeparator
+
+func init() {
+ checkWrapErr = true
+}
return n, err
}
+// checkWrapErr is the test hook to enable checking unexpected wrapped errors of poll.ErrFileClosing.
+// It is set to true in the export_test.go for tests (including fuzz tests).
+var checkWrapErr = false
+
// wrapErr wraps an error that occurred during an operation on an open file.
// It passes io.EOF through unchanged, otherwise converts
// poll.ErrFileClosing to ErrClosed and wraps the error in a PathError.
}
if err == poll.ErrFileClosing {
err = ErrClosed
+ } else if checkWrapErr && errors.Is(err, poll.ErrFileClosing) {
+ panic("unexpected error wrapping poll.ErrFileClosing: " + err.Error())
}
return &PathError{Op: op, Path: f.name, Err: err}
}
lr.N = remain - written
}
- return written, handled, NewSyscallError(syscallName, err)
+ return written, handled, wrapSyscallError(syscallName, err)
}
// getPollFD tries to get the poll.FD from the given io.Reader by expecting
if lr != nil {
lr.N -= written
}
- return written, handled, NewSyscallError("copy_file_range", err)
+ return written, handled, wrapSyscallError("copy_file_range", err)
}
// tryLimitedReader tries to assert the io.Reader to io.LimitedReader, it returns the io.LimitedReader,