$OpenBSD: hotplugd.8,v 1.13 2015/07/27 17:28:39 sobrado Exp $

Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org>

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

.Dd $Mdocdate: January 21 2014 $ .Dt HOTPLUGD 8 .Os .Sh NAME .Nm hotplugd .Nd devices hot plugging monitor daemon .Sh SYNOPSIS .Nm hotplugd .Op Fl d Ar device .Sh DESCRIPTION The .Nm daemon monitors the .Xr hotplug 4 pseudo-device, acting on signaled events by executing the scripts in the

a /etc/hotplug directory. By default it uses the

a /dev/hotplug device for reading events from, but an alternative device can be specified with the .Fl d option.

p Actions can be configured either for device attachment or detachment. On device attachment the

a attach script is executed if it exists. On device detachment the

a detach script is executed if it exists. In both cases two parameters are passed to the scripts: the class and name of the attached or detached device. The device class corresponds to the classes described in the n sys/device.h header file and can be one of the following:

p l -tag -width Ds -offset indent -compact t 0 generic, no special info t 1 CPU (carries resource utilization) t 2 disk drive t 3 network interface t 4 tape device t 5 serial line interface .El

p Not all classes are really usable. For example, it's unlikely that a CPU will be hotplugged.

p The device name is the usual name, as listed in .Xr MAKEDEV 8 , and the unit number, e.g.\&

a sd1 . .Sh FILES l -tag -width "/dev/hotplug/attach" -compact t Pa /dev/hotplug Pseudo-device file. t Pa /etc/hotplug Directory where the scripts to execute are located. t Pa /etc/hotplug/attach Script to execute on device attachment. t Pa /etc/hotplug/detach Script to execute on device detachment. .El .Sh EXAMPLES Sample

a attach script: d -literal -offset indent #!/bin/sh DEVCLASS=$1 DEVNAME=$2 case $DEVCLASS in 2) # disk devices disklabel=`/sbin/disklabel $DEVNAME 2\*(Gt&1 | \e sed -n '/^label: /s/^label: //p'` case $disklabel in Sony*DSC*) # Sony DSC camera mount -o nodev,nosuid /dev/"$DEVNAME"i /mnt/camera ;; esac ;; 3) # network devices; requires hostname.$DEVNAME sh /etc/netstart $DEVNAME ;; esac .Ed .Sh SEE ALSO .Xr hotplug 4 .Sh HISTORY The .Nm program first appeared in .Ox 3.6 . .Sh AUTHORS The .Nm program was written by .An Alexander Yurchenko Aq Mt grange@openbsd.org .