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.
Merge pull request ostreedev#261 from cgwalters/tar-split-prep4
bootabletree: New module with helpers for bootable ostree commits
- 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