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)
Mon, Sep 23, 3:05 PM
Unknown Object (File)
Sun, Sep 22, 12:46 PM
Unknown Object (File)
Fri, Sep 20, 9:43 AM
Unknown Object (File)
Thu, Sep 19, 9:23 AM
Unknown Object (File)
Wed, Sep 18, 5:51 AM
Unknown Object (File)
Wed, Sep 18, 5:12 AM
Unknown Object (File)
Mon, Sep 16, 12:27 PM
Unknown Object (File)
Mon, Sep 16, 8:10 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.