diff --git a/src/agent/src/linux_abi.rs b/src/agent/src/linux_abi.rs index 08600d9f7e..53fabaf0b9 100644 --- a/src/agent/src/linux_abi.rs +++ b/src/agent/src/linux_abi.rs @@ -95,6 +95,7 @@ pub const SYSTEM_DEV_PATH: &str = "/dev"; // Linux UEvent related consts. pub const U_EVENT_ACTION: &str = "ACTION"; pub const U_EVENT_ACTION_ADD: &str = "add"; +pub const U_EVENT_ACTION_REMOVE: &str = "remove"; pub const U_EVENT_DEV_PATH: &str = "DEVPATH"; pub const U_EVENT_SUB_SYSTEM: &str = "SUBSYSTEM"; pub const U_EVENT_SEQ_NUM: &str = "SEQNUM"; diff --git a/src/agent/src/uevent.rs b/src/agent/src/uevent.rs index c5ecefcc19..84e1625f65 100644 --- a/src/agent/src/uevent.rs +++ b/src/agent/src/uevent.rs @@ -97,10 +97,18 @@ impl Uevent { }) } + #[instrument] + async fn process_remove(&self, logger: &Logger, sandbox: &Arc>) { + let mut sb = sandbox.lock().await; + sb.uevent_map.remove(&self.devpath); + } + #[instrument] async fn process(&self, logger: &Logger, sandbox: &Arc>) { if self.action == U_EVENT_ACTION_ADD { return self.process_add(logger, sandbox).await; + } else if self.action == U_EVENT_ACTION_REMOVE { + return self.process_remove(logger, sandbox).await; } debug!(*logger, "ignoring event"; "uevent" => format!("{:?}", self)); }