// ExtractErrno extracts an integer error number from the error.
// The syscall number is purely for context in the error case. Use -1 if
// syscall number is unknown.
ExtractErrno extracts an integer error number from the error.
The syscall number is purely for context in the error case. Use -1 if
syscall number is unknown.
// ExtractErrno extracts an integer error number from the error . // The syscall number is purely for context in the error case . Use - 1 if // syscall number is unknown .
func ExtractErrno(err error, sysno int) int {
	switch err := err.(type) {
	case nil:
		return 0
	case unix.Errno:
		return int(err)
	case syserror.SyscallRestartErrno:
		return int(err)
	case *memmap.BusError:
		return int(unix.EFAULT)
	case *os.PathError:
		return ExtractErrno(err.Err, sysno)
	case *os.LinkError:
		return ExtractErrno(err.Err, sysno)
	case *os.SyscallError:
		return ExtractErrno(err.Err, sysno)
	default:
		if errno, ok := syserror.TranslateError(err); ok {
			return int(errno)
		}
	}
	panic(fmt.Sprintf("Unknown syscall %d error: %v", sysno, err))
}
func ExtractErrno ( err error , sysno int ) int { switch err := err . ( type ) { case nil : return 0 case unix . Errno : return int ( err ) case syserror . SyscallRestartErrno : return int ( err ) case * memmap . BusError : return int ( unix . EFAULT ) case * os . PathError : return ExtractErrno ( err . Err , sysno ) case * os . LinkError : return ExtractErrno ( err . Err , sysno ) case * os . SyscallError : return ExtractErrno ( err . Err , sysno ) default : if errno , ok := syserror . TranslateError ( err ) ; ok { return int ( errno ) } } panic ( fmt . Sprintf ( " " , sysno , err ) ) }
ExtractErrno extracts an integer error number from the error.
ExtractErrno extracts an integer error number from the error .
// Bus errors may generate SIGBUS, but for syscalls they still // return EFAULT. See case in task_run.go where the fault is // handled (and the SIGBUS is delivered).