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

@@ -21,11 +21,10 @@
 /*
  * 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>

@@ -48,11 +47,11 @@
         char *path = "/";
         di_node_t dn;
         uchar_t *val_b;
         int *val_i;
         int64_t *val_l;
-        char *val_s;
+        char *val_s, *ptr;
         int n;
 
         extern char *optarg;
         extern int optind;
 

@@ -71,10 +70,11 @@
         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,13 +106,18 @@
          * 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)
+        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);
         }