Skip to content

Commit 2202c70

Browse files
committed
efi: add drop() before unmounting /boot/efi
Fix error: ``` umount: /boot/efi: target is busy. error: unmount after validate: Failed to unmount "/boot/efi": Child ["umount" "/boot/efi"] exited: exit status: 32 ```
1 parent 2230337 commit 2202c70

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/efi.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::path::{Path, PathBuf};
1010
use std::process::Command;
1111

1212
use anyhow::{bail, Context, Result};
13+
use bootc_utils::CommandRunExt;
1314
use cap_std::fs::Dir;
1415
use cap_std_ext::cap_std;
1516
use fn_error_context::context;
@@ -22,7 +23,7 @@ use widestring::U16CString;
2223
use crate::bootupd::RootContext;
2324
use crate::model::*;
2425
use crate::ostreeutil;
25-
use crate::util::{self, CommandRunExt};
26+
use crate::util;
2627
use crate::{blockdev, filetree};
2728
use crate::{component::*, packagesystem};
2829

@@ -266,14 +267,15 @@ impl Component for Efi {
266267
for esp in esp_devices {
267268
let destpath = &self.ensure_mounted_esp(rootcxt.path.as_ref(), Path::new(&esp))?;
268269

269-
let esp = openat::Dir::open(&destpath.join("EFI")).context("opening EFI dir")?;
270-
validate_esp_fstype(&esp)?;
270+
let efidir = openat::Dir::open(&destpath.join("EFI")).context("opening EFI dir")?;
271+
validate_esp_fstype(&efidir)?;
271272

272273
// For adoption, we should only touch files that we know about.
273-
let diff = updatef.relative_diff_to(&esp)?;
274+
let diff = updatef.relative_diff_to(&efidir)?;
274275
log::trace!("applying adoption diff: {}", &diff);
275-
filetree::apply_diff(&updated, &esp, &diff, None)
276+
filetree::apply_diff(&updated, &efidir, &diff, None)
276277
.context("applying filesystem changes")?;
278+
drop(efidir);
277279
self.unmount().context("unmount after adopt")?;
278280
}
279281
Ok(Some(InstalledContent {
@@ -356,6 +358,7 @@ impl Component for Efi {
356358
log::trace!("applying diff: {}", &diff);
357359
filetree::apply_diff(&updated, &destdir, &diff, None)
358360
.context("applying filesystem changes")?;
361+
drop(destdir);
359362
self.unmount().context("unmount after update")?;
360363
}
361364

@@ -422,7 +425,7 @@ impl Component for Efi {
422425
for esp in esp_devices.iter() {
423426
let destpath = &self.ensure_mounted_esp(Path::new("/"), Path::new(&esp))?;
424427

425-
let efidir = &openat::Dir::open(&destpath.join("EFI"))
428+
let efidir = openat::Dir::open(&destpath.join("EFI"))
426429
.with_context(|| format!("opening EFI dir {}", destpath.display()))?;
427430
let diff = currentf.relative_diff_to(&efidir)?;
428431

@@ -433,6 +436,7 @@ impl Component for Efi {
433436
errs.push(format!("Removed: {}", f));
434437
}
435438
assert_eq!(diff.additions.len(), 0);
439+
drop(efidir);
436440
self.unmount().context("unmount after validate")?;
437441
}
438442

src/util.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::process::Command;
55
use anyhow::{bail, Context, Result};
66
use openat_ext::OpenatDirExt;
77

8+
#[allow(dead_code)]
89
pub(crate) trait CommandRunExt {
910
fn run(&mut self) -> Result<()>;
1011
}

0 commit comments

Comments
 (0)