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)
Wed, Jul 24, 4:28 AM
Unknown Object (File)
Sat, Jul 13, 10:22 PM
Unknown Object (File)
Jun 22 2024, 8:58 AM
Unknown Object (File)
Jun 15 2024, 7:16 AM
Unknown Object (File)
Jun 14 2024, 1:42 PM
Unknown Object (File)
Jun 14 2024, 12:48 PM
Unknown Object (File)
Jun 14 2024, 12:14 PM
Unknown Object (File)
Jun 3 2024, 8:06 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.