Skip to content

lscpu: add -s/--sysroot support#528

Open
jmr wants to merge 1 commit intouutils:mainfrom
jmr:sysroot
Open

lscpu: add -s/--sysroot support#528
jmr wants to merge 1 commit intouutils:mainfrom
jmr:sysroot

Conversation

@jmr
Copy link
Copy Markdown

@jmr jmr commented Apr 16, 2026

Add the -s/--sysroot option present in upstream util-linux but previously missing. All hardcoded /sys/ and /proc/ paths in sysfs.rs are threaded through a root: &Path parameter; the default root is / so behaviour without the flag is unchanged.

To support this cleanly, introduce a new local shared crate uulinux with a join_under_root(root, path) -> PathBuf helper that prepends a sysroot to an absolute system path without discarding the root (unlike Path::join). Also use it in lsmem to replace the existing hand-rolled path construction there.

Add unit tests for join_under_root and Linux integration tests for lscpu --sysroot using a minimal fake sysfs/procfs tree.

Add the `-s`/`--sysroot` option present in upstream util-linux but
previously missing. All hardcoded `/sys/` and `/proc/` paths in
`sysfs.rs` are threaded through a `root: &Path` parameter; the default
root is `/` so behaviour without the flag is unchanged.

To support this cleanly, introduce a new local shared crate `uulinux`
with a `join_under_root(root, path) -> PathBuf` helper that prepends a
sysroot to an absolute system path without discarding the root (unlike
`Path::join`). Also use it in `lsmem` to replace the existing
hand-rolled path construction there.

Add unit tests for `join_under_root` and Linux integration tests for
`lscpu --sysroot` using a minimal fake sysfs/procfs tree.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant