Skip to content

Commit 63f593d

Browse files
authored
Merge pull request #689 from cgwalters/bump-cap-std-ext
boundimage: Use new RootDir API
2 parents 2ef07ec + adf6b90 commit 63f593d

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/boundimage.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ use fn_error_context::context;
77
use ostree_ext::ostree::Deployment;
88
use ostree_ext::sysroot::SysrootLock;
99
use rustix::fd::BorrowedFd;
10-
use rustix::fs::{OFlags, ResolveFlags};
11-
use std::fs::File;
12-
use std::io::Read;
13-
use std::os::unix::io::AsFd;
1410

1511
const BOUND_IMAGE_DIR: &str = "usr/lib/bootc-experimental/bound-images.d";
1612

@@ -37,6 +33,9 @@ fn parse_spec_dir(root: &Dir, spec_dir: &str) -> Result<Vec<BoundImage>> {
3733
let Some(bound_images_dir) = root.open_dir_optional(spec_dir)? else {
3834
return Ok(Default::default());
3935
};
36+
// And open a view of the dir that uses RESOLVE_IN_ROOT so we
37+
// handle absolute symlinks.
38+
let absroot = &root.open_dir_rooted_ext(".")?;
4039

4140
let mut bound_images = Vec::new();
4241

@@ -59,19 +58,7 @@ fn parse_spec_dir(root: &Dir, spec_dir: &str) -> Result<Vec<BoundImage>> {
5958

6059
//parse the file contents
6160
let path = Utf8Path::new(spec_dir).join(file_name);
62-
let mut file: File = rustix::fs::openat2(
63-
root.as_fd(),
64-
path.as_std_path(),
65-
OFlags::CLOEXEC | OFlags::RDONLY,
66-
rustix::fs::Mode::empty(),
67-
ResolveFlags::IN_ROOT,
68-
)
69-
.context("Unable to openat")?
70-
.into();
71-
72-
let mut file_contents = String::new();
73-
file.read_to_string(&mut file_contents)
74-
.context("Unable to read file contents")?;
61+
let file_contents = absroot.read_to_string(&path)?;
7562

7663
let file_ini = tini::Ini::from_string(&file_contents).context("Parse to ini")?;
7764
let file_extension = Utf8Path::new(file_name).extension();

0 commit comments

Comments
 (0)