1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
|
'\" te
.\" Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
.\" 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.
.\" 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.
.\" 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]
.TH ADD_DRV 8 "May 13, 2017"
.SH NAME
add_drv \- add a new device driver to the system
.SH SYNOPSIS
.LP
.nf
\fBadd_drv\fR [\fB-b\fR \fIbasedir\fR] [\fB-c\fR \fIclass_name\fR]
[\fB-i\fR '\fIidentify_name\fR...'] [\fB-m\fR '\fIpermission\fR','...']
[\fB-p\fR '\fIpolicy\fR'] [\fB-P\fR \fIprivilege\fR] [\fB-n\fR] [\fB-f\fR] [\fB-v\fR] \fIdevice_driver\fR
.fi
.SH DESCRIPTION
.LP
The \fBadd_drv\fR command is used to inform the system about newly installed
device drivers.
.sp
.LP
Each device on the system has a name associated with it. This name is
represented by the \fBname\fR property for the device. Similarly, the device
may also have a list of driver names associated with it. This list is
represented by the \fBcompatible\fR property for the device.
.sp
.LP
The system determines which devices will be managed by the driver being added
by examining the contents of the \fBname\fR property and the \fBcompatible\fR
property (if it exists) on each device. If the value in the \fBname\fR property
does not match the driver being added, each entry in the \fBcompatible\fR
property is tried, in order, until either a match occurs or there are no more
entries in the \fBcompatible\fR property.
.sp
.LP
In some cases, adding a new driver may require a reconfiguration boot. See the
\fBNOTES\fR section.
.sp
.LP
Aliases might require quoting (with double-quotes) if they contain numbers. See
\fBEXAMPLES\fR.
.SS "The \fB/etc/minor_perm\fR File"
.LP
\fBadd_drv\fR and \fBupdate_drv\fR(8) read the \fB/etc/minor_perm\fR file to
obtain permission information. The permission specified is applied to matching
minor nodes created when a device bound to the driver is attached. A minor
node's permission may be manually changed by \fBchmod\fR(1). For such nodes,
the specified permissions apply, overriding the default permissions specified
via \fBadd_drv\fR or \fBupdate_drv\fR(8).
.sp
.LP
The format of the \fB/etc/minor_perm\fR file is as follows:
.sp
.in +2
.nf
\fIname\fR\fB:\fR\fIminor_name permissions owner group\fR
.fi
.in -2
.sp
.sp
.LP
\fIminor_name\fR may be the actual name of the minor node, or contain shell
metacharacters to represent several minor nodes (see \fBsh\fR(1)).
.sp
.LP
For example:
.sp
.in +2
.nf
sd:* 0640 root sys
zs:[a-z],cu 0600 uucp uucp
mm:kmem 0640 root bin
.fi
.in -2
.sp
.sp
.LP
The first line sets all devices exported by the \fBsd\fR node to \fB0640\fR
permissions, owned by \fBroot\fR, with group \fBsys\fR. In the second line,
devices such as \fBa,cu\fR \fBand\fR \fBz,cu\fR exported by the \fBzs\fR driver
are set to \fB0600\fR permission, owned by \fBuucp\fR, with group \fBuucp\fR.
In the third line the \fBkmem\fR device exported by the \fBmm\fR driver is set
to \fB0640\fR permission, owned by \fBroot\fR, with group \fBbin\fR.
.SS "Running \fBadd_drv\fR from a \fBpostinstall\fR Script"
.LP
When running \fBadd_drv\fR from within the context of a legacy SVR4
package's postinstall
script, you must consider whether the package is being added to a system image
or to a running system. When a package is being installed on a system image,
the \fBBASEDIR\fR variable refers to the image's base directory. In this
situation, \fBadd_drv\fR should be invoked with \fB-b\fR \fB$BASEDIR\fR. This
causes \fBadd_drv\fR only to update the image's system files; a reboot of the
system or client would be required to make the driver operational.
.sp
.LP
When a package is being installed on the running system itself, the system
files need to be updated, as in the case above. However, the running kernel can
be informed of the existence of the new driver without requiring a reboot. To
accomplish this, the postinstall script must invoke \fBadd_drv\fR without the
\fB-b\fR option. Accordingly, \fBpostinstall\fR scripts invoking \fBadd_drv\fR
should be written thusly:
.sp
.in +2
.nf
if [ "${BASEDIR:=/}" = "/" ]
then
ADD_DRV="add_drv"
else
ADD_DRV="add_drv -b ${BASEDIR}"
fi
$ADD_DRV [<options>] \fI<driver>\fR
.fi
.in -2
.sp
.sp
.LP
\&...or, alternatively:
.sp
.in +2
.nf
if [ "${BASEDIR:=/}" != "/" ]
then
BASEDIR_OPT="-b $BASEDIR"
fi
add_drv $BASEDIR_OPT [<options>] \fI<driver>\fR
.fi
.in -2
.sp
.sp
.LP
The \fB-b\fR option is described below.
.SH OPTIONS
.ne 2
.na
\fB\fB-b\fR \fIbasedir\fR\fR
.ad
.RS 26n
Installs the driver on the system with a root directory of \fIbasedir\fR rather
than installing on the system executing \fBadd_drv\fR. This option was typically
used in package post-installation scripts. The system using
\fIbasedir\fR as its root directory must reboot to complete the driver
installation.
.LP
Note -
.sp
.RS 2
The root file system of any non-global zones must not be referenced with the
\fB-b\fR option. Doing so might damage the global zone's file system, might
compromise the security of the global zone, and might damage the non-global
zone's file system. See \fBzones\fR(7).
.RE
.RE
.sp
.ne 2
.na
\fB\fB-c\fR \fIclass_name\fR\fR
.ad
.RS 26n
The driver being added to the system exports the class \fIclass_name\fR.
.RE
.sp
.ne 2
.na
\fB\fB-f\fR\fR
.ad
.RS 26n
Normally if a reconfiguration boot is required to complete the configuration of
the driver into the system, \fBadd_drv\fR will not add the driver. The force
flag forces \fBadd_drv\fR to add the driver even if a reconfiguration boot is
required. See the \fB-v\fR flag.
.RE
.sp
.ne 2
.na
\fB\fB-i\fR \fB\&'\fR\fIidentify_name\fR\fB\&'\fR\fR
.ad
.RS 26n
A white-space separated list of aliases for the driver \fIdevice_driver\fR.
.RE
.sp
.ne 2
.na
\fB\fB-m\fR \fB\&'\fR\fIpermission\fR\fB\&'\fR\fR
.ad
.RS 26n
Specify the file system permissions for device nodes created by the system on
behalf of \fIdevice_driver\fR.
.RE
.sp
.ne 2
.na
\fB\fB-n\fR\fR
.ad
.RS 26n
Do not try to load and attach \fIdevice_driver\fR, just modify the system
configuration files for the \fIdevice_driver\fR.
.RE
.sp
.ne 2
.na
\fB\fB-p\fR '\fIpolicy\fR\fB\&'\fR\fR
.ad
.RS 26n
Specify an additional device security policy.
.sp
The device security policy constists of several whitespace separated tokens:
.sp
.in +2
.nf
{\fIminorspec\fR {token=value}+}+
.fi
.in -2
.sp
\fIminorspec\fR is a simple wildcard pattern for a minor device. A single
\fB*\fR matches all minor devices. Only one \fB*\fR is allowed in the pattern.
.sp
Patterns are matched in the following order:
.RS +4
.TP
.ie t \(bu
.el o
entries without a wildcard
.RE
.RS +4
.TP
.ie t \(bu
.el o
entries with wildcards, longest wildcard first
.RE
The following tokens are defined: \fBread_priv_set\fR and \fBwrite_priv_set\fR.
\fBread_priv_set\fR defines the privileges that need to be asserted in the
effective set of the calling process when opening a device for reading.
\fBwrite_priv_set\fR defines the privileges that need to be asserted in the
effective set of the calling process when opening a device for writing. See
\fBprivileges\fR(7).
.sp
A missing minor spec is interpreted as a \fB*\fR.
.RE
.sp
.ne 2
.na
\fB\fB-P\fR '\fIprivilege\fR\fB\&'\fR\fI\fR\fR
.ad
.RS 26n
Specify additional, comma separated, privileges used by the driver. You can
also use specific privileges in the device's policy.
.RE
.sp
.ne 2
.na
\fB\fB-v\fR\fR
.ad
.RS 26n
The verbose flag causes \fBadd_drv\fR to provide additional information
regarding the success or failure of a driver's configuration into the system.
See the \fBEXAMPLES\fR section.
.RE
.SH EXAMPLES
.LP
\fBExample 1 \fRAdding SUNW Example Driver to the System
.sp
.LP
The following example adds the \fBSUNW,example\fR driver to a 32-bit system,
with an alias name of \fBSUNW,alias\fR. It assumes the driver has already been
copied to \fB/usr/kernel/drv\fR.
.sp
.in +2
.nf
example# add_drv \fB-m\fR '* 0666 bin bin','a 0644 root sys' \e
\fB-p\fR 'a write_priv_set=sys_config * write_priv_set=none' \e
\fB-i\fR 'SUNW,alias' SUNW,example
.fi
.in -2
.sp
.sp
.LP
Every minor node created by the system for the \fBSUNW,example\fR driver will
have the permission \fB0666\fR, and be owned by user \fBbin\fR in the group
\fBbin\fR, except for the minor device \fBa\fR, which will be owned by
\fBroot\fR, group \fBsys\fR, and have a permission of \fB0644\fR. The specified
device policy requires no additional privileges to open all minor nodes, except
minor device \fBa\fR, which requires the \fBsys_config\fR privilege when
opening the device for writing.
.LP
\fBExample 2 \fRAdding Driver to the Client \fB/export/root/sun1\fR
.sp
.LP
The following example adds the driver to the client \fB/export/root/sun1\fR.
The driver is installed and loaded when the client machine, \fBsun1\fR, is
rebooted. This second example produces the same result as the first, except the
changes are on the diskless client, \fBsun1\fR, and the client must be
rebooted for the driver to be installed.
.sp
.in +2
.nf
example# add_drv \fB-m\fR '* 0666 bin bin','a 0644 root sys' \e
\fB-i\fR 'SUNW,alias' -b /export/root/sun1 \e
SUNW,example
.fi
.in -2
.sp
.sp
.LP
See the note in the description of the \fB-b\fR option, above, specifying the
caveat regarding the use of this option with the Solaris zones feature.
.LP
\fBExample 3 \fRAdding Driver for a Device Already Managed by an Existing
Driver
.sp
.LP
The following example illustrates the case where a new driver is added for a
device that is already managed by an existing driver. Consider a device that is
currently managed by the driver \fBdumb_framebuffer\fR. The \fBname\fR and
\fBcompatible\fR properties for this device are as follows:
.sp
.in +2
.nf
name="display"
compatible="whizzy_framebuffer", "dumb_framebuffer"
.fi
.in -2
.sp
.sp
.LP
If \fBadd_drv\fR is used to add the \fBwhizzy_framebuffer\fR driver, the
following will result.
.sp
.in +2
.nf
example# add_drv whizzy_framebuffer
Error: Could not install driver (whizzy_framebuffer)
Device managed by another driver.
.fi
.in -2
.sp
.sp
.LP
If the \fB-v\fR flag is specified, the following will result.
.sp
.in +2
.nf
example# add_drv -v whizzy_framebuffer
Error: Could not install driver (whizzy_framebuffer)
Device managed by another driver.
Driver installation failed because the following
entries in /devices would be affected:
/devices/iommu@f,e0000000/sbus@f,e0001000/display[:*]
(Device currently managed by driver "dumb_framebuffer")
The following entries in /dev would be affected:
/dev/fbs/dumb_framebuffer0
.fi
.in -2
.sp
.sp
.LP
If the \fB-v\fR and \fB-f\fR flags are specified, the driver will be added
resulting in the following.
.sp
.in +2
.nf
example# add_drv -vf whizzy_framebuffer
A reconfiguration boot must be performed to complete the
installation of this driver.
The following entries in /devices will be affected:
/devices/iommu@f,e0000000/sbus@f,e0001000/display[:*]
(Device currently managed by driver "dumb_framebuffer"
The following entries in /dev will be affected:
/dev/fbs/dumb_framebuffer0
.fi
.in -2
.sp
.sp
.LP
The above example is currently only relevant to devices exporting a generic
device name.
.LP
\fBExample 4 \fRUse of Double Quotes in Specifying Driver Alias
.sp
.LP
The following example shows the use of double quotes in specifying a driver
alias that contains numbers.
.sp
.in +2
.nf
example# add_drv -i '"pci10c5,25"' smc
.fi
.in -2
.sp
.SH EXIT STATUS
.LP
\fBadd_drv\fR returns \fB0\fR on success and \fB1\fR on failure.
.SH FILES
.ne 2
.na
\fB\fB/kernel/drv\fR\fR
.ad
.sp .6
.RS 4n
32-bit boot device drivers
.RE
.sp
.ne 2
.na
\fB\fB/kernel/drv/sparcv9\fR\fR
.ad
.sp .6
.RS 4n
64-bit SPARC boot device drivers
.RE
.sp
.ne 2
.na
\fB\fB/kernel/drv/amd64\fR\fR
.ad
.sp .6
.RS 4n
64-bit x86 boot device drivers
.RE
.sp
.ne 2
.na
\fB\fB/usr/kernel/drv\fR\fR
.ad
.sp .6
.RS 4n
other 32-bit drivers that could potentially be shared between platforms
.RE
.sp
.ne 2
.na
\fB\fB/usr/kernel/drv/sparcv9\fR\fR
.ad
.sp .6
.RS 4n
other 64-bit SPARC drivers that could potentially be shared between platforms
.RE
.sp
.ne 2
.na
\fB\fB/usr/kernel/drv/amd64\fR\fR
.ad
.sp .6
.RS 4n
other 64-bit x86 drivers that could potentially be shared between platforms
.RE
.sp
.ne 2
.na
\fB\fB/platform/`uname\fR \fB-i`/kernel/drv\fR\fR
.ad
.sp .6
.RS 4n
32-bit platform-dependent drivers
.RE
.sp
.ne 2
.na
\fB\fB/platform/`uname\fR \fB-i`/kernel/drv/sparcv9\fR\fR
.ad
.sp .6
.RS 4n
64-bit SPARC platform-dependent drivers
.RE
.sp
.ne 2
.na
\fB\fB/platform/`uname\fR \fB-i`/kernel/drv/amd64\fR\fR
.ad
.sp .6
.RS 4n
64-bit x86 platform-dependent drivers
.RE
.sp
.ne 2
.na
\fB\fB/etc/driver_aliases\fR\fR
.ad
.sp .6
.RS 4n
driver aliases file
.RE
.sp
.ne 2
.na
\fB\fB/etc/driver_classes\fR\fR
.ad
.sp .6
.RS 4n
driver classes file
.RE
.sp
.ne 2
.na
\fB\fB/etc/minor_perm\fR\fR
.ad
.sp .6
.RS 4n
minor node permissions
.RE
.sp
.ne 2
.na
\fB\fB/etc/name_to_major\fR\fR
.ad
.sp .6
.RS 4n
major number binding
.RE
.sp
.ne 2
.na
\fB\fB/etc/security/device_policy\fR\fR
.ad
.sp .6
.RS 4n
device policy
.RE
.sp
.ne 2
.na
\fB\fB/etc/security/extra_privs\fR\fR
.ad
.sp .6
.RS 4n
device privileges
.RE
.SH SEE ALSO
.LP
.BR chmod (1),
.BR devfs (4FS),
.BR driver.conf (5),
.BR system (5),
.BR attributes (7),
.BR privileges (7),
.BR boot (8),
.BR devfsadm (8),
.BR kernel (8),
.BR modinfo (8),
.BR rem_drv (8),
.BR update_drv (8),
.BR ddi_create_minor_node (9F)
.sp
.LP
\fI\fR
.SH NOTES
.LP
It is possible to add a driver for a device already being managed by a
different driver, where the driver being added appears in the device's
\fBcompatible\fR list before the current driver. In such cases, a
reconfiguration boot is required (see \fBboot\fR(8) and \fBkernel\fR(8)).
After the reconfiguration boot, device links in \fB/dev\fR and references to
these files may no longer be valid (see the \fB-v\fR flag). If a
reconfiguration boot would be required to complete the driver installation,
\fBadd_drv\fR will fail unless the \fB-f\fR option is specified. See
\fBExample\fR \fB3\fR in the \fBEXAMPLES\fR section.
.sp
.LP
With the introduction of the device policy several drivers have had their minor
permissions changed and a device policy instated. The typical network driver
should use the following device policy:
.sp
.in +2
.nf
add_drv -p 'read_priv_set=net_rawaccess\e
write_priv_set=net_rawaccess' -m '* 666 root sys'\e
mynet
.fi
.in -2
.sp
.sp
.LP
This document does not constitute an API. \fB/etc/minor_perm\fR,
\fB/etc/name_to_major\fR, \fB/etc/driver_classes\fR, and \fB/devices\fR may not
exist or may have different contents or interpretations in a future release.
The existence of this notice does not imply that any other documentation that
lacks this notice constitutes an API.
.sp
.LP
\fB/etc/minor_perm\fR can only be updated by \fBadd_drv\fR(8),
\fBrem_drv\fR(8) or \fBupdate_drv\fR(8).
.sp
.LP
In the current version of \fBadd_drv\fR, the use of double quotes to specify an
alias is optional when used from the command line. However, when using
\fBadd_drv\fR from packaging scripts, you should continue to use double quotes
to specify an alias.
.SH BUGS
.LP
Previous versions of \fBadd_drv\fR accepted a pathname for \fIdevice_driver\fR.
This feature is no longer supported and results in failure.
|