Page MenuHomeFreeBSD

kboot: For hostfs, return better errors from read, where possible.
ClosedPublic

Authored by imp on Jan 29 2023, 3:16 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 13, 1:17 AM
Unknown Object (File)
Dec 2 2024, 11:32 PM
Unknown Object (File)
Dec 1 2024, 6:59 PM
Unknown Object (File)
Nov 21 2024, 8:49 AM
Unknown Object (File)
Nov 21 2024, 7:09 AM
Unknown Object (File)
Nov 21 2024, 7:09 AM
Unknown Object (File)
Nov 21 2024, 7:09 AM
Unknown Object (File)
Nov 21 2024, 7:09 AM
Subscribers

Details

Summary

Translate the Linux error return from read to a FreeBSD errno. We use a
simplified translation: 1-34 are the same between the systems, so any of
those will be returned directly. All other errno map to EINVAL. This
will suffice for some code that reads /dev/mem in producing the right
diagnostic.

A fully generalized version is much harder. Linux has a number of errno
that don't translate well and has architecture dependent
encodings. Avoid this mess with a simple macro for now. Add comment
explaining why we use the simple method we do.

Sponsored by: Netflix

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

imp requested review of this revision.Jan 29 2023, 3:16 PM

rebase / refactor / redo

kevans added inline comments.
stand/kboot/host_syscall.h
211
This revision is now accepted and ready to land.Feb 2 2023, 3:58 AM
This revision now requires review to proceed.Feb 2 2023, 4:21 AM
This revision is now accepted and ready to land.Feb 2 2023, 2:55 PM

I did find myself wondering if host_to_stand_errno should assert that e <= 0 since it's a relatively common error to accidentally use positive errors when modifying linux code.

I did find myself wondering if host_to_stand_errno should assert that e <= 0 since it's a relatively common error to accidentally use positive errors when modifying linux code.

I had similar thoughts early on, but this wound up being a #define... I'll post a followup review.