sys/storage: gate the sysfs device discovery to unix - #548
Open
obodnikov wants to merge 1 commit into
Open
Conversation
`sys/storage.rs` walks `/sys/dev/block/` and reaches the device through
`MetadataExt::dev` and `libc::major`/`libc::minor`, none of which exist off
unix, so `tuwunel_core` does not compile there:
error[E0599]: no method named `dev` found for struct `Metadata`
error[E0425]: cannot find function `major` in crate `libc`
error[E0425]: cannot find function `minor` in crate `libc`
`dev_from_path` already carries `#[cfg(target_family = "unix")]` on its
`MetadataExt` import, which is what makes the method go missing rather than the
import fail; the three call sites below it were never gated to match. This puts
the whole discovery path behind the same condition, so that attribute becomes
redundant and goes.
`md_discover` and `name_from_path` are the two entry points, both called
unconditionally from `database/pool/configure.rs`, so each gains a
`#[cfg(not(unix))]` arm rather than pushing a condition onto the caller:
`md_discover` reports no raid, which is what the unix arm returns for a path
that is not on one, and `name_from_path` reports the target cannot name a
device, alongside the `NotFound` the unix arm already returns when the name is
not there to be read.
`mq_discover`, `queue_discover`, `dev_from_path` and `block_path` are private
and reachable only from the gated entry points, so they need no second arm.
`itertools` and `libc::dev_t` do resolve off unix but are used only by the gated
items, so they follow the condition; `Path` and `Result` are used by both arms
and stay ungated.
No behaviour change on unix.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
sys/storage.rswalks/sys/dev/block/and reaches the device throughMetadataExt::devandlibc::major/libc::minor, none of which exists off unix, sotuwunel_coredoes not compile there:dev_from_pathalready carries#[cfg(target_family = "unix")]on itsMetadataExtimport — which is what makes the method go missing rather than the import fail — but the
three call sites below it were never gated to match. This puts the whole discovery path
behind the same condition, so that attribute becomes redundant and goes with it.
md_discoverandname_from_pathare the two entry points, both called unconditionallyfrom
database/pool/configure.rs, so each gains a#[cfg(not(unix))]arm rather thanpushing a condition onto the caller:
Both mirror an outcome the unix arm already produces:
md_discoverreturns the sameempty
MultiDeviceit returns for a path that is not on a raid, andname_from_pathalready returns
NotFoundwhenDEVNAMEis not there to be read, soconfigure.rshandles an error from it today.mq_discover,queue_discover,dev_from_pathandblock_pathare private andreachable only from the gated entry points, so they need no second arm.
itertoolsandlibc::dev_tdo resolve off unix but are used only by the gated items, so they followthe same condition;
PathandResultare used by both arms and stay ungated.The module comment is rewritten to say which facility is missing rather than which
platform is running, since the condition is
unix, not any one target.No behaviour change on unix. Same class of fix as #526, #527, #528 and #536.
On verification. CI builds Linux only, where none of this appears, so CI cannot
demonstrate the change: the symptom is absent there both before and after. It was
observed building v1.8.3 for
x86_64-pc-windows-msvc, and the three errors above arereproducible on any host with a two-file crate that depends on
libcand callsstat.dev(),libc::majorandlibc::minorbehind the same#[cfg(target_family = "unix")]import this file has.cargo +nightly fmt --check,cargo checkandcargo clippyon the unix path are clean before and after.Checklist
cargo fmtand satisfies clippy andrustc lints; any allowed lint is justified by an obvious reason or a
comment.
are noted in the description above. — none; the unix path is unchanged.
src/core/config/mod.rsdoccomments and the regenerated
tuwunel-example.tomlis committed. — n/adocs/. — n/aand my conduct is in line with the Contributor's Covenant and
Tuwunel's Code of Conduct.