diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-05-05 18:22:01 +0200 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-05-05 18:22:01 +0200 |
commit | ce337ea566a7cda7c9a89c4080fa24a15256a1ed (patch) | |
tree | 922ed280370b5a16a672d4f5d6593a37f457af86 /src/main.rs | |
parent | 549e7045a48d899373147d4037d54d3051b45128 (diff) |
overwrite boot partition to modify cmdline
should be more reliable than trying to write a regular file
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index 2997ec7..696a2ba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -157,8 +157,10 @@ fn validate_credentials(user_id: &str, user_password: &str) -> io::Result<bool> } fn modify_cmdline(old: &str, new: &str) -> Result<()> { - let cmdline = fs::read_to_string("/boot/cmdline.txt")?; - fs::write("/boot/cmdline.txt", cmdline.replace(old, new))?; + let boot = boot_dev()?; + + let cmdline = fs::read_to_string(boot)?; + fs::write(boot, cmdline.replace(old, new))?; Ok(()) } @@ -254,8 +256,6 @@ fn switch_to_inactive_root() -> Result<()> { let old = String::from("root=PARTUUID=00000000-0") + &old.chars().last().unwrap().to_string(); let new = String::from("root=PARTUUID=00000000-0") + &new.chars().last().unwrap().to_string(); - println!("[admind] rewrite cmdline {} -> {}", old, new); - modify_cmdline(&old, &new)?; Ok(()) } |