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

Function is_linux_kernel_config_item_enabled

tests/thread/prctl.rs:171–195  ·  view source on GitHub ↗
(config: &[u8], name: &str)

Source from the content-addressed store, hash-verified

169
170#[cfg(feature = "system")]
171fn is_linux_kernel_config_item_enabled(config: &[u8], name: &str) -> io::Result<bool> {
172 for line in io::Cursor::new(config).lines() {
173 let line = line?;
174 let line = line.trim();
175 if line.is_empty() || line.starts_with('#') {
176 continue;
177 }
178
179 let mut iter = line.splitn(2, '=');
180 if let Some(current_name) = iter.next().map(str::trim) {
181 if current_name == name {
182 if let Some(mut value) = iter.next().map(str::trim) {
183 if value.starts_with('"') && value.ends_with('"') {
184 // Just remove the quotes, but don't bother unescaping the inner string
185 // because we are only trying to find out if the option is a true boolean.
186 value = &value[1..(value.len() - 2)];
187 }
188
189 return Ok(value == "y" || value == "m");
190 }
191 }
192 }
193 }
194 Ok(false)
195}
196
197#[cfg(feature = "system")]
198fn 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