293 useradd/del/mod should be ZFS-aware
[illumos-gate.git] / usr / src / man / man1m / add_drv.1m
blobc0172803171d1c6e26e42d787086891d9bb69fba
1 '\" te
2 .\"  Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH ADD_DRV 1M "Dec 1, 2005"
7 .SH NAME
8 add_drv \- add a new device driver to the system
9 .SH SYNOPSIS
10 .LP
11 .nf
12 \fBadd_drv\fR [\fB-b\fR \fIbasedir\fR] [\fB-c\fR \fIclass_name\fR]
13      [\fB-i\fR '\fIidentify_name\fR...'] [\fB-m\fR '\fIpermission\fR','...']
14      [\fB-p\fR '\fIpolicy\fR'] [\fB-P\fR \fIprivilege\fR] [\fB-n\fR] [\fB-f\fR] [\fB-v\fR] \fIdevice_driver\fR
15 .fi
17 .SH DESCRIPTION
18 .sp
19 .LP
20 The \fBadd_drv\fR command is used to inform the system about newly installed
21 device drivers.
22 .sp
23 .LP
24 Each device on the system has a name associated with it. This name is
25 represented by the \fBname\fR property for the device. Similarly, the device
26 may also have a list of driver names associated with it. This list is
27 represented by the \fBcompatible\fR property for the device.
28 .sp
29 .LP
30 The system determines which devices will be managed by the driver being added
31 by examining the contents of the \fBname\fR property and the \fBcompatible\fR
32 property (if it exists) on each device. If the value in the \fBname\fR property
33 does not match the driver being added, each entry in the \fBcompatible\fR
34 property is tried, in order, until either a match occurs or there are no more
35 entries in the \fBcompatible\fR property.
36 .sp
37 .LP
38 In some cases, adding a new driver may require a reconfiguration boot. See the
39 \fBNOTES\fR section.
40 .sp
41 .LP
42 Aliases might require quoting (with double-quotes) if they contain numbers. See
43 \fBEXAMPLES\fR.
44 .SS "The \fB/etc/minor_perm\fR File"
45 .sp
46 .LP
47 \fBadd_drv\fR and \fBupdate_drv\fR(1M) read the \fB/etc/minor_perm\fR file to
48 obtain permission information. The permission specified is applied to matching
49 minor nodes created when a device bound to the driver is attached. A minor
50 node's permission may be manually changed by \fBchmod\fR(1). For such nodes,
51 the specified permissions apply, overriding the default permissions specified
52 via \fBadd_drv\fR or \fBupdate_drv\fR(1M).
53 .sp
54 .LP
55 The format of the \fB/etc/minor_perm\fR file is as follows:
56 .sp
57 .in +2
58 .nf
59 \fIname\fR\fB:\fR\fIminor_name permissions owner group\fR
60 .fi
61 .in -2
62 .sp
64 .sp
65 .LP
66 \fIminor_name\fR may be the actual name of the minor node, or contain shell
67 metacharacters to represent several minor nodes (see \fBsh\fR(1)).
68 .sp
69 .LP
70 For example:
71 .sp
72 .in +2
73 .nf
74 sd:* 0640 root sys
75 zs:[a-z],cu 0600 uucp uucp
76 mm:kmem 0640 root bin
77 .fi
78 .in -2
79 .sp
81 .sp
82 .LP
83 The first line sets all devices exported by the \fBsd\fR node to \fB0640\fR
84 permissions, owned by \fBroot\fR, with group \fBsys\fR. In the second line,
85 devices such as \fBa,cu\fR \fBand\fR \fBz,cu\fR exported by the \fBzs\fR driver
86 are set to \fB0600\fR permission, owned by \fBuucp\fR, with group \fBuucp\fR.
87 In the third line the \fBkmem\fR device exported by the \fBmm\fR driver is set
88 to \fB0640\fR permission, owned by \fBroot\fR, with group \fBbin\fR.
89 .SS "Running \fBadd_drv\fR from a \fBpostinstall\fR Script"
90 .sp
91 .LP
92 When running \fBadd_drv\fR from within the context of a package's postinstall
93 script, you must consider whether the package is being added to a system image
94 or to a running system. When a package is being installed on a system image,
95 the \fBBASEDIR\fR variable refers to the image's base directory. In this
96 situation, \fBadd_drv\fR should be invoked with \fB-b\fR \fB$BASEDIR\fR. This
97 causes \fBadd_drv\fR only to update the image's system files; a reboot of the
98 system or client would be required to make the driver operational.
99 .sp
101 When a package is being installed on the running system itself, the system
102 files need to be updated, as in the case above. However, the running kernel can
103 be informed of the existence of the new driver without requiring a reboot. To
104 accomplish this, the postinstall script must invoke \fBadd_drv\fR without the
105 \fB-b\fR option. Accordingly, \fBpostinstall\fR scripts invoking \fBadd_drv\fR
106 should be written thusly:
108 .in +2
110 if [ "${BASEDIR:=/}" = "/" ]
111 then
112         ADD_DRV="add_drv"
113 else
114         ADD_DRV="add_drv -b ${BASEDIR}"
116 $ADD_DRV [<options>] \fI<driver>\fR
118 .in -2
123 \&...or, alternatively:
125 .in +2
127 if [ "${BASEDIR:=/}" != "/" ]
128 then
129          BASEDIR_OPT="-b $BASEDIR"
131          add_drv $BASEDIR_OPT [<options>] \fI<driver>\fR
133 .in -2
138 The \fB-b\fR option is described below.
139 .SH OPTIONS
141 .ne 2
143 \fB\fB-b\fR \fIbasedir\fR\fR
145 .RS 26n
146 Installs the driver on the system with a root directory of \fIbasedir\fR rather
147 than installing on the system executing \fBadd_drv\fR. This option is typically
148 used in package post-installation scripts when the package is not being
149 installed on the system executing the \fBpkgadd\fR command. The system using
150 \fIbasedir\fR as its root directory must reboot to complete the driver
151 installation.
153 Note -
155 .RS 2
156 The root file system of any non-global zones must not be referenced with the
157 \fB-b\fR option. Doing so might damage the global zone's file system, might
158 compromise the security of the global zone, and might damage the non-global
159 zone's file system. See \fBzones\fR(5).
164 .ne 2
166 \fB\fB-c\fR \fIclass_name\fR\fR
168 .RS 26n
169 The driver being added to the system exports the class \fIclass_name\fR.
173 .ne 2
175 \fB\fB-f\fR\fR
177 .RS 26n
178 Normally if a reconfiguration boot is required to complete the configuration of
179 the driver into the system, \fBadd_drv\fR will not add the driver. The force
180 flag forces \fBadd_drv\fR to add the driver even if a reconfiguration boot is
181 required. See the \fB-v\fR flag.
185 .ne 2
187 \fB\fB-i\fR \fB\&'\fR\fIidentify_name\fR\fB\&'\fR\fR
189 .RS 26n
190 A white-space separated list of aliases for the driver \fIdevice_driver\fR.
194 .ne 2
196 \fB\fB-m\fR \fB\&'\fR\fIpermission\fR\fB\&'\fR\fR
198 .RS 26n
199 Specify the file system permissions for device nodes created by the system on
200 behalf of \fIdevice_driver\fR.
204 .ne 2
206 \fB\fB-n\fR\fR
208 .RS 26n
209 Do not try to load and attach \fIdevice_driver\fR, just modify the system
210 configuration files for the \fIdevice_driver\fR.
214 .ne 2
216 \fB\fB-p\fR '\fIpolicy\fR\fB\&'\fR\fR
218 .RS 26n
219 Specify an additional device security policy.
221 The device security policy constists of several whitespace separated tokens:
223 .in +2
225 {\fIminorspec\fR {token=value}+}+
227 .in -2
230 \fIminorspec\fR is a simple wildcard pattern for a minor device. A single
231 \fB*\fR matches all minor devices. Only one \fB*\fR is allowed in the pattern.
233 Patterns are matched in the following order:
234 .RS +4
236 .ie t \(bu
237 .el o
238 entries without a wildcard
240 .RS +4
242 .ie t \(bu
243 .el o
244 entries with wildcards, longest wildcard first
246 The following tokens are defined: \fBread_priv_set\fR and \fBwrite_priv_set\fR.
247 \fBread_priv_set\fR defines the privileges that need to be asserted in the
248 effective set of the calling process when opening a device for reading.
249 \fBwrite_priv_set\fR defines the privileges that need to be asserted in the
250 effective set of the calling process when opening a device for writing. See
251 \fBprivileges\fR(5).
253 A missing minor spec is interpreted as a \fB*\fR.
257 .ne 2
259 \fB\fB-P\fR '\fIprivilege\fR\fB\&'\fR\fI\fR\fR
261 .RS 26n
262 Specify additional, comma separated, privileges used by the driver. You can
263 also use specific privileges in the device's policy.
267 .ne 2
269 \fB\fB-v\fR\fR
271 .RS 26n
272 The verbose flag causes \fBadd_drv\fR to provide additional information
273 regarding the success or failure of a driver's configuration into the system.
274 See the \fBEXAMPLES\fR section.
277 .SH EXAMPLES
279 \fBExample 1 \fRAdding SUNW Example Driver to the System
282 The following example adds the \fBSUNW,example\fR driver to a 32-bit system,
283 with an alias name of \fBSUNW,alias\fR. It assumes the driver has already been
284 copied to \fB/usr/kernel/drv\fR.
287 .in +2
289 example# add_drv \fB-m\fR '* 0666 bin bin','a 0644 root sys' \e
290       \fB-p\fR 'a write_priv_set=sys_config  * write_priv_set=none' \e
291       \fB-i\fR 'SUNW,alias' SUNW,example
293 .in -2
298 Every minor node created by the system for the \fBSUNW,example\fR driver will
299 have the permission \fB0666\fR, and be owned by user \fBbin\fR in the group
300 \fBbin\fR, except for the minor device \fBa\fR, which will be owned by
301 \fBroot\fR, group \fBsys\fR, and have a permission of \fB0644\fR. The specified
302 device policy requires no additional privileges to open all minor nodes, except
303 minor device \fBa\fR, which requires the \fBsys_config\fR privilege when
304 opening the device for writing.
307 \fBExample 2 \fRAdding Driver to the Client \fB/export/root/sun1\fR
310 The following example adds the driver to the client \fB/export/root/sun1\fR.
311 The driver is installed and loaded when the client machine, \fBsun1\fR, is
312 rebooted. This second example produces the same result as the first, except the
313 changes are on the diskless client,  \fBsun1\fR, and the client must be
314 rebooted for the driver to be installed.
317 .in +2
319 example# add_drv \fB-m\fR '* 0666 bin bin','a 0644 root sys' \e
320         \fB-i\fR 'SUNW,alias' -b /export/root/sun1 \e
321         SUNW,example
323 .in -2
328 See the note in the description of the \fB-b\fR option, above, specifying the
329 caveat regarding the use of this option with the Solaris zones feature.
332 \fBExample 3 \fRAdding Driver for a Device Already Managed by an Existing
333 Driver
336 The following example illustrates the case where a new driver is added for a
337 device that is already managed by an existing driver. Consider a device that is
338 currently managed by the driver \fBdumb_framebuffer\fR. The \fBname\fR and
339 \fBcompatible\fR properties for this device are as follows:
342 .in +2
344 name="display"
345 compatible="whizzy_framebuffer", "dumb_framebuffer"
347 .in -2
352 If \fBadd_drv\fR is used to add the \fBwhizzy_framebuffer\fR driver, the
353 following will result.
356 .in +2
358 example# add_drv whizzy_framebuffer
359 Error: Could not install driver (whizzy_framebuffer)
360 Device managed by another driver.
362 .in -2
367 If the \fB-v\fR flag is specified, the following will result.
370 .in +2
372 example# add_drv -v whizzy_framebuffer
373 Error: Could not install driver (whizzy_framebuffer)
374 Device managed by another driver.
375 Driver installation failed because the following
376 entries in /devices would be affected:
378         /devices/iommu@f,e0000000/sbus@f,e0001000/display[:*]
379         (Device currently managed by driver "dumb_framebuffer")
381 The following entries in /dev would be affected:
383         /dev/fbs/dumb_framebuffer0
385 .in -2
390 If the \fB-v\fR and \fB-f\fR flags are specified, the driver will be added
391 resulting in the following.
394 .in +2
396 example# add_drv -vf whizzy_framebuffer
397 A reconfiguration boot must be performed to complete the
398 installation of this driver.
400 The following entries in /devices will be affected:
402         /devices/iommu@f,e0000000/sbus@f,e0001000/display[:*]
403         (Device currently managed by driver "dumb_framebuffer"
405 The following entries in /dev will be affected:
407         /dev/fbs/dumb_framebuffer0
409 .in -2
414 The above example is currently only relevant to devices exporting a generic
415 device name.
418 \fBExample 4 \fRUse of Double Quotes in Specifying Driver Alias
421 The following example shows the use of double quotes in specifying a driver
422 alias that contains numbers.
425 .in +2
427 example# add_drv -i '"pci10c5,25"' smc
429 .in -2
432 .SH EXIT STATUS
435 \fBadd_drv\fR returns \fB0\fR on success and \fB1\fR on failure.
436 .SH FILES
438 .ne 2
440 \fB\fB/kernel/drv\fR\fR
442 .sp .6
443 .RS 4n
444 32-bit boot device drivers
448 .ne 2
450 \fB\fB/kernel/drv/sparcv9\fR\fR
452 .sp .6
453 .RS 4n
454 64-bit SPARC boot device drivers
458 .ne 2
460 \fB\fB/kernel/drv/amd64\fR\fR
462 .sp .6
463 .RS 4n
464 64-bit x86 boot device drivers
468 .ne 2
470 \fB\fB/usr/kernel/drv\fR\fR
472 .sp .6
473 .RS 4n
474 other 32-bit drivers that could potentially be shared between platforms
478 .ne 2
480 \fB\fB/usr/kernel/drv/sparcv9\fR\fR
482 .sp .6
483 .RS 4n
484 other 64-bit SPARC drivers that could potentially be shared between platforms
488 .ne 2
490 \fB\fB/usr/kernel/drv/amd64\fR\fR
492 .sp .6
493 .RS 4n
494 other 64-bit x86 drivers that could potentially be shared between platforms
498 .ne 2
500 \fB\fB/platform/`uname\fR \fB-i`/kernel/drv\fR\fR
502 .sp .6
503 .RS 4n
504 32-bit platform-dependent drivers
508 .ne 2
510 \fB\fB/platform/`uname\fR \fB-i`/kernel/drv/sparcv9\fR\fR
512 .sp .6
513 .RS 4n
514 64-bit SPARC platform-dependent drivers
518 .ne 2
520 \fB\fB/platform/`uname\fR \fB-i`/kernel/drv/amd64\fR\fR
522 .sp .6
523 .RS 4n
524 64-bit x86 platform-dependent drivers
528 .ne 2
530 \fB\fB/etc/driver_aliases\fR\fR
532 .sp .6
533 .RS 4n
534 driver aliases file
538 .ne 2
540 \fB\fB/etc/driver_classes\fR\fR
542 .sp .6
543 .RS 4n
544 driver classes file
548 .ne 2
550 \fB\fB/etc/minor_perm\fR\fR
552 .sp .6
553 .RS 4n
554 minor node permissions
558 .ne 2
560 \fB\fB/etc/name_to_major\fR\fR
562 .sp .6
563 .RS 4n
564 major number binding
568 .ne 2
570 \fB\fB/etc/security/device_policy\fR\fR
572 .sp .6
573 .RS 4n
574 device policy
578 .ne 2
580 \fB\fB/etc/security/extra_privs\fR\fR
582 .sp .6
583 .RS 4n
584 device privileges
587 .SH SEE ALSO
590 \fBboot\fR(1M), \fBchmod\fR(1), \fBdevfsadm\fR(1M), \fBkernel\fR(1M),
591 \fBmodinfo\fR(1M), \fBrem_drv\fR(1M), \fBupdate_drv\fR(1M),
592 \fBdriver.conf\fR(4), \fBsystem\fR(4), \fBattributes\fR(5),
593 \fBprivileges\fR(5), \fBdevfs\fR(7FS), \fBddi_create_minor_node\fR(9F)
596 \fI\fR
597 .SH NOTES
600 It is possible to add a driver for a device already being managed by a
601 different driver, where the driver being added appears in the device's
602 \fBcompatible\fR list before the current driver. In such cases, a
603 reconfiguration boot is required (see \fBboot\fR(1M) and \fBkernel\fR(1M)).
604 After the reconfiguration boot, device links in \fB/dev\fR and references to
605 these files may no longer be valid (see the \fB-v\fR flag). If a
606 reconfiguration boot would be required to complete the driver installation,
607 \fBadd_drv\fR will fail unless the \fB-f\fR option is specified. See
608 \fBExample\fR \fB3\fR in the \fBEXAMPLES\fR section.
611 With the introduction of the device policy several drivers have had their minor
612 permissions changed and a device policy instated. The typical network driver
613 should use the following device policy:
615 .in +2
617 add_drv -p 'read_priv_set=net_rawaccess\e
618    write_priv_set=net_rawaccess' -m '* 666 root sys'\e
619    mynet
621 .in -2
626 This document does not constitute an API. \fB/etc/minor_perm\fR,
627 \fB/etc/name_to_major\fR, \fB/etc/driver_classes\fR, and \fB/devices\fR may not
628 exist or may have different contents or interpretations in a future release.
629 The existence of this notice does not imply that any other documentation that
630 lacks this notice constitutes an API.
633 \fB/etc/minor_perm\fR can only be updated by \fBadd_drv\fR(1M),
634 \fBrem_drv\fR(1M) or \fBupdate_drv\fR(1M).
637 In the current version of \fBadd_drv\fR, the use of double quotes to specify an
638 alias is optional when used from the command line. However, when using
639 \fBadd_drv\fR from packaging scripts, you should continue to use double quotes
640 to specify an alias.
641 .SH BUGS
644 Previous versions of \fBadd_drv\fR accepted a pathname for \fIdevice_driver\fR.
645 This feature is no longer supported and results in failure.