update_drv.c revision 0013e2d3ee8df19e750204fa40ded829084c45f8
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe * CDDL HEADER START
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe * The contents of this file are subject to the terms of the
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe * Common Development and Distribution License (the "License").
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe * You may not use this file except in compliance with the License.
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe * See the License for the specific language governing permissions
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe * and limitations under the License.
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe * When distributing Covered Code, include this CDDL HEADER in each
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe * If applicable, add the following below this CDDL HEADER, with the
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe * fields enclosed by brackets "[]" replaced with your own identifying
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe * information: Portions Copyright [yyyy] [name of copyright owner]
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe * CDDL HEADER END
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe * Use is subject to license terms.
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe/* function prototypes */
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowestatic void usage();
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowestatic int unload_drv(char *, int, int);
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe * try to modunload driver.
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe * return -1 on failure and 0 on success
07dc1947c362e187fb955d283b692f8769dd5defRichard Loweunload_drv(char *driver_name, int force_flag, int verbose_flag)
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe (void) fprintf(stderr, gettext(ERR_MODUN), driver_name);
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe /* clean up and exit. remove lock file */
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe return (-1);
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe (void) fprintf(stderr, gettext(UPD_DRV_USAGE));
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe int update_conf = 1; /* reload driver.conf by default */
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe#define TEXT_DOMAIN "SYS_TEST" /* Use this only if it weren't */
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe /* must be run by root */
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe if (getuid() != 0) {
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe while ((opt = getopt(argc, argv, "m:i:b:p:adlfuvP:")) != EOF) {
d_flag++;
force_flag++;
i_flag++;
aliases);
l_flag++;
m_flag++;
verbose_flag++;
usage();
usage();
usage();
usage();
if (l_flag) {
return (NOERR);
/* must be only running version of add_drv/update_drv/rem_drv */
enter_lock();
err_exit();
/* update_drv doesn't modify /etc/name_to_major file */
err_exit();
err_exit();
err_exit();
* i_flag: update /etc/driver_aliases
* m_flag: update /etc/minor_perm
* -p: update /etc/security/device_policy
* -P: update /etc/security/extra_privs
if (a_flag) {
if (m_flag) {
exit_unlock();
return (error);
exit_unlock();
return (error);
if (rval) {
exit_unlock();
return (error);
if (i_flag) {
err_exit();
err_exit();
exit_unlock();
return (error);
goto done;
exit_unlock();
return (error);
exit_unlock();
return (error);
sync();
if (update_conf) {
err_exit();
done:
exit_unlock();
* i_flag: update /etc/driver_aliases
* m_flag: update /etc/minor_perm
* -p: update /etc/security/device_policy
* -P: update /etc/security/extra_privs
if (d_flag) {
if (m_flag) {
if (rval) {
if (rval) {
if (i_flag) {
exit_unlock();
return (err);
err_exit();
* Update driver.conf file:
* be attached devices using the old driver.conf properties,
* so we cannot safely update driver.conf
* The user may specify -f to force a driver.conf update.
* In this case, we will update driver.conf cache. All attached
* devices still reference old driver.conf properties, including
* referent properties in the updated driver.conf file.
if (update_conf) {
err_exit();
if (verbose_flag) {
exit_unlock();
return (NOERR);