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

Function is_linux_kernel_config_item_enabled

tests/process/prctl.rs:209–233  ·  view source on GitHub ↗
(config: &[u8], name: &str)

Source from the content-addressed store, hash-verified

207
208#[cfg(feature = "system")]
209fn is_linux_kernel_config_item_enabled(config: &[u8], name: &str) -> io::Result<bool> {
210 for line in io::Cursor::new(config).lines() {
211 let line = line?;
212 let line = line.trim();
213 if line.is_empty() || line.starts_with('#') {
214 continue;
215 }
216
217 let mut iter = line.splitn(2, '=');
218 if let Some(current_name) = iter.next().map(str::trim) {
219 if current_name == name {
220 if let Some(mut value) = iter.next().map(str::trim) {
221 if value.starts_with('"') && value.ends_with('"') {
222 // Just remove the quotes, but don't bother unescaping the inner string
223 // because we are only trying to find out if the option is a true boolean.
224 value = &value[1..(value.len() - 2)];
225 }
226
227 return Ok(value == "y" || value == "m");
228 }
229 }
230 }
231 }
232 Ok(false)
233}
234
235#[cfg(feature = "system")]
236fn linux_kernel_config_item_is_enabled(name: &str) -> io::Result<bool> {

Callers 1

Calls 2

nextMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected