File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,25 +65,31 @@ pub fn list() -> io::Result<impl Iterator<Item = io::Result<Device>>> {
6565 Err ( e) => return Some ( Err ( e. into ( ) ) ) ,
6666 } ;
6767
68+ let name = file. file_name ( ) ;
69+ if !DEVICE_PREFIXES
70+ . iter ( )
71+ . any ( |p| name. as_bytes ( ) . starts_with ( p. as_bytes ( ) ) )
72+ {
73+ // Doesn't match any V4L2 device patterns.
74+ return None ;
75+ }
76+
77+ // Sanity check that it's a char device.
6878 match file. file_type ( ) {
6979 Ok ( ty) => {
7080 if !ty. is_char_device ( ) {
71- log:: debug!( "unexpected device file type {:?}" , ty) ;
81+ log:: warn!(
82+ "'{}' is not a character device: {:?}" ,
83+ name. to_string_lossy( ) ,
84+ ty,
85+ ) ;
7286 return None ;
7387 }
7488 }
7589 Err ( e) => return Some ( Err ( e. into ( ) ) ) ,
7690 }
7791
78- let name = file. file_name ( ) ;
79- if DEVICE_PREFIXES
80- . iter ( )
81- . any ( |p| name. as_bytes ( ) . starts_with ( p. as_bytes ( ) ) )
82- {
83- Some ( Device :: open ( & file. path ( ) ) )
84- } else {
85- None
86- }
92+ Some ( Device :: open ( & file. path ( ) ) )
8793 } ) )
8894}
8995
You can’t perform that action at this time.
0 commit comments