Skip to content

Commit

Permalink
ksud: check image before shrink
Browse files Browse the repository at this point in the history
  • Loading branch information
tiann committed Feb 19, 2024
1 parent 81f15ef commit e0802b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion userspace/ksud/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ pub fn run() -> Result<()> {
Module::Enable { id } => module::enable_module(&id),
Module::Disable { id } => module::disable_module(&id),
Module::List => module::list_modules(),
Module::Shrink => module::shrink_image(),
Module::Shrink => module::shrink_ksu_images(),
}
}
Commands::Install => event::install(),
Expand Down
13 changes: 11 additions & 2 deletions userspace/ksud/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,11 +674,20 @@ pub fn list_modules() -> Result<()> {
Ok(())
}

pub fn shrink_image() -> Result<()> {
pub fn shrink_image(img: &str) -> Result<()> {
check_image(img)?;
Command::new("resize2fs")
.arg("-M")
.arg(defs::MODULE_IMG)
.arg(img)
.stdout(Stdio::piped())
.status()?;
Ok(())
}

pub fn shrink_ksu_images() -> Result<()> {
shrink_image(defs::MODULE_IMG)?;
if Path::new(defs::MODULE_UPDATE_IMG).exists() {
shrink_image(defs::MODULE_UPDATE_IMG)?;
}
Ok(())
}

0 comments on commit e0802b0

Please sign in to comment.