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
F93103195: D38265.id116023.diff
Sat, Sep 7, 9:11 AM
F93085313: D38265.id116267.diff
Sat, Sep 7, 4:48 AM
Unknown Object (File)
Fri, Sep 6, 9:13 AM
Unknown Object (File)
Wed, Sep 4, 9:38 AM
Unknown Object (File)
Wed, Sep 4, 9:28 AM
Unknown Object (File)
Tue, Sep 3, 9:41 AM
Unknown Object (File)
Mon, Sep 2, 1:27 PM
Unknown Object (File)
Sun, Sep 1, 1:23 PM
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 49307
Build 46197: arc lint + arc unit

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.