Skip to content

Commit c4916c1

Browse files
committed
Add helper function to write reboot-required message
This change adds a helper function that will allow us to write a message to /run/reboot-required after bootc operations that require a reboot. Fixes #1574 Signed-off-by: Brendan Shephard <[email protected]>
1 parent 310f9f5 commit c4916c1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

crates/lib/src/store/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ pub const COMPOSEFS_MODE: Mode = Mode::from_raw_mode(0o700);
4949
/// system root
5050
pub(crate) const BOOTC_ROOT: &str = "ostree/bootc";
5151

52+
/// The path for the reboot-required file, relative to the system
53+
/// root
54+
pub(crate) const REBOOT_REQUIRED: &str = "run/reboot-required";
55+
56+
/// Reboot required message that will appear in /run/reboot-required
57+
pub(crate) const REBOOT_REQUIRED_MESSAGE: &[u8] = b"Reboot required to complete bootc operation";
58+
5259
/// A reference to a physical filesystem root, plus
5360
/// accessors for the different types of container storage.
5461
pub(crate) struct Storage {
@@ -175,4 +182,18 @@ impl Storage {
175182
.update_timestamps(std::path::Path::new(BOOTC_ROOT))
176183
.context("update_timestamps")
177184
}
185+
186+
#[context("Updating the reboot-required file")]
187+
pub(crate) fn update_reboot_file(&self) -> Result<()> {
188+
let sysroot_dir =
189+
crate::utils::sysroot_dir(&self.ostree).context("Reopen sysroot directory")?;
190+
191+
sysroot_dir
192+
.write(
193+
std::path::Path::new(REBOOT_REQUIRED),
194+
REBOOT_REQUIRED_MESSAGE,
195+
)
196+
.context("Bootc reboot required")
197+
.map_err(Into::into)
198+
}
178199
}

0 commit comments

Comments
 (0)