diff options
author | Alexander Pyhalov <apyhalov@gmail.com> | 2018-09-07 18:05:20 +0300 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2018-09-13 23:50:01 +0000 |
commit | 002c14a113236969185bd1db508bf126971502be (patch) | |
tree | 76c7381f19129e0ff40099c0731dbd697bd376d4 | |
parent | 286d309c80aad9eac1fdbcb0388ed194d995d837 (diff) | |
download | illumos-joyent-002c14a113236969185bd1db508bf126971502be.tar.gz |
9804 hal-set-property should support --direct option
Reviewed by: Gergő Mihály Doma <domag02@gmail.com>
Reviewed by: Peter Tribble <peter.tribble@gmail.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Robert Mustacchi <rm@joyent.com>
-rw-r--r-- | exception_lists/cstyle | 1 | ||||
-rw-r--r-- | usr/src/cmd/hal/tools/hal_set_property.c | 57 | ||||
-rw-r--r-- | usr/src/man/man1m/hal-get-property.1m | 14 |
3 files changed, 48 insertions, 24 deletions
diff --git a/exception_lists/cstyle b/exception_lists/cstyle index 1c8a67609a..b61995ba08 100644 --- a/exception_lists/cstyle +++ b/exception_lists/cstyle @@ -37,6 +37,7 @@ usr/src/cmd/cmd-inet/usr.lib/mdnsd/anonymous.[ch] usr/src/cmd/cmd-inet/usr.lib/mdnsd/dnssec.h usr/src/cmd/cmd-inet/usr.lib/mdnsd/uDNS.[ch] usr/src/cmd/cmd-inet/usr.lib/mdnsd/uds_daemon.[ch] +usr/src/cmd/hal/tools/hal_set_property.c usr/src/cmd/krb5/kadmin/cli/kadmin_ct.c usr/src/cmd/krb5/kadmin/cli/kadmin.c usr/src/cmd/krb5/kadmin/cli/kadmin.h diff --git a/usr/src/cmd/hal/tools/hal_set_property.c b/usr/src/cmd/hal/tools/hal_set_property.c index 88e3e1d306..afeeb16453 100644 --- a/usr/src/cmd/hal/tools/hal_set_property.c +++ b/usr/src/cmd/hal/tools/hal_set_property.c @@ -73,7 +73,7 @@ usage (int argc, char *argv[]) " (--int <value> | --string <value> | --bool <value> |\n" " --strlist-pre <value> | --strlist-post <value> |\n" " --strlist-rem <value> | --double <value> | --remove)\n" - " [--help] [--version]\n"); + " [--direct] [--help] [--version]\n"); fprintf (stderr, "\n" " --udi Unique Device Id\n" " --key Key of the property to set\n" @@ -88,6 +88,7 @@ usage (int argc, char *argv[]) " --strlist-post Append a string to a list\n" " --strlist-rem Remove a string from a list\n" " --remove Indicates that the property should be removed\n" + " --direct Use direct HAL connection\n" " --version Show version and exit\n" " --help Show this information and exit\n" "\n" @@ -119,6 +120,7 @@ main (int argc, char *argv[]) dbus_bool_t udi_exists = FALSE; int type = PROP_INVALID; DBusError error; + dbus_bool_t direct = FALSE; if (argc <= 1) { usage (argc, argv); @@ -140,12 +142,13 @@ main (int argc, char *argv[]) {"strlist-pre", 1, NULL, 0}, {"strlist-post", 1, NULL, 0}, {"strlist-rem", 1, NULL, 0}, + {"direct", 0, NULL, 0}, {"remove", 0, NULL, 0}, {"version", 0, NULL, 0}, {"help", 0, NULL, 0}, {NULL, 0, NULL, 0} }; - + c = getopt_long (argc, argv, "", long_options, &option_index); if (c == -1) @@ -193,6 +196,8 @@ main (int argc, char *argv[]) type = PROP_STRLIST_REM; } else if (strcmp (opt, "remove") == 0) { remove = TRUE; + } else if (strcmp (opt, "direct") == 0) { + direct = TRUE; } else if (strcmp (opt, "udi") == 0) { udi = strdup (optarg); } else if (strcmp (opt, "version") == 0) { @@ -217,27 +222,35 @@ main (int argc, char *argv[]) usage (argc, argv); return 1; } - + fprintf (stderr, "\n"); - - dbus_error_init (&error); - if ((hal_ctx = libhal_ctx_new ()) == NULL) { - fprintf (stderr, "error: libhal_ctx_new\n"); - return 1; - } - if (!libhal_ctx_set_dbus_connection (hal_ctx, dbus_bus_get (DBUS_BUS_SYSTEM, &error))) { - fprintf (stderr, "error: libhal_ctx_set_dbus_connection: %s: %s\n", error.name, error.message); - LIBHAL_FREE_DBUS_ERROR (&error); - return 1; - } - if (!libhal_ctx_init (hal_ctx, &error)) { - if (dbus_error_is_set(&error)) { - fprintf (stderr, "error: libhal_ctx_init: %s: %s\n", error.name, error.message); + + dbus_error_init (&error); + if (direct) { + if ((hal_ctx = libhal_ctx_init_direct (&error)) == NULL) { + fprintf (stderr, "error: libhal_ctx_init_direct\n"); LIBHAL_FREE_DBUS_ERROR (&error); + return 1; + } + } else { + if ((hal_ctx = libhal_ctx_new ()) == NULL) { + fprintf (stderr, "error: libhal_ctx_new\n"); + return 1; + } + if (!libhal_ctx_set_dbus_connection (hal_ctx, dbus_bus_get (DBUS_BUS_SYSTEM, &error))) { + fprintf (stderr, "error: libhal_ctx_set_dbus_connection: %s: %s\n", error.name, error.message); + LIBHAL_FREE_DBUS_ERROR (&error); + return 1; + } + if (!libhal_ctx_init (hal_ctx, &error)) { + if (dbus_error_is_set(&error)) { + fprintf (stderr, "error: libhal_ctx_init: %s: %s\n", error.name, error.message); + LIBHAL_FREE_DBUS_ERROR (&error); + } + fprintf (stderr, "Could not initialise connection to hald.\n" + "Normally this means the HAL daemon (hald) is not running or not ready.\n"); + return 1; } - fprintf (stderr, "Could not initialise connection to hald.\n" - "Normally this means the HAL daemon (hald) is not running or not ready.\n"); - return 1; } /* check UDI exists */ @@ -249,7 +262,7 @@ main (int argc, char *argv[]) if (dbus_error_is_set(&error)) { fprintf (stderr, "error: libhal_device_exists: %s: %s\n", error.name, error.message); dbus_error_free (&error); - return 1; + return 1; } if (remove) { @@ -300,7 +313,7 @@ main (int argc, char *argv[]) return 1; } } - + return rc ? 0 : 1; } diff --git a/usr/src/man/man1m/hal-get-property.1m b/usr/src/man/man1m/hal-get-property.1m index faeba7318f..f3670ab8dd 100644 --- a/usr/src/man/man1m/hal-get-property.1m +++ b/usr/src/man/man1m/hal-get-property.1m @@ -3,7 +3,7 @@ .\" 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 HAL-GET-PROPERTY 1M "Nov 26, 2017" +.TH HAL-GET-PROPERTY 1M "Sep 7, 2018" .SH NAME hal-get-property, hal-set-property \- get and set HAL device properties .SH SYNOPSIS @@ -18,7 +18,7 @@ hal-get-property, hal-set-property \- get and set HAL device properties \fBhal-set-property\fR \fB--udi\fR \fIudi\fR \fB--key\fR \fIkey\fR {\fB--int\fR \fIvalue\fR | \fB--uint64\fR \fIvalue\fR | \fB--string\fR \fIvalue\fR | \fB--bool\fR \fIvalue\fR | \fB--strlist-pre\fR \fIvalue\fR | \fB--strlist-post\fR \fIvalue\fR | \fB--strlist-rem\fR \fIvalue\fR | \fB--double\fR \fIvalue\fR - | \fB--remove\fR \fIvalue\fR} [\fB--help\fR] [\fB--version\fR] + | \fB--remove\fR \fIvalue\fR} [\fB--direct\fR] [\fB--help\fR] [\fB--version\fR] .fi .SH DESCRIPTION @@ -153,6 +153,16 @@ Indicates that the property should be removed. .sp .ne 2 .na +\fB\fB--direct\fR\fR +.ad +.sp .6 +.RS 4n +Use direct HAL connection +.RE + +.sp +.ne 2 +.na \fB\fB--version\fR\fR .ad .sp .6 |