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