dumpfs(8): The device name can be longer than 12 chars due to /dev/serno.
[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 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
27 The
28 .Nm
29 daemon monitors the
30 .Xr hotplug 4
31 pseudo-device, acting on signaled events by executing the scripts in the
32 .Pa /etc/hotplug
33 directory.
34 By default it uses the
35 .Pa /dev/hotplug
36 device for reading events from, but an alternative device can be
37 specified with the
38 .Fl d
39 option.
40 .Pp
41 Actions can be configured either for device attachment or detachment.
42 On device attachment the
43 .Pa attach
44 script is executed if it exists.
45 On device detachment the
46 .Pa detach
47 script is executed if it exists.
48 In both cases two parameters are passed to the scripts: the class and name
49 of the attached or detached device.
50 The device class corresponds to the classes described in the
51 .In sys/device.h
52 header file and can be one of the following:
53 .Pp
54 .Bl -tag -width Ds -offset indent -compact
55 .It 0
56 generic, no special info
57 .It 1
58 CPU (carries resource utilization)
59 .It 2
60 disk drive
61 .It 3
62 network interface
63 .It 4
64 tape device
65 .It 5
66 serial line interface
67 .El
68 .Pp
69 Not all classes are really usable.
70 For example, it's unlikely that a CPU will be hotplugged.
71 .Pp
72 The device name is the usual name, as found in
73 .Pa /dev ,
74 e.g.\&
75 .Pa da1 .
76 .Sh FILES
77 .Bl -tag -width "/dev/hotplug/attach" -compact
78 .It /dev/hotplug
79 Pseudo-device file.
80 .It /etc/hotplug
81 Directory where the scripts to execute are located.
82 .It /etc/hotplug/attach
83 Script to execute on device attachment.
84 .It /etc/hotplug/detach
85 Script to execute on device detachment.
86 .El
87 .Sh EXAMPLES
88 Sample
89 .Pa attach
90 script:
91 .Bd -literal -offset indent
92 #!/bin/sh
93
94 DEVCLASS=$1
95 DEVNAME=$2
96
97 case $DEVCLASS in
98 2)
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         ;;
109 3)
110         # network devices; requires hostname.$DEVNAME
111         sh /etc/netstart $DEVNAME
112         ;;
113 esac
114 .Ed
115 .Sh SEE ALSO
116 .Xr hotplug 4
117 .Sh HISTORY
118 The
119 .Nm
120 program first appeared in
121 .Ox 3.6 .
122 .Sh AUTHORS
123 The
124 .Nm
125 program was written by
126 .An Alexander Yurchenko Aq grange@openbsd.org .