@@ -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 ;
@@ -1344,27 +1345,21 @@ pub(crate) async fn install_to_disk(mut opts: InstallToDiskOpts) -> Result<()> {
1344
1345
#[ context( "Verifying empty rootfs" ) ]
1345
1346
fn require_empty_rootdir ( rootfs_fd : & Dir ) -> Result < ( ) > {
1346
1347
for e in rootfs_fd. entries ( ) ? {
1347
- let e = e?;
1348
- let name = e. file_name ( ) ;
1349
- let name = name
1350
- . to_str ( )
1351
- . ok_or_else ( || anyhow ! ( "Invalid non-UTF8 filename: {name:?}" ) ) ?;
1348
+ let e = DirEntryUtf8 :: from_cap_std ( e?) ;
1349
+ let name = e. file_name ( ) ?;
1352
1350
if name == LOST_AND_FOUND {
1353
1351
continue ;
1354
1352
}
1355
1353
// There must be a boot directory (that is empty)
1356
1354
if name == BOOT {
1357
1355
let mut entries = rootfs_fd. read_dir ( BOOT ) ?;
1358
1356
if let Some ( e) = entries. next ( ) {
1359
- let e = e?;
1360
- let name = e. file_name ( ) ;
1361
- let name = name
1362
- . to_str ( )
1363
- . ok_or_else ( || anyhow ! ( "Invalid non-UTF8 filename: {name:?}" ) ) ?;
1364
- if matches ! ( name, LOST_AND_FOUND | crate :: bootloader:: EFI_DIR ) {
1357
+ let e = DirEntryUtf8 :: from_cap_std ( e?) ;
1358
+ let name = e. file_name ( ) ?;
1359
+ if matches ! ( name. as_str( ) , LOST_AND_FOUND | crate :: bootloader:: EFI_DIR ) {
1365
1360
continue ;
1366
1361
}
1367
- anyhow:: bail!( "Non-empty boot directory, found {name:? }" ) ;
1362
+ anyhow:: bail!( "Non-empty boot directory, found {name}" ) ;
1368
1363
}
1369
1364
} else {
1370
1365
anyhow:: bail!( "Non-empty root filesystem; found {name:?}" ) ;
0 commit comments