MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / validate_sysfs_data

Function validate_sysfs_data

crates/openshell-vfio/src/sysfs.rs:203–208  ·  view source on GitHub ↗

Returns `true` if `data` contains only safe characters for sysfs values (alphanumeric plus `:`, `.`, `-`, `_`).

(data: &str)

Source from the content-addressed store, hash-verified

201/// Returns `true` if `data` contains only safe characters for sysfs values
202/// (alphanumeric plus `:`, `.`, `-`, `_`).
203pub fn validate_sysfs_data(data: &str) -> bool {
204 !data.is_empty()
205 && data
206 .chars()
207 .all(|c| c.is_alphanumeric() || matches!(c, ':' | '.' | '-' | '_'))
208}
209
210pub(crate) fn read_sysfs_trimmed(path: &Path) -> Result<String, VfioError> {
211 fs::read_to_string(path)

Callers

nothing calls this directly

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected