Commit 2efc043b authored by MLA98's avatar MLA98

Update device.rs

parent 8dc7aaee
......@@ -95,12 +95,16 @@ const TD_CMD_RS: u8 = 1 << 3;
const TD_DD: u8 = 1;
pub fn setnetcfg(key: &str, value: &str) -> Result<()> {
let mut file = File::create(&format!("/etc/net/eth0/{}", key))?;
file.write(value.as_bytes())?;
file.set_len(value.len() as u64)?;
file.sync_all()?;
Ok(())
mod utils {
use std::fs::File;
use std::io::{Result, Read, Write};
pub fn setnetcfg(key: &str, value: &str) -> Result<()> {
let mut file = File::create(&format!("/etc/net/eth0/{}", key))?;
file.write(value.as_bytes())?;
file.set_len(value.len() as u64)?;
file.sync_all()?;
Ok(())
}
}
......@@ -341,7 +345,7 @@ impl Intel8254x {
mac_high as u8,
(mac_high >> 8) as u8];
print!("{}", format!(" - MAC: {:>02X}:{:>02X}:{:>02X}:{:>02X}:{:>02X}:{:>02X}\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]));
let _ = setnetcfg("mac", &format!("{:>02X}-{:>02X}-{:>02X}-{:>02X}-{:>02X}-{:>02X}\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]));
let _ = utils::setnetcfg("mac", &format!("{:>02X}-{:>02X}-{:>02X}-{:>02X}-{:>02X}-{:>02X}\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]));
//
// MTA => 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment