xref: /dragonfly/usr.sbin/hotplugd/hotplugd.8 (revision dcd37f7d)
1.\"	$OpenBSD: hotplugd.8,v 1.10 2009/03/20 17:53:14 jasper 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 December 5, 2009
18.Dt HOTPLUGD 8
19.Os
20.Sh NAME
21.Nm hotplugd
22.Nd devices hot plugging monitor daemon
23.Sh SYNOPSIS
24.Nm
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, as found in
73.Pa /dev ,
74e.g.\&
75.Pa da1 .
76.Sh FILES
77.Bl -tag -width "/dev/hotplug/attach" -compact
78.It /dev/hotplug
79Pseudo-device file.
80.It /etc/hotplug
81Directory where the scripts to execute are located.
82.It /etc/hotplug/attach
83Script to execute on device attachment.
84.It /etc/hotplug/detach
85Script to execute on device detachment.
86.El
87.Sh EXAMPLES
88Sample
89.Pa attach
90script:
91.Bd -literal -offset indent
92#!/bin/sh
93
94DEVCLASS=$1
95DEVNAME=$2
96
97case $DEVCLASS in
982)
99	# disk devices
100	disklabel=`/sbin/disklabel $DEVNAME 2\*(Gt&1 | \e
101	    sed -n '/^label: /s/^label: //p'`
102	case $disklabel in
103	Sony*DSC*)
104		# Sony DSC camera
105		mount -o nodev,nosuid /dev/"$DEVNAME"i /mnt/camera
106		;;
107	esac
108	;;
1093)
110	# network devices; requires hostname.$DEVNAME
111	sh /etc/netstart $DEVNAME
112	;;
113esac
114.Ed
115.Sh SEE ALSO
116.Xr hotplug 4
117.Sh HISTORY
118The
119.Nm
120program first appeared in
121.Ox 3.6 .
122.Sh AUTHORS
123The
124.Nm
125program was written by
126.An Alexander Yurchenko Aq grange@openbsd.org .
127