forked from ostreedev/ostree-rs-ext
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bootabletree: New module with helpers for bootable ostree commits
Right now this only offers an API to find the kernel directory, but I could imagine we do more stuff here in the future. I think this will be generally useful (e.g. ostree and rpm-ostree have duplicate code for this) as is, but it's specifically prep for using this in container layer splitting.
- Loading branch information
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//! Helper functions for bootable OSTrees. | ||
use anyhow::Result; | ||
use ostree::gio; | ||
use ostree::prelude::*; | ||
|
||
const MODULES: &str = "/usr/lib/modules"; | ||
|
||
/// Find the kernel modules directory in a bootable OSTree commit. | ||
pub fn find_kernel_dir( | ||
root: &gio::File, | ||
cancellable: Option<&gio::Cancellable>, | ||
) -> Result<Option<gio::File>> { | ||
let moddir = root.resolve_relative_path(MODULES); | ||
let e = moddir.enumerate_children( | ||
"standard::name", | ||
gio::FileQueryInfoFlags::NOFOLLOW_SYMLINKS, | ||
cancellable, | ||
)?; | ||
let mut r = None; | ||
for child in e.clone() { | ||
let child = &child?; | ||
let childpath = e.child(child); | ||
if child.file_type() == gio::FileType::Directory && r.replace(childpath).is_some() { | ||
anyhow::bail!("Found multiple subdirectories in {}", MODULES); | ||
} | ||
} | ||
Ok(r) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters