@@ -13,7 +13,7 @@ use regex_automata::{hybrid::dfa, util::syntax, Anchored, Input};
13
13
use crate :: {
14
14
fsverity:: FsVerityHashValue ,
15
15
repository:: Repository ,
16
- tree:: { Directory , FileSystem , ImageError , Inode , Leaf , LeafContent , RegularFile , Stat } ,
16
+ tree:: { Directory , FileSystem , Inode , Leaf , LeafContent , RegularFile , Stat } ,
17
17
} ;
18
18
19
19
/* We build the entire SELinux policy into a single "lazy DFA" such that:
@@ -106,16 +106,18 @@ struct Policy {
106
106
contexts : Vec < String > ,
107
107
}
108
108
109
+ /// Open a file in the composefs store, handling inline vs external files.
109
110
pub fn openat < ' a , H : FsVerityHashValue > (
110
111
dir : & ' a Directory < H > ,
111
112
filename : impl AsRef < OsStr > ,
112
113
repo : & Repository < H > ,
113
114
) -> Result < Option < Box < dyn Read + ' a > > > {
114
- match dir. get_file ( filename. as_ref ( ) ) {
115
- Ok ( RegularFile :: Inline ( data) ) => Ok ( Some ( Box :: new ( & * * data) ) ) ,
116
- Ok ( RegularFile :: External ( id, ..) ) => Ok ( Some ( Box :: new ( File :: from ( repo. open_object ( id) ?) ) ) ) ,
117
- Err ( ImageError :: NotFound ( ..) ) => Ok ( None ) ,
118
- Err ( other) => Err ( other) ?,
115
+ match dir. get_file_opt ( filename. as_ref ( ) ) ? {
116
+ Some ( file) => match file {
117
+ RegularFile :: Inline ( data) => Ok ( Some ( Box :: new ( & * * data) ) ) ,
118
+ RegularFile :: External ( id, ..) => Ok ( Some ( Box :: new ( File :: from ( repo. open_object ( id) ?) ) ) ) ,
119
+ } ,
120
+ None => Ok ( None ) ,
119
121
}
120
122
}
121
123
@@ -248,10 +250,9 @@ fn parse_config(file: impl Read) -> Result<Option<String>> {
248
250
249
251
pub fn selabel < H : FsVerityHashValue > ( fs : & mut FileSystem < H > , repo : & Repository < H > ) -> Result < ( ) > {
250
252
// if /etc/selinux/config doesn't exist then it's not an error
251
- let etc_selinux = match fs. root . get_directory ( "etc/selinux" . as_ref ( ) ) {
252
- Err ( ImageError :: NotFound ( ..) ) => return Ok ( ( ) ) ,
253
- other => other,
254
- } ?;
253
+ let Some ( etc_selinux) = fs. root . get_directory_opt ( "etc/selinux" . as_ref ( ) ) ? else {
254
+ return Ok ( ( ) ) ;
255
+ } ;
255
256
256
257
let Some ( etc_selinux_config) = openat ( etc_selinux, "config" , repo) ? else {
257
258
return Ok ( ( ) ) ;
0 commit comments