MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / load_linux_kernel_config

Function load_linux_kernel_config

tests/process/prctl.rs:191–206  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

189
190#[cfg(feature = "system")]
191fn load_linux_kernel_config() -> io::Result<Vec<u8>> {
192 if let Ok(compressed_bytes) = fs::read("/proc/config.gz") {
193 let mut decoder = flate2::bufread::GzDecoder::new(compressed_bytes.as_slice());
194 let mut bytes = Vec::default();
195 decoder.read_to_end(&mut bytes)?;
196 return Ok(bytes);
197 }
198
199 let info = rustix::system::uname();
200 let release = info
201 .release()
202 .to_str()
203 .map_err(|_r| io::Error::from(io::ErrorKind::InvalidData))?;
204
205 fs::read(format!("/boot/config-{}", release))
206}
207
208#[cfg(feature = "system")]
209fn is_linux_kernel_config_item_enabled(config: &[u8], name: &str) -> io::Result<bool> {

Callers 1

Calls 4

releaseMethod · 0.80
readFunction · 0.50
unameFunction · 0.50
as_sliceMethod · 0.45

Tested by

no test coverage detected