@@ -25,6 +25,7 @@ use camino::Utf8Path;
25
25
use camino:: Utf8PathBuf ;
26
26
use cap_std:: fs:: { Dir , MetadataExt } ;
27
27
use cap_std_ext:: cap_std;
28
+ use cap_std_ext:: cap_std:: fs_utf8:: DirEntry as DirEntryUtf8 ;
28
29
use cap_std_ext:: prelude:: CapStdExtDirExt ;
29
30
use chrono:: prelude:: * ;
30
31
use clap:: ValueEnum ;
@@ -1343,27 +1344,21 @@ pub(crate) async fn install_to_disk(mut opts: InstallToDiskOpts) -> Result<()> {
1343
1344
#[ context( "Verifying empty rootfs" ) ]
1344
1345
fn require_empty_rootdir ( rootfs_fd : & Dir ) -> Result < ( ) > {
1345
1346
for e in rootfs_fd. entries ( ) ? {
1346
- let e = e?;
1347
- let name = e. file_name ( ) ;
1348
- let name = name
1349
- . to_str ( )
1350
- . ok_or_else ( || anyhow ! ( "Invalid non-UTF8 filename: {name:?}" ) ) ?;
1347
+ let e = DirEntryUtf8 :: from_cap_std ( e?) ;
1348
+ let name = e. file_name ( ) ?;
1351
1349
if name == LOST_AND_FOUND {
1352
1350
continue ;
1353
1351
}
1354
1352
// There must be a boot directory (that is empty)
1355
1353
if name == BOOT {
1356
1354
let mut entries = rootfs_fd. read_dir ( BOOT ) ?;
1357
1355
if let Some ( e) = entries. next ( ) {
1358
- let e = e?;
1359
- let name = e. file_name ( ) ;
1360
- let name = name
1361
- . to_str ( )
1362
- . ok_or_else ( || anyhow ! ( "Invalid non-UTF8 filename: {name:?}" ) ) ?;
1363
- if matches ! ( name, LOST_AND_FOUND | crate :: bootloader:: EFI_DIR ) {
1356
+ let e = DirEntryUtf8 :: from_cap_std ( e?) ;
1357
+ let name = e. file_name ( ) ?;
1358
+ if matches ! ( name. as_str( ) , LOST_AND_FOUND | crate :: bootloader:: EFI_DIR ) {
1364
1359
continue ;
1365
1360
}
1366
- anyhow:: bail!( "Non-empty boot directory, found {name:? }" ) ;
1361
+ anyhow:: bail!( "Non-empty boot directory, found {name}" ) ;
1367
1362
}
1368
1363
} else {
1369
1364
anyhow:: bail!( "Non-empty root filesystem; found {name:?}" ) ;
0 commit comments