/mdev

mdev daemon workalike, written in pure rust

Primary LanguageRust

mdev

mdev daemon workalike, written in pure rust

mdev and mdevd are uevent managers, they listen for kernel object userspace events and react according to a set of rules that are coded in their mdev.conf format.

Structure and components

Any uevent manager daemon has 4 primary components:

  • A netlink listener, in our case netlink-sys provides us already some level of abstraction
  • Something that parses the messages encoded in the netlink packets
  • A set of rules on how to react to the events, we use the same mdev.conf format
  • The actual code that reacts to the events according to the rules
    • It matches events with rules
    • [] It executes the actual action and make sure to log the results of it
┌─────────┐                 ┌───────────┐
│ Linux   │ Uevent Packets  │ Netlink   │    UEvents
│  Kernel ├────────────────►│  Listener ├─────────────────┐
│         │                 │           │                 ▼
└─────────┘                 └───────────┘            ┌──────────┐
                                                     │ UEvent   │
                                                     │  Daemon  │
┌───────────┐               ┌───────────┐            └───────┬──┘
│ mdev.conf │ mdev lines    │ Rules     │                 ▲  │
│           ├──────────────►│  Parser   ├─────────────────┘  │
│           │               │           │   Rules            │
└───────────┘               └───────────┘                    ▼
                                                    ┌────────────┐
                                                    │ Actions    │
                                                    └────────────┘