@@ -288,6 +288,7 @@ enum EntryType {
288288 Directory ( String ) ,
289289 SymbolicLink ( String , String ) ,
290290 HardLink ( String , String ) ,
291+ Unknown ( String , DataKind ) ,
291292}
292293
293294impl EntryType {
@@ -297,7 +298,8 @@ impl EntryType {
297298 EntryType :: File ( name)
298299 | EntryType :: Directory ( name)
299300 | EntryType :: SymbolicLink ( name, _)
300- | EntryType :: HardLink ( name, _) => name,
301+ | EntryType :: HardLink ( name, _)
302+ | EntryType :: Unknown ( name, _) => name,
301303 }
302304 }
303305
@@ -322,6 +324,7 @@ impl Display for EntryTypeBsdLongStyleDisplay<'_> {
322324 EntryType :: HardLink ( name, link_to) => {
323325 write ! ( f, "{name} link to {link_to}" )
324326 }
327+ EntryType :: Unknown ( name, _) => Display :: fmt ( & name, f) ,
325328 }
326329 }
327330}
@@ -451,6 +454,7 @@ impl TableRow {
451454 ) ,
452455 DataKind :: Directory => EntryType :: Directory ( entry. name ( ) . to_string ( ) ) ,
453456 DataKind :: File => EntryType :: File ( entry. name ( ) . to_string ( ) ) ,
457+ kind => EntryType :: Unknown ( entry. name ( ) . to_string ( ) , kind) ,
454458 } ,
455459 // Only collect xattrs if needed
456460 xattrs : if collect. xattrs {
@@ -1081,7 +1085,7 @@ fn detailed_format_name(entry: EntryType, options: &ListOptions) -> String {
10811085 EntryType :: SymbolicLink ( name, link_to) if options. classify => {
10821086 format ! ( "{name}@ -> {link_to}" )
10831087 }
1084- EntryType :: File ( path) | EntryType :: Directory ( path) => path,
1088+ EntryType :: File ( path) | EntryType :: Directory ( path) | EntryType :: Unknown ( path , _ ) => path,
10851089 EntryType :: SymbolicLink ( path, link_to) | EntryType :: HardLink ( path, link_to) => {
10861090 format ! ( "{path} -> {link_to}" )
10871091 }
@@ -1200,6 +1204,7 @@ fn kind_paint(kind: &EntryType) -> impl Display + 'static {
12001204 EntryType :: File ( _) | EntryType :: HardLink ( _, _) => STYLE_HYPHEN . paint ( '.' ) ,
12011205 EntryType :: Directory ( _) => STYLE_DIR . paint ( 'd' ) ,
12021206 EntryType :: SymbolicLink ( _, _) => STYLE_LINK . paint ( 'l' ) ,
1207+ EntryType :: Unknown ( _, _) => STYLE_HYPHEN . paint ( '?' ) ,
12031208 }
12041209}
12051210
@@ -1239,6 +1244,7 @@ const fn kind_char(kind: &EntryType) -> char {
12391244 EntryType :: File ( _) | EntryType :: HardLink ( _, _) => '-' ,
12401245 EntryType :: Directory ( _) => 'd' ,
12411246 EntryType :: SymbolicLink ( _, _) => 'l' ,
1247+ EntryType :: Unknown ( _, _) => '?' ,
12421248 }
12431249}
12441250
@@ -1272,6 +1278,7 @@ impl PermissionDisplay {
12721278 EntryType :: HardLink ( _, _) => 'h' ,
12731279 EntryType :: Directory ( _) => 'd' ,
12741280 EntryType :: SymbolicLink ( _, _) => 'l' ,
1281+ EntryType :: Unknown ( _, _) => '?' ,
12751282 } ,
12761283 permission,
12771284 indicator : if has_acl { '+' } else { ' ' } ,
@@ -1526,6 +1533,7 @@ fn tree_entries_to(
15261533 EntryType :: Directory ( name) => ( name. as_str ( ) , DataKind :: Directory ) ,
15271534 EntryType :: SymbolicLink ( name, _) => ( name. as_str ( ) , DataKind :: SymbolicLink ) ,
15281535 EntryType :: HardLink ( name, _) => ( name. as_str ( ) , DataKind :: HardLink ) ,
1536+ EntryType :: Unknown ( name, kind) => ( name. as_str ( ) , * kind) ,
15291537 } ) ;
15301538 let map = build_tree_map ( entries) ;
15311539 let tree = build_term_tree ( & map, Cow :: Borrowed ( "" ) , None , DataKind :: Directory , options) ;
@@ -1648,6 +1656,26 @@ mod tests {
16481656 ) ;
16491657 }
16501658
1659+ #[ test]
1660+ fn unknown_entry_type_does_not_render_as_file ( ) {
1661+ let entry_type = EntryType :: Unknown ( "private-entry" . into ( ) , DataKind :: Private ( 128 ) ) ;
1662+
1663+ assert_eq ! ( entry_type. name( ) , "private-entry" ) ;
1664+ assert_eq ! (
1665+ entry_type. bsd_long_style_display( ) . to_string( ) ,
1666+ "private-entry"
1667+ ) ;
1668+ assert_eq ! ( kind_char( & entry_type) , '?' ) ;
1669+ assert_eq ! (
1670+ PermissionDisplay :: new( & entry_type, 0o644 , false , false ) . to_string( ) ,
1671+ "?rw-r--r-- "
1672+ ) ;
1673+ assert_eq ! (
1674+ PermissionDisplay :: bsdtar( & entry_type, 0o644 , false ) . to_string( ) ,
1675+ "?rw-r--r-- "
1676+ ) ;
1677+ }
1678+
16511679 #[ test]
16521680 fn i64_max_seconds_exceed_jiff_window ( ) {
16531681 assert ! ( unix_timestamp_to_local_opt( & TimeZone :: UTC , i64 :: MAX , 0 ) . is_none( ) ) ;
0 commit comments