summaryrefslogtreecommitdiff
path: root/usr/src/cmd/devprop/devprop.c
diff options
context:
space:
mode:
authorjohnlev <none@none>2007-09-18 15:46:43 -0700
committerjohnlev <none@none>2007-09-18 15:46:43 -0700
commit843e19887f64dde75055cf8842fc4db2171eff45 (patch)
tree4ab8a445a86736e31e88b22413d080cc29f89aa0 /usr/src/cmd/devprop/devprop.c
parent3d318c665ed0c4b4170851459cc58b3386bfec9b (diff)
downloadillumos-joyent-843e19887f64dde75055cf8842fc4db2171eff45.tar.gz
PSARC 2006/260 Solaris on Xen
PSARC 2007/155 IPv4 Network Configuration Enhancements for Xen Guest Domains 6424124 panic in intr_thread->av_dispatch_autovect->atomic_add_ptr 6496858 mdb could use a memory-based IO backend 6515319 workaround for 6491065 needs to be removed from elfextract.c 6518807 snv_nightly: SUNWcakr pkgck error 6551858 PSARC 2006/260 Solaris on Xen 6584697 Can't boot Xen / Solaris dom0 if root is using ZFS 6593429 usr/src/cmd/devfsadm isn't linting properly 6600359 mdb_kvm_intrframe() is unused 6600750 can remove 'u' workaround from zlib 6601465 /dev/lofictl needs to accept kernel ioctl 6604043 Erronous ASSERT in sdev_vnops.c ASSERT(VTOSDEV(vp)->sdev_attrvp); --HG-- rename : usr/src/common/util/memset.h => deleted_files/usr/src/common/util/memset.h rename : usr/src/uts/common/krtld/mapfile => deleted_files/usr/src/uts/common/krtld/mapfile rename : usr/src/uts/i86pc/boot/boot_keyboard.h => deleted_files/usr/src/uts/i86pc/boot/boot_keyboard.h rename : usr/src/uts/intel/io/i8254.c => usr/src/uts/i86pc/io/microfind.c rename : usr/src/uts/i86pc/cpunex/Makefile => usr/src/uts/intel/cpunex/Makefile rename : usr/src/uts/i86pc/io/cpunex.c => usr/src/uts/intel/io/cpunex.c
Diffstat (limited to 'usr/src/cmd/devprop/devprop.c')
-rw-r--r--usr/src/cmd/devprop/devprop.c158
1 files changed, 158 insertions, 0 deletions
diff --git a/usr/src/cmd/devprop/devprop.c b/usr/src/cmd/devprop/devprop.c
new file mode 100644
index 0000000000..69306353a7
--- /dev/null
+++ b/usr/src/cmd/devprop/devprop.c
@@ -0,0 +1,158 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <stdio.h>
+#include <unistd.h>
+#include <strings.h>
+#include <libdevinfo.h>
+
+static void
+usage(void)
+{
+ (void) fprintf(stderr,
+ "Usage: devprop [-n device-path] "
+ "[-vq] [-{b|i|l|s}] [property [...]]\n");
+}
+
+int
+main(int argc, char *argv[])
+{
+ int c;
+ boolean_t verbose = B_FALSE, quote = B_FALSE,
+ error = B_FALSE;
+ int type = DI_PROP_TYPE_UNKNOWN;
+ char *path = "/";
+ di_node_t dn;
+ uchar_t *val_b;
+ int *val_i;
+ int64_t *val_l;
+ char *val_s;
+ int n;
+
+ extern char *optarg;
+ extern int optind;
+
+#define BOOL(ch, var) \
+case ch: \
+ var = B_TRUE; \
+ break
+
+#define PER_OPT(ch, typ) \
+case ch: \
+ if (type != DI_PROP_TYPE_UNKNOWN) { \
+ usage(); \
+ return (1); \
+ } \
+ type = (typ); \
+ break
+
+ while ((c = getopt(argc, argv, ":n:vqbils")) != -1) {
+ switch (c) {
+ case 'n':
+ path = optarg;
+ break;
+ case ':':
+ usage();
+ return (1);
+
+ BOOL('v', verbose);
+ BOOL('q', quote);
+ BOOL('?', error);
+
+ PER_OPT('b', DI_PROP_TYPE_BYTE);
+ PER_OPT('i', DI_PROP_TYPE_INT);
+ PER_OPT('l', DI_PROP_TYPE_INT64);
+ PER_OPT('s', DI_PROP_TYPE_STRING);
+ }
+ }
+
+#undef BOOL
+#undef PER_OPT
+
+ if (error) {
+ usage();
+ return (1);
+ }
+
+ /* default to strings */
+ if (type == DI_PROP_TYPE_UNKNOWN)
+ type = DI_PROP_TYPE_STRING;
+
+ /*
+ * It's convenient to use the filesystem as a source of device
+ * node paths. In that case, the path will be prefixed with
+ * "/devices", which we strip off here as di_init() expects
+ * just the path to the node.
+ */
+ if (strncmp("/devices/", path, strlen("/devices/")) == 0)
+ path += strlen("/devices");
+
+ if ((dn = di_init(path, DINFOPROP)) == DI_NODE_NIL) {
+ perror("di_init");
+ return (1);
+ }
+
+ /* Careful with that axe, Eugene... */
+#define PER_TYPE(typ, func, val, incr, form, pv, sep) \
+case (typ): \
+ n = func(DDI_DEV_T_ANY, \
+ dn, argv[optind], &(val)); \
+ while (n > 0) { \
+ (void) printf((form), pv); \
+ incr; \
+ n--; \
+ if (n > 0) \
+ (void) printf(sep); \
+ } \
+ (void) printf("\n"); \
+ break
+
+ while (optind < argc) {
+ if (verbose)
+ (void) printf("%s=", argv[optind]);
+
+ switch (type) {
+ PER_TYPE(DI_PROP_TYPE_BYTE, di_prop_lookup_bytes,
+ val_b, val_b++, "%2.2x", *val_b, ".");
+ PER_TYPE(DI_PROP_TYPE_INT, di_prop_lookup_ints,
+ val_i, val_i++, "%8.8x", *val_i, ".");
+ PER_TYPE(DI_PROP_TYPE_INT64, di_prop_lookup_int64,
+ val_l, val_l++, "%16.16llx", *val_l, ".");
+ PER_TYPE(DI_PROP_TYPE_STRING, di_prop_lookup_strings,
+ val_s, val_s += strlen(val_s) + 1,
+ (quote ? "\"%s\"" : "%s"), val_s, " + ");
+ }
+
+ optind++;
+ }
+
+#undef PER_TYPE
+
+ di_fini(dn);
+
+ return (0);
+}