1.\" $OpenBSD: hotplugd.8,v 1.13 2015/07/27 17:28:39 sobrado 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: July 27 2015 $ 18.Dt HOTPLUGD 8 19.Os 20.Sh NAME 21.Nm hotplugd 22.Nd devices hot plugging monitor daemon 23.Sh SYNOPSIS 24.Nm hotplugd 25.Op Fl d Ar device 26.Sh DESCRIPTION 27The 28.Nm 29daemon monitors the 30.Xr hotplug 4 31pseudo-device, acting on signaled events by executing the scripts in the 32.Pa /etc/hotplug 33directory. 34By default it uses the 35.Pa /dev/hotplug 36device for reading events from, but an alternative device can be 37specified with the 38.Fl d 39option. 40.Pp 41Actions can be configured either for device attachment or detachment. 42On device attachment the 43.Pa attach 44script is executed if it exists. 45On device detachment the 46.Pa detach 47script is executed if it exists. 48In both cases two parameters are passed to the scripts: the class and name 49of the attached or detached device. 50The device class corresponds to the classes described in the 51.In sys/device.h 52header file and can be one of the following: 53.Pp 54.Bl -tag -width Ds -offset indent -compact 55.It 0 56generic, no special info 57.It 1 58CPU (carries resource utilization) 59.It 2 60disk drive 61.It 3 62network interface 63.It 4 64tape device 65.It 5 66serial line interface 67.El 68.Pp 69Not all classes are really usable. 70For example, it's unlikely that a CPU will be hotplugged. 71.Pp 72The device name is the usual name, 73as listed in 74.Xr MAKEDEV 8 , 75and the unit number, e.g.\& 76.Pa sd1 . 77.Sh FILES 78.Bl -tag -width "/dev/hotplug/attach" -compact 79.It Pa /dev/hotplug 80Pseudo-device file. 81.It Pa /etc/hotplug 82Directory where the scripts to execute are located. 83.It Pa /etc/hotplug/attach 84Script to execute on device attachment. 85.It Pa /etc/hotplug/detach 86Script to execute on device detachment. 87.El 88.Sh EXAMPLES 89Sample 90.Pa attach 91script: 92.Bd -literal -offset indent 93#!/bin/sh 94 95DEVCLASS=$1 96DEVNAME=$2 97 98case $DEVCLASS in 992) 100 # disk devices 101 disklabel=`/sbin/disklabel $DEVNAME 2\*(Gt&1 | \e 102 sed -n '/^label: /s/^label: //p'` 103 case $disklabel in 104 Sony*DSC*) 105 # Sony DSC camera 106 mount -o nodev,nosuid /dev/"$DEVNAME"i /mnt/camera 107 ;; 108 esac 109 ;; 1103) 111 # network devices; requires hostname.$DEVNAME 112 sh /etc/netstart $DEVNAME 113 ;; 114esac 115.Ed 116.Sh SEE ALSO 117.Xr hotplug 4 118.Sh HISTORY 119The 120.Nm 121program first appeared in 122.Ox 3.6 . 123.Sh AUTHORS 124The 125.Nm 126program was written by 127.An Alexander Yurchenko Aq Mt grange@openbsd.org . 128