HOTPLUG(4)

πŸ“¦ in nixpkgs unstable

πŸ’– HOTPLUG(4) πŸ’–

okay bestie, this one is from the Kernel Interfaces Manual and it's literally about devices hot plugging β€” like when your hardware just shows up or ghosts you, and Unix is like "noted πŸ’…".


✨ NAME ✨

hotplug β€” devices hot plugging

like… the whole vibe is "device comes in, device leaves, and we're keeping receipts"


πŸ¦‹ SYNOPSIS πŸ¦‹

pseudo-device hotplug 1

#include <sys/types.h>
#include <sys/device.h>
#include <sys/hotplug.h>

🌸 DESCRIPTION 🌸

The hotplug pseudo-device passes device attachment and detachment events to userland. fr fr, that's its whole job. When a device attaches or detaches, the corresponding event is queued β€” like it's sliding into your DMs. The events can then be obtained from the queue through the read(2) call on the /dev/hotplug device file. Once an event has been read, it's deleted from the queue. periodt. The event queue has a limited size and if it's full all new events will be dropped β€” so yeah, it's giving "capacity issues, don't @ me" 😭. Each event is described with the following structure declared in the <sys/hotplug.h> header file:

struct hotplug_event {
        int             he_type;        /* event type           */
        enum devclass   he_devclass;    /* device class         */
        char            he_devname[16]; /* device name          */
};

The he_type field describes the event type and can be either HOTPLUG_DEVAT for device attachment or HOTPLUG_DEVDT for detachment. The he_devclass field describes the device class. All device classes can be found in the <sys/device.h> header file:

enum devclass {
        DV_DULL,        /* generic, no special info */
        DV_CPU,         /* CPU (carries resource utilization) */
        DV_DISK,        /* disk drive (label, etc) */
        DV_IFNET,       /* network interface */
        DV_TAPE,        /* tape device */
        DV_TTY          /* serial line interface */
};

The he_devname is a device name including unit number, e.g. sd1.

Only one structure can be read per call. one. singular. no bundling bestie πŸ™ˆ. If there are no events in the queue, the read(2) call will block until an event appears β€” so it's just gonna sit there and wait, main character energy of "I'm not leaving until something happens".


πŸ’€ DIAGNOSTICS πŸ’€

  • hotplug: event lost, queue full β€” New events will be dropped until all pending events have been read.

like the queue is literally full and it's turning people away at the door 🫢


πŸ”₯ SEE ALSO πŸ”₯


🌈 HISTORY 🌈

The hotplug device first appeared in OpenBSD 3.6. an icon, a legend, a moment in time ⭐


πŸ‘‘ AUTHORS πŸ‘‘

The hotplug driver was written by Alexander Yurchenko <grange@openbsd.org>. we stan a kernel dev πŸ’œ


and that's the tea, bestie πŸŽ€ this page was brought to you by Debian, dated September 14, 2015, and filed under HOTPLUG(4) β€” go read some read(2) docs and slay βœ¨πŸ’…

πŸ“¦ where this page comes from
  • nixpkgs unstable: cvs-export
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms