Managed to start a VM again

This commit is contained in:
2023-12-06 20:27:59 +01:00
parent 8b53875349
commit 60d35f17bd
6 changed files with 53 additions and 6 deletions

View File

@ -1,3 +1,4 @@
use std::os::unix::fs::PermissionsExt;
use std::path::Path;
const INVALID_CHARS: [&str; 19] = [
@ -19,6 +20,14 @@ pub fn create_directory_if_missing<P: AsRef<Path>>(path: P) -> anyhow::Result<()
Ok(())
}
/// Update file permission
pub fn set_file_permission<P: AsRef<Path>>(path: P, mode: u32) -> anyhow::Result<()> {
let mut perms = std::fs::metadata(path.as_ref())?.permissions();
perms.set_mode(mode);
std::fs::set_permissions(path.as_ref(), perms)?;
Ok(())
}
#[cfg(test)]
mod test {
use crate::utils::files_utils::check_file_name;