Print this page
6992 devprop(1M) should work also with logical names

*** 21,31 **** /* * 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> --- 21,30 ----
*** 48,58 **** 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; --- 47,57 ---- char *path = "/"; di_node_t dn; uchar_t *val_b; int *val_i; int64_t *val_l; ! char *val_s, *ptr; int n; extern char *optarg; extern int optind;
*** 71,80 **** --- 70,80 ---- break while ((c = getopt(argc, argv, ":n:vqbils")) != -1) { switch (c) { case 'n': + if ((path = realpath(optarg, NULL)) == NULL) path = optarg; break; case ':': usage(); return (1);
*** 106,118 **** * 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); } --- 106,123 ---- * 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"); + /* cut off minor name */ + if ((ptr = strrchr(path, ':')) != NULL) + *ptr = '\0'; + } + if ((dn = di_init(path, DINFOPROP)) == DI_NODE_NIL) { perror("di_init"); return (1); }