| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 1M: System Administration Commands Oracle Solaris 11 Information Library |
- add a new device driver to the system
add_drv [-bbasedir] [-cclass_name] [-i 'identify_name...'] [-m 'permission','...'] [-p 'policy'] [-Pprivilege] [-n] [-f] [-u] [-v]device_driver
Theadd_drv command is used to inform the system about newly installeddevice drivers.
Each device on the system has a name associated with it. Thisname is represented by thename property for the device. Similarly, thedevice may also have a list of driver names associated with it.This list is represented by thecompatible property for the device.
The system determines which devices will be managed by the driver beingadded by examining the contents of thename property and thecompatibleproperty (if it exists) on each device. If the value in thename property does not match the driver being added, each entry in thecompatible property is tried, in order, until either a match occurs orthere are no more entries in thecompatible property.
In some cases, adding a new driver may require a reconfiguration boot.See theNOTES section.
Aliases might require quoting (with double-quotes) if they contain numbers. SeeEXAMPLES.
add_drv andupdate_drv(1M) read the/etc/minor_perm file to obtain permission information. Thepermission specified is applied to matching minor nodes created when a device boundto the driver is attached. A minor node's permission may be manuallychanged bychmod(1). For such nodes, the specified permissions apply, overriding the default permissions specified viaadd_drv orupdate_drv(1M).
The format of the/etc/minor_perm file is as follows:
name:minor_name permissions owner group
minor_name may be the actual name of the minor node, or containshell metacharacters to represent several minor nodes (seesh(1)).
For example:
sd:* 0640 root syszs:[a-z],cu 0600 uucp uucpmm:kmem 0640 root bin
The first line sets all devices exported by thesd node to0640 permissions, owned byroot, with groupsys. In the second line,devices such asa,cuandz,cu exported by thezs driver are setto0600 permission, owned byuucp, with groupuucp. In the thirdline thekmem device exported by themm driver is set to0640 permission, owned byroot, with groupbin.
When runningadd_drv from within the context of a package's postinstall script,you must consider whether the package is being added to a systemimage or to a running system. When a package is being installedon a system image, theBASEDIR variable refers to the image's basedirectory. In this situation,add_drv should be invoked with-b$BASEDIR. Thiscausesadd_drv only to update the image's system files; a reboot of thesystem or client would be required to make the driver operational.
When a package is being installed on the running system itself, thesystem files need to be updated, as in the case above. However,the running kernel can be informed of the existence of the newdriver without requiring a reboot. To accomplish this, the postinstall script mustinvokeadd_drv without the-b option. Accordingly,postinstall scripts invokingadd_drv shouldbe written thusly:
if [ "${BASEDIR:=/}" = "/" ]then ADD_DRV="add_drv"else ADD_DRV="add_drv -b ${BASEDIR}"fi$ADD_DRV [<options>]<driver>...or, alternatively:
if [ "${BASEDIR:=/}" != "/" ]then BASEDIR_OPT="-b $BASEDIR"fi add_drv $BASEDIR_OPT [<options>]<driver>The-b option is described below.
Installs the driver on the system with a root directory ofbasedir rather than installing on the system executingadd_drv. This option is typically used in package post-installation scripts when the package is not being installed on the system executing thepkgadd command. The system usingbasedir as its root directory must reboot to complete the driver installation.
Note -The root file system of any non-global zones must not be referenced with the-b 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. Seezones(5).
The driver being added to the system exports the classclass_name.
Normally if a reconfiguration boot is required to complete the configuration of the driver into the system,add_drv will not add the driver. The force flag forcesadd_drv to add the driver even if a reconfiguration boot is required. See the-v flag.
A white-space separated list of aliases for the driverdevice_driver.
Specify the file system permissions for device nodes created by the system on behalf ofdevice_driver.
Do not try to load and attachdevice_driver, just modify the system configuration files for thedevice_driver.
Specify an additional device security policy.
The device security policy constists of several whitespace separated tokens:
{minorspec {token=value}+}+minorspec is a simple wildcard pattern for a minor device. A single* matches all minor devices. Only one* is allowed in the pattern.
Patterns are matched in the following order:
entries without a wildcard
entries with wildcards, longest wildcard first
The following tokens are defined:read_priv_set andwrite_priv_set.read_priv_set defines the privileges that need to be asserted in the effective set of the calling process when opening a device for reading.write_priv_set defines the privileges that need to be asserted in the effective set of the calling process when opening a device for writing. Seeprivileges(5).
A missing minor spec is interpreted as a*.
Specify additional, comma separated, privileges used by the driver. You can also use specific privileges in the device's policy.
Add the driver to the system, leaving it in an inactive state for later configuration withdevfsadm(1M)-u. The-u behavior differs from-n in that-n only updates the system files, requiring a reboot to attach the driver. Drivers added with-u can be attached by runningdevfsadm-u without rebooting. Driver writers should verify their driver with this behavior. SeeNOTES for additional considerations. The-u option cannot be used together with-n or-b.
The verbose flag causesadd_drv to provide additional information regarding the success or failure of a driver's configuration into the system. See theEXAMPLES section.
Example 1 Adding SUNW Example Driver to the System
The following example adds theSUNW,example driver to a 32–bit system, withan alias name ofSUNW,alias. It assumes the driver has already beencopied to/usr/kernel/drv.
example# add_drv-m '* 0666 bin bin','a 0644 root sys' \-p 'a write_priv_set=sys_config * write_priv_set=none' \-i 'SUNW,alias' SUNW,example
Every minor node created by the system for theSUNW,example driver willhave the permission0666, and be owned by userbin in thegroupbin, except for the minor devicea, which will be ownedbyroot, groupsys, and have a permission of0644. The specifieddevice policy requires no additional privileges to open all minor nodes, exceptminor devicea, which requires thesys_config privilege when opening the device forwriting.
Example 2 Adding Driver to the Client/export/root/sun1
The following example adds the driver to the client/export/root/sun1. The driveris installed and loaded when the client machine,sun1, is rebooted. Thissecond example produces the same result as the first, except the changesare on the diskless client,sun1, and the client must be rebootedfor the driver to be installed.
example# add_drv-m '* 0666 bin bin','a 0644 root sys' \-i 'SUNW,alias' -b /export/root/sun1 \ SUNW,example
See the note in the description of the-b option, above, specifyingthe caveat regarding the use of this option with the Solaris zonesfeature.
Example 3 Adding Driver for a Device Already Managed by an Existing Driver
The following example illustrates the case where a new driver is addedfor a device that is already managed by an existing driver. Considera device that is currently managed by the driverdumb_framebuffer. Thenameandcompatible properties for this device are as follows:
name="display"compatible="whizzy_framebuffer", "dumb_framebuffer"
Ifadd_drv is used to add thewhizzy_framebuffer driver, the following willresult.
example# add_drv whizzy_framebufferError: Could not install driver (whizzy_framebuffer)Device managed by another driver.
If the-v flag is specified, the following will result.
example# add_drv -v whizzy_framebufferError: Could not install driver (whizzy_framebuffer)Device managed by another driver.Driver installation failed because the followingentries 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
If the-v and-f flags are specified, the driver will beadded resulting in the following.
example# add_drv -vf whizzy_framebufferA reconfiguration boot must be performed to complete theinstallation 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
The above example is currently only relevant to devices exporting a genericdevice name.
Example 4 Use of Double Quotes in Specifying Driver Alias
The following example shows the use of double quotes in specifying adriver alias that contains numbers.
example# add_drv -i '"pci10c5,25"' smc
add_drv returns0 on success and1 on failure.
32–bit boot device drivers
64–bit SPARC boot device drivers
64–bit x86 boot device drivers
other 32–bit drivers that could potentially be shared between platforms
other 64–bit SPARC drivers that could potentially be shared between platforms
other 64–bit x86 drivers that could potentially be shared between platforms
32–bit platform-dependent drivers
64–bit SPARC platform-dependent drivers
64–bit x86 platform-dependent drivers
driver aliases file
driver classes file
minor node permissions
major number binding
device policy
device privileges
Seeattributes(5) for descriptions of the following attributes:
|
boot(1M),chmod(1),devfsadm(1M),kernel(1M),modinfo(1M),rem_drv(1M),update_drv(1M),driver.conf(4),system(4),attributes(5),privileges(5),devfs(7FS),ddi_create_minor_node(9F)
It is possible to add a driver for a device already beingmanaged by a different driver, where the driver being added appears inthe device'scompatible list before the current driver. In such cases, areconfiguration boot is required (seeboot(1M) andkernel(1M)). After the reconfiguration boot, devicelinks in/dev and references to these files may no longer bevalid (see the-v flag). If a reconfiguration boot would be requiredto complete the driver installation,add_drv will fail unless the-f optionis specified. SeeExample3 in theEXAMPLES section.
With the introduction of the device policy several drivers have had theirminor permissions changed and a device policy instated. The typical network drivershould use the following device policy:
add_drv -p 'read_priv_set=net_rawaccess\ write_priv_set=net_rawaccess' -m '* 666 root sys'\ mynet
This document does not constitute an API./etc/minor_perm,/etc/name_to_major,/etc/driver_classes, and/devicesmay not exist or may have different contents or interpretations in afuture release. The existence of this notice does not imply that any otherdocumentation that lacks this notice constitutes an API.
/etc/minor_perm can only be updated byadd_drv(1M),rem_drv(1M) orupdate_drv(1M).
In the current version ofadd_drv, the use of double quotes tospecify an alias is optional when used from the command line. However,when usingadd_drv from packaging scripts, you should continue to use doublequotes to specify an alias.
Some drivers should not be added and configured on the system directly,but should only be configured as the system boots. The reasons forthis restriction include, but are not limited to, a driver dependency onconfiguration early during boot or a dependency on some kernel component being installedor updated at the same time as the driver is being added.Such drivers should only be added to the system with the-nflag, so the driver is only loaded and configured when the systemis rebooted, thus assuring an environment in which the driver can beconfigured properly.
Previous versions ofadd_drv accepted a pathname fordevice_driver. This feature isno longer supported and results in failure.
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |