1.\" $OpenBSD: hotplug.4,v 1.6 2015/09/14 17:09:26 schwarze Exp $ 2.\" 3.\" Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org> 4.\" 5.\" Permission to use, copy, modify, and distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" 17.Dd $Mdocdate: September 14 2015 $ 18.Dt HOTPLUG 4 19.Os 20.Sh NAME 21.Nm hotplug 22.Nd devices hot plugging 23.Sh SYNOPSIS 24.Cd "pseudo-device hotplug 1" 25.Pp 26.In sys/types.h 27.In sys/device.h 28.In sys/hotplug.h 29.Sh DESCRIPTION 30The 31.Nm 32pseudo-device passes device attachment and detachment events to 33userland. 34When a device attaches or detaches, the corresponding event is queued. 35The events can then be obtained from the queue through the 36.Xr read 2 37call on the 38.Pa /dev/hotplug 39device file. 40Once an event has been read, it's deleted from the queue. 41The event queue has a limited size and if it's full all new events will be 42dropped. 43Each event is described with the following structure declared in the 44.In sys/hotplug.h 45header file: 46.Bd -literal -offset indent 47struct hotplug_event { 48 int he_type; /* event type */ 49 enum devclass he_devclass; /* device class */ 50 char he_devname[16]; /* device name */ 51}; 52 53.Ed 54The 55.Va he_type 56field describes the event type and can be either 57.Dv HOTPLUG_DEVAT 58for device attachment or 59.Dv HOTPLUG_DEVDT 60for detachment. 61The 62.Va he_devclass 63field describes the device class. 64All device classes can be found in the 65.In sys/device.h 66header file: 67.Bd -literal -offset indent 68enum devclass { 69 DV_DULL, /* generic, no special info */ 70 DV_CPU, /* CPU (carries resource utilization) */ 71 DV_DISK, /* disk drive (label, etc) */ 72 DV_IFNET, /* network interface */ 73 DV_TAPE, /* tape device */ 74 DV_TTY /* serial line interface */ 75}; 76 77.Ed 78The 79.Va he_devname 80is a device name including unit number, e.g.\& 81.Pa sd1 . 82.Pp 83Only one structure can be read per call. 84If there are no events in the queue, the 85.Xr read 2 86call will block until an event appears. 87.Sh DIAGNOSTICS 88.Bl -diag 89.It "hotplug: event lost, queue full" 90New events will be dropped until all pending events have been read. 91.El 92.Sh SEE ALSO 93.Xr read 2 , 94.Xr hotplugd 8 95.Sh HISTORY 96The 97.Nm 98device first appeared in 99.Ox 3.6 . 100.Sh AUTHORS 101The 102.Nm 103driver was written by 104.An Alexander Yurchenko Aq Mt grange@openbsd.org . 105