Skip to content

Commit c24672a

Browse files
WhatAmISupposedToPutHereslp
authored andcommitted
Do not assume /dev/input is present
It can be absent when running muvm inside of a container Supersedes: #221 Suggested-by: Zewei Yang <[email protected]> Signed-off-by: Sasha Finkelstein <[email protected]>
1 parent ea73c7c commit c24672a

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

crates/muvm/src/hidpipe_server.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,12 @@ where
283283
pub fn spawn_hidpipe_server(socket_path: PathBuf) -> anyhow::Result<()> {
284284
let mut evdevs = EvdevContainer::new();
285285
let epoll = Epoll::new(EpollCreateFlags::empty()).context("Failed to create epoll object")?;
286-
for dir_ent in
287-
fs::read_dir("/dev/input/").context("Failed to read \"/dev/input/\" directory")?
288-
{
286+
let dir_ents = match fs::read_dir("/dev/input/") {
287+
Ok(dir_ents) => Some(dir_ents),
288+
Err(e) if e.kind() == ErrorKind::NotFound => None,
289+
Err(e) => return Err(e).context("Failed to read /dev/input/ directory"),
290+
};
291+
for dir_ent in dir_ents.into_iter().flatten() {
289292
let dir_ent = dir_ent.context("Failed to read directory entry")?;
290293
if dir_ent
291294
.file_type()

0 commit comments

Comments
 (0)