changeset 4444:558de447355b onnv_67

6568015 libtopo sets wrong return value for dev scheme's unusable method 6568016 libdevinfo should export devinfo node's flags field 6568017 libdevinfo should check snapshot version
author vikram
date Mon, 11 Jun 2007 22:00:14 -0700
parents f204cc846dd4
children c0e2d3b35754
files usr/src/lib/fm/topo/libtopo/common/dev.c usr/src/lib/libdevinfo/devinfo.c usr/src/lib/libdevinfo/mapfile-vers usr/src/uts/common/io/devinfo.c usr/src/uts/common/sys/devinfo_impl.h
diffstat 5 files changed, 29 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/lib/fm/topo/libtopo/common/dev.c	Mon Jun 11 21:30:14 2007 -0700
+++ b/usr/src/lib/fm/topo/libtopo/common/dev.c	Mon Jun 11 22:00:14 2007 -0700
@@ -456,7 +456,7 @@
 
 	if (topo_mod_nvalloc(mod, out, NV_UNIQUE_NAME) != 0)
 		return (topo_mod_seterrno(mod, EMOD_NVL_INVAL));
-	if (nvlist_add_uint32(*out, TOPO_METH_PRESENT_RET, unusable) != 0) {
+	if (nvlist_add_uint32(*out, TOPO_METH_UNUSABLE_RET, unusable) != 0) {
 		nvlist_free(*out);
 		return (topo_mod_seterrno(mod, EMOD_NVL_INVAL));
 	}
--- a/usr/src/lib/libdevinfo/devinfo.c	Mon Jun 11 21:30:14 2007 -0700
+++ b/usr/src/lib/libdevinfo/devinfo.c	Mon Jun 11 22:00:14 2007 -0700
@@ -271,6 +271,14 @@
 	(void) close(fd);
 
 	dap = DI_ALL(pa);
+	if (dap->version != DI_SNAPSHOT_VERSION) {
+		DPRINTF((DI_ERR, "wrong snapshot version "
+		    "(expected=%d, actual=%d)\n",
+		    DI_SNAPSHOT_VERSION, dap->version));
+		free(pa);
+		errno = ESTALE;
+		return (DI_NODE_NIL);
+	}
 	if (dap->top_devinfo == 0) {	/* phys_path not found */
 		DPRINTF((DI_ERR, "%s not found\n", phys_path));
 		free(pa);
@@ -984,6 +992,12 @@
 	return (DI_NODE(node)->node_state);
 }
 
+uint_t
+di_flags(di_node_t node)
+{
+	return (DI_NODE(node)->flags);
+}
+
 ddi_devid_t
 di_devid(di_node_t node)
 {
--- a/usr/src/lib/libdevinfo/mapfile-vers	Mon Jun 11 21:30:14 2007 -0700
+++ b/usr/src/lib/libdevinfo/mapfile-vers	Mon Jun 11 22:00:14 2007 -0700
@@ -210,6 +210,7 @@
 	finddev_readdir;
 	finddev_close;
 	finddev_next;
+	di_flags;
     local:
 	*;
 };
--- a/usr/src/uts/common/io/devinfo.c	Mon Jun 11 21:30:14 2007 -0700
+++ b/usr/src/uts/common/io/devinfo.c	Mon Jun 11 22:00:14 2007 -0700
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -1713,6 +1713,7 @@
 	me->node_class = node->devi_node_class;
 	me->attributes = node->devi_node_attributes;
 	me->state = node->devi_state;
+	me->flags = node->devi_flags;
 	me->node_state = node->devi_node_state;
 	me->next_vhci = 0;		/* Filled up by build_vhci_list. */
 	me->top_phci = 0;		/* Filled up by build_phci_list. */
--- a/usr/src/uts/common/sys/devinfo_impl.h	Mon Jun 11 21:30:14 2007 -0700
+++ b/usr/src/uts/common/sys/devinfo_impl.h	Mon Jun 11 22:00:14 2007 -0700
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * 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.
@@ -20,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -99,7 +98,8 @@
 #define	MAX_PTR_IN_PRV	5
 #define	DI_SNAPSHOT_VERSION_0	0	/* reserved */
 #define	DI_SNAPSHOT_VERSION_1	1	/* reserved */
-#define	DI_SNAPSHOT_VERSION	DI_SNAPSHOT_VERSION_1	/* current version */
+#define	DI_SNAPSHOT_VERSION_2	2	/* reserved */
+#define	DI_SNAPSHOT_VERSION	DI_SNAPSHOT_VERSION_2	/* current version */
 #define	DI_PRIVDATA_VERSION_0	10	/* Start from 10 so caller must set */
 #define	DI_BIG_ENDIAN		0	/* reserved */
 #define	DI_LITTLE_ENDIAN	1	/* reserved */
@@ -277,6 +277,12 @@
 	di_off_t top_phci;
 	di_off_t next_phci;
 	uint32_t multipath_component;	/* stores MDI_COMPONENT_* value. */
+
+	/*
+	 * devi_flags field
+	 */
+	uint32_t flags;
+	uint32_t di_pad2;	/* 4 byte padding for 32bit x86 app. */
 };
 
 /*