6944423 'format' need identify the name scheme of emc powerpath driver in x86 platform
authorSheng-Liang Eric Zhang <Shengliang.Zhang@Sun.COM>
Wed, 05 May 2010 12:10:59 +0800
changeset 12311 650b48a2bf75
parent 12310 f87d8e83d301
child 12312 2f3e4b56b6fe
6944423 'format' need identify the name scheme of emc powerpath driver in x86 platform
usr/src/cmd/format/menu_fdisk.c
usr/src/cmd/format/misc.c
usr/src/cmd/format/misc.h
--- a/usr/src/cmd/format/menu_fdisk.c	Wed May 05 11:09:47 2010 +0800
+++ b/usr/src/cmd/format/menu_fdisk.c	Wed May 05 12:10:59 2010 +0800
@@ -19,8 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -190,6 +189,28 @@
 }
 #endif /* defined(sparc) */
 
+#ifdef i386
+/*
+ * Convert emcpowerN[a-p,p0,p1,p2,p3,p4] to emcpowerNp0 path,
+ * this is specific for emc powerpath driver.
+ */
+static void
+get_emcpower_pname(char *name, char *devname)
+{
+	char	*emcp = "emcpower";
+	char	*npt = NULL;
+	char	np[MAXNAMELEN];
+	int	i = strlen(emcp);
+
+	(void) strcpy(np, devname);
+	npt = strstr(np, emcp);
+	while ((i < strlen(npt)) && (isdigit(npt[i])))
+		i++;
+	npt[i] = '\0';
+	(void) snprintf(name, MAXNAMELEN, "/dev/rdsk/%sp0", npt);
+}
+#endif
+
 /*
  * Convert cn[tn]dn to cn[tn]dns2 path
  */
@@ -202,6 +223,13 @@
 	char		np[MAXNAMELEN];
 	char		*npt;
 
+#ifdef i386
+	if (emcpower_name(cur_disk->disk_name)) {
+		get_emcpower_pname(name, cur_disk->disk_name);
+		return;
+	}
+#endif
+
 	/*
 	 * If it is a full path /dev/[r]dsk/cn[tn]dn, use this path
 	 */
@@ -248,6 +276,13 @@
 		(void) strcpy(np, cur_disk->disk_name);
 	}
 
+#ifdef i386
+	if (emcpower_name(np)) {
+		get_emcpower_pname(name, np);
+		return;
+	}
+#endif
+
 	if (strncmp(rdevp, np, strlen(rdevp)) == 0 ||
 	    strncmp(devp, np, strlen(devp)) == 0) {
 		/*
--- a/usr/src/cmd/format/misc.c	Wed May 05 11:09:47 2010 +0800
+++ b/usr/src/cmd/format/misc.c	Wed May 05 12:10:59 2010 +0800
@@ -19,8 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -674,6 +673,40 @@
 	return (*name == 0);
 }
 
+#ifdef i386
+/*
+ * Return true if a device name match the emc powerpath name scheme:
+ * emcpowerN[a-p,p0,p1,p2,p3,p4]
+ */
+int
+emcpower_name(char *name)
+{
+	char	*emcp = "emcpower";
+	char	*devp = "/dev/dsk";
+	char	*rdevp = "/dev/rdsk";
+
+	if (strncmp(devp, name, strlen(devp)) == 0) {
+		name += strlen(devp) + 1;
+	} else if (strncmp(rdevp, name, strlen(rdevp)) == 0) {
+		name += strlen(rdevp) + 1;
+	}
+	if (strncmp(emcp, name, strlen(emcp)) == 0) {
+		name += strlen(emcp);
+		if (isdigit(*name)) {
+			skip_digits(name);
+			if ((*name >= 'a') && (*name <= 'p')) {
+				name ++;
+				if ((*name >= '0') && (*name <= '4')) {
+					name++;
+				}
+			}
+			return (*name == '\0');
+		}
+	}
+	return (0);
+}
+#endif
+
 /*
  * Return true if a device name matches the intel physical name conventions
  * for the particular system.
--- a/usr/src/cmd/format/misc.h	Wed May 05 11:09:47 2010 +0800
+++ b/usr/src/cmd/format/misc.h	Wed May 05 12:10:59 2010 +0800
@@ -19,8 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 #ifndef	_MISC_H
@@ -154,6 +153,10 @@
 char	*alloc_string(char *s);
 char	**build_argvlist(char **, int *, int *, char *);
 int	conventional_name(char *name);
+#ifdef i386
+int	emcpower_name(char *name);
+#endif
+
 
 #if defined(_FIRMWARE_NEEDS_FDISK)
 int	fdisk_physical_name(char *name);