linux-kernel-cmdline
A parser for the Linux kernel command line (/proc/cmdline), supporting both
byte-level and UTF-8 parsing with proper quote handling and dash/underscore
equivalence for parameter keys.
Usage
Add the dependency to your Cargo.toml:
[]
= "0.1"
Parsing the current system's kernel command line
use Cmdline;
let cmdline = from_proc?;
if let Some = cmdline.value_of
for param in cmdline.iter
Parsing a command line from a string
use Cmdline;
let cmdline = from;
// Find a specific parameter
if let Some = cmdline.find
// Dashes and underscores in keys are treated as equivalent
let cmdline = from;
assert_eq!;
Working with non-UTF-8 data
For environments where the kernel command line may contain arbitrary bytes,
use the bytes module:
use Cmdline;
let cmdline = from_proc?;
if let Some = cmdline.value_of
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.