5284 TI doesn't utilize last cylinder when creating VTOC with default layout
authorJan Damborsky <jan.damborsky@sun.com>
Thu, 22 Jan 2009 16:28:37 +0100
changeset 420 818239049932
parent 419 b266a3ef138d
child 421 faf781efca86
5284 TI doesn't utilize last cylinder when creating VTOC with default layout 5644 TD and TI test drivers should be built as part of full build of source gate
usr/src/Makefile.master
usr/src/Targetdirs
usr/src/lib/Makefile.targ
usr/src/lib/libtd/Makefile
usr/src/lib/libti/Makefile
usr/src/lib/libti/test_ti.c
usr/src/lib/libti/ti_dm.c
usr/src/lib/libti/ti_dm.h
usr/src/pkgdefs/Makefile
usr/src/pkgdefs/SUNWinstall-test/Makefile
usr/src/pkgdefs/SUNWinstall-test/depend
usr/src/pkgdefs/SUNWinstall-test/pkginfo.tmpl
usr/src/pkgdefs/SUNWinstall-test/prototype_com
usr/src/pkgdefs/SUNWinstall-test/prototype_i386
usr/src/pkgdefs/SUNWinstall-test/prototype_sparc
usr/src/pkgdefs/common_files/copyright
--- a/usr/src/Makefile.master	Wed Jan 21 18:44:40 2009 -0700
+++ b/usr/src/Makefile.master	Thu Jan 22 16:28:37 2009 +0100
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 
@@ -90,6 +90,7 @@
 ROOTINCADMIN=		$(ROOTINC)/admin
 ROOTMAN1M=		$(ROOTMAN)/man1m
 ROOTMAN=		$(ROOT)/usr/share/man
+ROOTOPTINSTALLTESTBIN=	$(ROOT)/opt/install-test/bin
 ROOTPYTHON=		$(ROOTUSRLIB)/python2.4
 ROOTPYTHONVENDOR=	$(ROOTPYTHON)/vendor-packages
 ROOTPYTHONVENDORINSTALL=	$(ROOTPYTHONVENDOR)/osol_install
--- a/usr/src/Targetdirs	Wed Jan 21 18:44:40 2009 -0700
+++ b/usr/src/Targetdirs	Thu Jan 22 16:28:37 2009 +0100
@@ -18,7 +18,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 #
@@ -80,6 +80,9 @@
 
 
 OTHERS= \
+	/opt \
+	/opt/install-test \
+	/opt/install-test/bin \
 	/usr/include/admin \
 	/usr/snadm/lib \
 	/var/installadm \
--- a/usr/src/lib/Makefile.targ	Wed Jan 21 18:44:40 2009 -0700
+++ b/usr/src/lib/Makefile.targ	Thu Jan 22 16:28:37 2009 +0100
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 
@@ -68,6 +68,9 @@
 $(ROOTADMINLIB)/%: $$(PNAME)/$(ARCH)/%
 	$(INS.file)
 
+$(ROOTOPTINSTALLTESTBIN)/%: %
+	$(INS.file)
+
 $(ROOTUSRLIB):
 	$(INS.dir)
 
--- a/usr/src/lib/libtd/Makefile	Wed Jan 21 18:44:40 2009 -0700
+++ b/usr/src/lib/libtd/Makefile	Thu Jan 22 16:28:37 2009 +0100
@@ -18,7 +18,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # Target Discovery software library makefile
@@ -27,6 +27,8 @@
 LIBRARY	= libtd.a
 VERS	= .1
 
+TEST_PROGS	= test_td test_td_static tdmgtst tdmgtst_static
+
 OBJECTS	= \
 	td_mg.o \
 	td_be.o \
@@ -53,37 +55,52 @@
 		   -I../libbe \
 		   -I$(ROOTINCADMIN)
 
-CPPFLAGS	+= ${INCLUDE} -D${ARCH}
-CFLAGS		+= $(DEBUG_CFLAGS) -Xa ${CPPFLAGS}
+CPPFLAGS	+= $(INCLUDE) -D$(ARCH)
+CFLAGS		+= $(DEBUG_CFLAGS) -Xa $(CPPFLAGS)
 LDFLAGS		+=
 SOFLAGS		+= -L$(ROOTADMINLIB) -R$(ROOTADMINLIB:$(ROOT)%=%) \
 		-L$(ROOTUSRLIB) -R$(ROOTUSRLIB:$(ROOT)%=%) \
 		-ldiskmgt -lnvpair -llogsvc -linstzones
 
-LINTERR		= lint_errors
-LINTFILES	= ${SRCS:%.c=${ARCH}/%.ln}
-LINTFLAGS	= -uaxm ${CPPFLAGS}
+ROOT_TEST_PROGS	= $(TEST_PROGS:%=$(ROOTOPTINSTALLTESTBIN)/%)
+CLEANFILES	= $(TEST_PROGS)
 
 .KEEP_STATE:
 
 all: $(HDRS) .WAIT static dynamic
 	@true
 
-#Target Discovery Manager test program
-mgtst tdmgtst:	.WAIT static tdmgtst.o
-	${LINK.c} -R$(ROOTADMINLIB:$(ROOT)%=%) \
-		-o tdmgtst tdmgtst.o \
-		-Lobjs/${ARCH} -ldiskmgt -lnvpair -ldevinfo -ladm \
-		-L$(ROOTADMINLIB) -llogsvc -linstzones \
+# Target Discovery Manager test program
+tdmgtst:	dynamic tdmgtst.o
+	$(LINK.c) -o tdmgtst tdmgtst.o \
+		-R$(ROOTADMINLIB:$(ROOT)%=%) \
+		-L$(ROOTADMINLIB) -Lpics/$(ARCH) \
+		-ltd -llogsvc -lnvpair
+
+# statically built Target Discovery Manager test program
+tdmgtst_static:	static tdmgtst.o
+	$(LINK.c) -o tdmgtst_static tdmgtst.o \
+		-L$(ROOTADMINLIB) -Lobjs/$(ARCH) \
 		-Bstatic \
-		-ltd \
-		-Bdynamic
+		-ltd -llogsvc -linstzones \
+		-Bdynamic \
+		-ldiskmgt -lnvpair -ldevinfo -ladm -lzonecfg -lcontract -lgen
 
-#Target Discovery test program
-tdtst:	.WAIT dynamic test_td.o
-	${LINK.c} -R$(ROOTADMINLIB:$(ROOT)%=%) \
-		-o test_td test_td.o -L$(ROOTADMINLIB) \
-		-Lpics/${ARCH} -ltd -llogsvc -lnvpair
+# Target Discovery test program
+test_td:	dynamic test_td.o
+	$(LINK.c) -o test_td test_td.o \
+		-R$(ROOTADMINLIB:$(ROOT)%=%) \
+		-L$(ROOTADMINLIB) -Lpics/$(ARCH) \
+		-ltd -llogsvc -lnvpair
+
+# statically built Target Discovery test program
+test_td_static:	static test_td.o
+	$(LINK.c) -o test_td_static test_td.o \
+		-L$(ROOTADMINLIB) -Lobjs/$(ARCH) \
+		-Bstatic \
+		-ltd -llogsvc -linstzones \
+		-Bdynamic \
+		-ldiskmgt -lnvpair -ldevinfo -ladm -lzonecfg -lcontract -lgen
 
 static: $(LIBS)
 
@@ -91,16 +108,12 @@
 
 install:	all .WAIT \
 		$(ROOTADMINLIB) $(ROOTADMINLIBS) $(ROOTADMINLIBDYNLIB) \
-		$(ROOTADMINLIBDYNLIBLINK)
-
-install_test:	all .WAIT \
-		$(ROOTADMINLIB) $(ROOTADMINLIBS) $(ROOTADMINLIBDYNLIB) \
-		$(ROOTADMINLIBDYNLIBLINK)
+		$(ROOT_TEST_PROGS) $(ROOTADMINLIBDYNLIBLINK)
 
 install_h:	$(ROOTUSRINCLEXP)
 
-lint:  ${SRCS} ${HDRS}
-	${LINT.c} ${SRCS}
+lint:  $(SRCS) $(HDRS)
+	$(LINT.c) $(SRCS)
 
 cstyle:	$(SRCS) $(PRIVHDRS) $(PUBHDRS)
 	$(CSTYLE) $(SRCS) $(PRIVHDRS) $(PUBHDRS)
--- a/usr/src/lib/libti/Makefile	Wed Jan 21 18:44:40 2009 -0700
+++ b/usr/src/lib/libti/Makefile	Thu Jan 22 16:28:37 2009 +0100
@@ -18,7 +18,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # Target Instantiation software library makefile
@@ -27,6 +27,8 @@
 LIBRARY	= libti.a
 VERS	= .1
 
+TEST_PROGS	= test_ti test_ti_static
+
 OBJECTS	= \
 	ti_mg.o \
 	ti_bem.o \
@@ -49,36 +51,37 @@
 		   -I../liblogsvc \
 		   -I$(ROOTINCADMIN)
 
-CPPFLAGS	+= ${INCLUDE} -D${ARCH}
-CFLAGS		+= $(DEBUG_CFLAGS) -Xa ${CPPFLAGS}
+CPPFLAGS	+= $(INCLUDE) -D$(ARCH)
+CFLAGS		+= $(DEBUG_CFLAGS) -Xa $(CPPFLAGS)
 LDFLAGS		+=
 SOFLAGS		+= -L$(ROOTADMINLIB) -R$(ROOTADMINLIB:$(ROOT)%=%) \
 		-L$(ROOTUSRLIB) -R$(ROOTUSRLIB:$(ROOT)%=%) \
 		-ladm -lnvpair -llogsvc -lbe
 
-LINTERR		= lint_errors
-LINTFILES	= ${SRCS:%.c=${ARCH}/%.ln}
-LINTFLAGS	= -uaxm ${CPPFLAGS}
+ROOT_TEST_PROGS	= $(TEST_PROGS:%=$(ROOTOPTINSTALLTESTBIN)/%)
+CLEANFILES	= $(TEST_PROGS)
 
 .KEEP_STATE:
 
-all: $(HDRS) .WAIT static dynamic
+all: $(HDRS) .WAIT static dynamic $(TEST_PROGS)
 	@true
 
 # Target Instantiation test program
-titst:	.WAIT dynamic test_ti.o
-	${LINK.c} -R$(ROOTADMINLIB:$(ROOT)%=%) \
-		-o test_ti test_ti.o -L$(ROOTADMINLIB) -L$(ROOTUSRLIB) \
-		-Lpics/${ARCH} -lti -llogsvc -lnvpair
+test_ti:	dynamic test_ti.o
+	$(LINK.c) -o test_ti test_ti.o \
+		-R$(ROOTADMINLIB:$(ROOT)%=%) \
+		-L$(ROOTADMINLIB) -L$(ROOTUSRLIB) -Lpics/$(ARCH) \
+		-lti -llogsvc -lnvpair
 
 # statically-built Target Instantiation test program
-titststatic:	.WAIT static test_ti.o
-	${LINK.c} \
-		-o test_ti test_ti.o -L$(ROOTADMINLIB) -L$(ROOTUSRLIB) \
+test_ti_static:	static test_ti.o
+	$(LINK.c) -o test_ti_static test_ti.o \
+		-L$(ROOTADMINLIB) -L$(ROOTUSRLIB) -Lobjs/$(ARCH) \
 		-Bstatic \
 		-lti -lbe -llogsvc -linstzones \
 		-Bdynamic \
-		-ladm -lnvpair -lgen -lzfs -lpython2.4 -luuid -lzonecfg -lcontract
+		-ladm -lnvpair -lgen -lzfs -lpython2.4 -luuid \
+		-lzonecfg -lcontract
 
 static: $(LIBS)
 
@@ -86,16 +89,12 @@
 
 install:	all .WAIT \
 		$(ROOTADMINLIB) $(ROOTADMINLIBS) $(ROOTADMINLIBDYNLIB) \
-		$(ROOTADMINLIBDYNLIBLINK)
-
-install_test:	all .WAIT \
-		$(ROOTADMINLIB) $(ROOTADMINLIBS) $(ROOTADMINLIBDYNLIB) \
-		$(ROOTADMINLIBDYNLIBLINK)
+		$(ROOT_TEST_PROGS) $(ROOTADMINLIBDYNLIBLINK)
 
 install_h:	$(ROOTUSRINCLEXP)
 
-lint:  ${SRCS} ${HDRS}
-	${LINT.c} ${SRCS}
+lint:  $(SRCS) $(HDRS)
+	$(LINT.c) $(SRCS)
 
 cstyle:	$(SRCS) $(PRIVHDRS) $(PUBHDRS)
 	$(CSTYLE) $(SRCS) $(PRIVHDRS) $(PUBHDRS)
--- a/usr/src/lib/libti/test_ti.c	Wed Jan 21 18:44:40 2009 -0700
+++ b/usr/src/lib/libti/test_ti.c	Thu Jan 22 16:28:37 2009 +0100
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -93,6 +93,8 @@
 	    "  -d disk_name      disk name - e.g c1t0d0\n"
 	    "  -f file           create VTOC from file - if not provided, "
 	    "create default layout (s0 will occupy all space)\n"
+	    "  -s                create swap on slice 1 (valid only for "
+	    " default layout)\n"
 	    " ZFS root pool options (select ZFS root pool type: "
 	    "option \"-t [p|P]\")\n"
 	    "  -t p              create ZFS pool\n"
@@ -415,7 +417,8 @@
 
 static int
 prepare_vtoc_target(nvlist_t *target_attrs, char *disk_name,
-    char *layout_file_name, boolean_t default_layout)
+    char *layout_file_name, boolean_t default_layout,
+    boolean_t create_swap_on_s1)
 {
 	FILE		*pt_file;
 	char		vtoc_line[1000];
@@ -442,9 +445,7 @@
 	}
 
 	/*
-	 * create default or customized layout ?
-	 * If customized layout is to be created, file containing layout
-	 * configuration needs to be provided
+	 * create default VTOC layout
 	 */
 
 	if (default_layout) {
@@ -455,177 +456,196 @@
 
 			return (-1);
 		}
-	} else {
+
 		/*
-		 * open file containing information about VTOC layout
-		 * to be created and populate attribute nv list accordingly
+		 * if swap should be created on slice 1, set appropriate
+		 * attribute
 		 */
 
-		pt_file = fopen(layout_file_name, "r");
+		if (create_swap_on_s1) {
+			if (nvlist_add_boolean_value(target_attrs,
+			    TI_ATTR_CREATE_SWAP_SLICE, B_TRUE) != 0) {
+				(void) fprintf(stderr, "ERR: Couldn't add "
+				    "TI_ATTR_CREATE_SWAP_SLICE to nvlist\n");
+
+				return (-1);
+			}
+		}
+
+		return (0);
+	}
+
+	/*
+	 * Customized layout will be created. File containing layout
+	 * configuration needs to be provided.
+	 *
+	 * Open that file and populate attribute nv list accordingly.
+	 */
+
+	pt_file = fopen(layout_file_name, "r");
+
+	if (pt_file == NULL) {
+		(void) fprintf(stderr,
+		    "ERR: Couldn't open %s file for reading\n");
+
+		return (-1);
+	}
+
+	/*
+	 * File is in format which is produced by prtvtoc(1M) command
+	 * and which can be passed to "fmthard(1M) -s" command.
+	 */
+
+	part_num = 0;
+
+	pnum = ptag = pflag = NULL;
+	pstart = psize = NULL;
+
+	while (fgets(vtoc_line, sizeof (vtoc_line), pt_file) != NULL) {
 
-		if (pt_file == NULL) {
+		/*
+		 * lines starting with '*' are comments - ignore them
+		 * as well as empty lines
+		 */
+
+		if ((vtoc_line[0] == '*') || (vtoc_line[0] == '\n'))
+			continue;
+
+		/*
+		 * read line describing VTOC slice.
+		 * Line is in following format (decimal numbers):
+		 *
+		 * num tag flag 1st_sector size_in_sectors
+		 *
+		 * num - slice number - 0-7 for Sparc, 0-15 for x86
+		 * tag - slice tag
+		 *	 0 - V_UNASSIGNED
+		 *	 1 - V_BOOT
+		 *	 2 - V_ROOT
+		 *	 3 - V_SWAP
+		 *	 4 - V_USR
+		 *	 5 - V_BACKUP
+		 *	 6 - V_STAND
+		 *	 7 - V_VAR
+		 *	 8 - V_HOME
+		 * flag - slice flag
+		 *	 01 - V_UNMNT
+		 *	 10 - V_RONLY
+		 * 1st_sector - 1st sector of slice
+		 * size_in_sectors - slice size in sectors
+		 */
+
+		num = tag = flag = 0;
+		start = size = 0;
+
+		ret = sscanf(vtoc_line, "%d%d%X%llu%llu",
+		    &num, &tag, &flag, &start, &size);
+
+		if (ret != 5) {
 			(void) fprintf(stderr,
-			    "ERR: Couldn't open %s file for reading\n");
+			    "following slice line has invalid format:\n"
+			    "%s\n", vtoc_line);
+
+			(void) fprintf(stderr, "sscanf returned %d: "
+			    "%d,%02X,%llu,%llu\n", ret,
+			    num, tag, flag, start, size);
+
+			(void) fclose(pt_file);
 
 			return (-1);
 		}
 
-		/*
-		 * File is in format which is produced by prtvtoc(1M) command
-		 * and which can be passed to "fmthard(1M) -s" command.
-		 */
-
-		part_num = 0;
-
-		pnum = ptag = pflag = NULL;
-		pstart = psize = NULL;
-
-		while (fgets(vtoc_line, sizeof (vtoc_line), pt_file) != NULL) {
-
-			/*
-			 * lines starting with '*' are comments - ignore them
-			 * as well as empty lines
-			 */
-
-			if ((vtoc_line[0] == '*') || (vtoc_line[0] == '\n'))
-				continue;
+		part_num++;
 
-			/*
-			 * read line describing VTOC slice.
-			 * Line is in following format (decimal numbers):
-			 *
-			 * num tag flag 1st_sector size_in_sectors
-			 *
-			 * num - slice number - 0-7 for Sparc, 0-15 for x86
-			 * tag - slice tag
-			 *	 0 - V_UNASSIGNED
-			 *	 1 - V_BOOT
-			 *	 2 - V_ROOT
-			 *	 3 - V_SWAP
-			 *	 4 - V_USR
-			 *	 5 - V_BACKUP
-			 *	 6 - V_STAND
-			 *	 7 - V_VAR
-			 *	 8 - V_HOME
-			 * flag - slice flag
-			 *	 01 - V_UNMNT
-			 *	 10 - V_RONLY
-			 * 1st_sector - 1st sector of slice
-			 * size_in_sectors - slice size in sectors
-			 */
-
-			num = tag = flag = 0;
-			start = size = 0;
-
-			ret = sscanf(vtoc_line, "%d%d%X%llu%llu",
-			    &num, &tag, &flag, &start, &size);
+		/* reallocate memory for another line */
 
-			if (ret != 5) {
-				(void) fprintf(stderr,
-				    "following slice line has invalid format:\n"
-				    "%s\n", vtoc_line);
-
-				(void) fprintf(stderr, "sscanf returned %d: "
-				    "%d,%02X,%llu,%llu\n", ret,
-				    num, tag, flag, start, size);
-
-				(void) fclose(pt_file);
-
-				return (-1);
-			}
-
-			part_num++;
-
-			/* reallocate memory for another line */
-
-			pnum = realloc(pnum, part_num * sizeof (uint16_t));
-			ptag = realloc(ptag, part_num * sizeof (uint16_t));
-			pflag = realloc(pflag, part_num * sizeof (uint16_t));
-			pstart = realloc(pstart, part_num * sizeof (uint64_t));
-			psize = realloc(psize, part_num * sizeof (uint64_t));
+		pnum = realloc(pnum, part_num * sizeof (uint16_t));
+		ptag = realloc(ptag, part_num * sizeof (uint16_t));
+		pflag = realloc(pflag, part_num * sizeof (uint16_t));
+		pstart = realloc(pstart, part_num * sizeof (uint64_t));
+		psize = realloc(psize, part_num * sizeof (uint64_t));
 
-			if (pnum == NULL || ptag == NULL ||
-			    pflag == NULL || pstart == NULL || psize == NULL) {
-				(void) fprintf(stderr,
-				    "Memory allocation failed\n");
-
-				(void) fclose(pt_file);
-
-				return (-1);
-			}
-
-			/* fill in data */
+		if (pnum == NULL || ptag == NULL ||
+		    pflag == NULL || pstart == NULL || psize == NULL) {
+			(void) fprintf(stderr,
+			    "Memory allocation failed\n");
 
-			pnum[part_num - 1] = num;
-			ptag[part_num - 1] = tag;
-			pflag[part_num - 1] = flag;
-			pstart[part_num - 1] = start;
-			psize[part_num - 1] = size;
-		}
-
-		(void) fclose(pt_file);
-
-		/* add number of slices to be created */
-
-		if (nvlist_add_uint16(target_attrs, TI_ATTR_SLICE_NUM,
-		    part_num) != 0) {
-			(void) fprintf(stderr, "Couldn't add "
-			    "TI_ATTR_SLICE_NUM to nvlist\n");
+			(void) fclose(pt_file);
 
 			return (-1);
 		}
 
-		/* add slice geometry configuration */
-
-		/* slice numbers */
+		/* fill in data */
 
-		if (nvlist_add_uint16_array(target_attrs, TI_ATTR_SLICE_PARTS,
-		    pnum, part_num) != 0) {
-			(void) fprintf(stderr, "Couldn't add "
-			    "TI_ATTR_SLICE_PARTS to nvlist\n");
+		pnum[part_num - 1] = num;
+		ptag[part_num - 1] = tag;
+		pflag[part_num - 1] = flag;
+		pstart[part_num - 1] = start;
+		psize[part_num - 1] = size;
+	}
 
-			return (-1);
-		}
+	(void) fclose(pt_file);
+
+	/* add number of slices to be created */
 
-		/* slice tags */
+	if (nvlist_add_uint16(target_attrs, TI_ATTR_SLICE_NUM,
+	    part_num) != 0) {
+		(void) fprintf(stderr, "Couldn't add "
+		    "TI_ATTR_SLICE_NUM to nvlist\n");
+
+		return (-1);
+	}
+
+	/* add slice geometry configuration */
 
-		if (nvlist_add_uint16_array(target_attrs,
-		    TI_ATTR_SLICE_TAGS, ptag, part_num) != 0) {
-			(void) fprintf(stderr, "Couldn't add "
-			    "TI_ATTR_SLICE_TAGS to nvlist\n");
+	/* slice numbers */
 
-			return (-1);
-		}
+	if (nvlist_add_uint16_array(target_attrs, TI_ATTR_SLICE_PARTS,
+	    pnum, part_num) != 0) {
+		(void) fprintf(stderr, "Couldn't add "
+		    "TI_ATTR_SLICE_PARTS to nvlist\n");
 
-		/* slice flags */
+		return (-1);
+	}
+
+	/* slice tags */
 
-		if (nvlist_add_uint16_array(target_attrs,
-		    TI_ATTR_SLICE_FLAGS, pflag, part_num) != 0) {
-			(void) fprintf(stderr, "Couldn't add "
-			    "TI_ATTR_SLICE_FLAGS to nvlist\n");
+	if (nvlist_add_uint16_array(target_attrs,
+	    TI_ATTR_SLICE_TAGS, ptag, part_num) != 0) {
+		(void) fprintf(stderr, "Couldn't add "
+		    "TI_ATTR_SLICE_TAGS to nvlist\n");
+
+		return (-1);
+	}
 
-			return (-1);
-		}
+	/* slice flags */
 
-		/* slice start */
+	if (nvlist_add_uint16_array(target_attrs,
+	    TI_ATTR_SLICE_FLAGS, pflag, part_num) != 0) {
+		(void) fprintf(stderr, "Couldn't add "
+		    "TI_ATTR_SLICE_FLAGS to nvlist\n");
+
+		return (-1);
+	}
 
-		if (nvlist_add_uint64_array(target_attrs,
-		    TI_ATTR_SLICE_1STSECS, pstart, part_num) != 0) {
-			(void) fprintf(stderr, "Couldn't add "
-			    "TI_ATTR_SLICE_1STSECS to nvlist\n");
+	/* slice start */
 
-			return (-1);
-		}
+	if (nvlist_add_uint64_array(target_attrs,
+	    TI_ATTR_SLICE_1STSECS, pstart, part_num) != 0) {
+		(void) fprintf(stderr, "Couldn't add "
+		    "TI_ATTR_SLICE_1STSECS to nvlist\n");
 
-		/* slice size */
+		return (-1);
+	}
+
+	/* slice size */
 
-		if (nvlist_add_uint64_array(target_attrs,
-		    TI_ATTR_SLICE_SIZES, psize, part_num) != 0) {
-			(void) fprintf(stderr, "Couldn't add "
-			    "TI_ATTR_SLICE_SIZES to nvlist\n");
+	if (nvlist_add_uint64_array(target_attrs,
+	    TI_ATTR_SLICE_SIZES, psize, part_num) != 0) {
+		(void) fprintf(stderr, "Couldn't add "
+		    "TI_ATTR_SLICE_SIZES to nvlist\n");
 
-			return (-1);
-		}
+		return (-1);
 	}
 
 	return (0);
@@ -896,6 +916,9 @@
 	/* all available space is dedicated to one slice 0 */
 	boolean_t	fl_vtoc_default = B_FALSE;
 
+	/* create swap on slice 1 */
+	boolean_t	fl_swap_on_s1 = B_FALSE;
+
 	nvlist_t	*target_attrs = NULL;
 	uint16_t	slice_parts[TI_TST_SLICE_NUM] = {0, 1};
 	uint16_t	slice_tags[TI_TST_SLICE_NUM] = {2, 3};
@@ -1019,7 +1042,7 @@
 			break;
 
 			case 's':
-				fl_vtoc_default = B_TRUE;
+				fl_swap_on_s1 = B_TRUE;
 			break;
 
 			case 't':
@@ -1284,6 +1307,10 @@
 
 				printf("Config file not specified, default "
 				    "VTOC will be created\n");
+
+				if (fl_swap_on_s1)
+					printf("swap on slice 1 will be "
+					    "created\n");
 			}
 
 			/* set target type attribute */
@@ -1298,7 +1325,7 @@
 			}
 
 			if (prepare_vtoc_target(target_attrs, disk_name,
-			    config_file, fl_vtoc_default) != 0) {
+			    config_file, fl_vtoc_default, fl_swap_on_s1) != 0) {
 				(void) fprintf(stderr,
 				    "ERR: preparing of VTOC target failed\n");
 
--- a/usr/src/lib/libti/ti_dm.c	Wed Jan 21 18:44:40 2009 -0700
+++ b/usr/src/lib/libti/ti_dm.c	Thu Jan 22 16:28:37 2009 +0100
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -93,6 +93,24 @@
 }
 
 /*
+ * translate cylinders to sectors
+ *
+ * Scope:	private
+ * Parameters:	cyls - number of cylinders
+ *		nsec - number of sectors per cylinder
+ *
+ * Return:	number of sectors
+ */
+
+static diskaddr_t
+idm_cyls_to_secs(uint32_t cyls, uint32_t nsec)
+{
+	return ((diskaddr_t)cyls * (diskaddr_t)nsec);
+
+}
+
+
+/*
  * Convert extvtoc structure to vtoc.
  * This is really temporary and must be removed
  * as soon as write_extvtoc bug(CR 6769481) is fixed.
@@ -1518,6 +1536,7 @@
 	uint64_t	*slice_1stsecs, *slice_sizes;
 	uint_t		nelem;
 	uint32_t	nsecs;
+	uint32_t	first_available_cylinder;
 	boolean_t	fl_slice_def_layout = B_FALSE;
 	boolean_t	create_swap_slice = B_FALSE;
 
@@ -1569,8 +1588,8 @@
 	}
 
 	/*
-	 * check for remaining attributes, only if default layout is not
-	 * required. Also, consider 1st inforamtion to be optional.
+	 * check for remaining attributes - only if customized VTOC
+	 * layout is to be created.
 	 */
 
 	if (!fl_slice_def_layout) {
@@ -1740,7 +1759,18 @@
 		extvtoc.v_part[i].p_flag = 0;
 	}
 
-	/* create slice 2 (ALL) - contains all available space */
+	/*
+	 * Cylinders will be allocated to slices starting
+	 * from the first cylinder
+	 */
+
+	first_available_cylinder = 0;
+
+	/*
+	 * create slice 2 (ALL) - contains all available space.
+	 * This is only valid for SMI label and will need to be
+	 * revisited when implementing support for EFI label.
+	 */
 
 	extvtoc.v_part[IDM_ALL_SLICE].p_tag = V_BACKUP;
 	extvtoc.v_part[IDM_ALL_SLICE].p_flag = V_UNMNT;
@@ -1752,9 +1782,12 @@
 #ifndef sparc
 	extvtoc.v_part[IDM_BOOT_SLICE].p_tag = V_BOOT;
 	extvtoc.v_part[IDM_BOOT_SLICE].p_flag = V_UNMNT;
-	extvtoc.v_part[IDM_BOOT_SLICE].p_start = 0;
+	extvtoc.v_part[IDM_BOOT_SLICE].p_start =
+	    idm_cyls_to_secs(first_available_cylinder, nsecs);
 	extvtoc.v_part[IDM_BOOT_SLICE].p_size =
 	    idm_cyls_to_secs(IDM_BOOT_SLICE_RES_CYL, nsecs);
+
+	first_available_cylinder += IDM_BOOT_SLICE_RES_CYL;
 #endif
 
 	/*
@@ -1762,8 +1795,8 @@
 	 */
 
 	if (fl_slice_def_layout) {
-		uint32_t	cyls_available = geom.dkg_ncyl
-		    - IDM_BOOT_SLICE_RES_CYL;
+		uint32_t	cyls_available = geom.dkg_ncyl -
+		    first_available_cylinder;
 
 		if (create_swap_slice) {
 			uint32_t	cyls_swap = 0;
@@ -1772,10 +1805,10 @@
 
 			if (cyls_swap != 0) {
 				extvtoc.v_part[1].p_start = idm_cyls_to_secs(
-				    IDM_BOOT_SLICE_RES_CYL, nsecs);
+				    first_available_cylinder, nsecs);
 
 				idm_debug_print(LS_DBGLVL_INFO,
-				    "%ld cyls were dedicated to swap slice\n",
+				    "%lu cyls were dedicated to swap slice\n",
 				    cyls_swap);
 
 				extvtoc.v_part[1].p_size =
@@ -1783,6 +1816,8 @@
 
 				extvtoc.v_part[1].p_tag = V_SWAP;
 				extvtoc.v_part[1].p_flag = V_UNMNT;
+
+				first_available_cylinder += cyls_swap;
 			} else {
 				idm_debug_print(LS_DBGLVL_WARN,
 				    "Space for swap slice s1 not available\n");
@@ -1793,8 +1828,8 @@
 		 * Slice 0 goes after slice 1, so that it can grow up if
 		 * there is additional free space available.
 		 */
-		extvtoc.v_part[0].p_start = extvtoc.v_part[1].p_start +
-		    extvtoc.v_part[1].p_size;
+		extvtoc.v_part[0].p_start =
+		    idm_cyls_to_secs(first_available_cylinder, nsecs);
 
 		extvtoc.v_part[0].p_size =
 		    idm_cyls_to_secs(cyls_available, nsecs);
--- a/usr/src/lib/libti/ti_dm.h	Wed Jan 21 18:44:40 2009 -0700
+++ b/usr/src/lib/libti/ti_dm.h	Thu Jan 22 16:28:37 2009 +0100
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -113,9 +113,7 @@
 #define	IDM_LAST_STDSLICE	7	/* last user accessible slice */
 
 /* 1st cylinder is dedicated to BOOT slice on x86 */
-#ifdef sparc
-#define	IDM_BOOT_SLICE_RES_CYL	0
-#else
+#ifndef sparc
 #define	IDM_BOOT_SLICE_RES_CYL	1
 #endif
 
@@ -124,24 +122,20 @@
 
 /* macros */
 
-/* translate cylinders to sectors */
-
-#define	idm_cyls_to_secs(c, nsec)	((c)*(nsec))
-
 /*
  * translate megabytes to cylinders - round appropriately
  * cyls = (mb * 1024 * 1024) / (nsecs * 512)
- * TODO: find appropriate symbolic constant for 512
- * which represents # of bytes per sector
+ * TODO: This will need to be changed when support for
+ * different sector size (other than 512 bytes) is implemented
  */
 
-#define	idm_mbs_to_cyls(mb, nsec)	((2048ULL*(mb)+(nsecs)/2)/(nsec))
+#define	idm_mbs_to_cyls(mb, nsec)	((2048ULL*(mb)+(nsec)/2)/(nsec))
 
 /*
  * translate cylinders to megabytes - round appropriately
  * mbs = (cyls * nsecs * 512) / (1024*1024)
- * TODO: find appropriate symbolic constant for 512
- * which represents # of bytes per sector
+ * TODO: This will need to be changed when support for
+ * different sector size (other than 512 bytes) is implemented
  */
 
 #define	idm_cyls_to_mbs(cyls, nsec)	(((cyls)*(nsecs)+1)/2048ULL)
--- a/usr/src/pkgdefs/Makefile	Wed Jan 21 18:44:40 2009 -0700
+++ b/usr/src/pkgdefs/Makefile	Thu Jan 22 16:28:37 2009 +0100
@@ -19,7 +19,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 #
@@ -39,6 +39,7 @@
 	SUNWgui-install \
 	SUNWinstall \
 	SUNWinstall-libs \
+	SUNWinstall-test \
 	SUNWinstalladm-tools \
 	SUNWslim-utils \
 	SUNWstosreg \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/pkgdefs/SUNWinstall-test/Makefile	Thu Jan 22 16:28:37 2009 +0100
@@ -0,0 +1,34 @@
+#
+# 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 2009 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+
+include ../Makefile.com
+
+.KEEP_STATE:
+
+all: $(FILES)
+
+install: all .WAIT pkg
+
+include ../Makefile.targ
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/pkgdefs/SUNWinstall-test/depend	Thu Jan 22 16:28:37 2009 +0100
@@ -0,0 +1,44 @@
+#
+# 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 2009 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+
+#
+#
+# This package information file defines software dependencies associated
+# with the pkg.  You can define three types of pkg dependencies with this file:
+#	 P indicates a prerequisite for installation
+#	 I indicates an incompatible package
+#	 R indicates a reverse dependency
+# <pkg.abbr> see pkginfo(4), PKG parameter
+# <name> see pkginfo(4), NAME parameter
+# <version> see pkginfo(4), VERSION parameter
+# <arch> see pkginfo(4), ARCH parameter
+# <type> <pkg.abbr> <name>
+# 	(<arch>)<version>
+# 	(<arch>)<version>
+# 	...
+# <type> <pkg.abbr> <name>
+# ...
+
+P SUNWinstall	System install libraries and commands
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/pkgdefs/SUNWinstall-test/pkginfo.tmpl	Thu Jan 22 16:28:37 2009 +0100
@@ -0,0 +1,50 @@
+#
+# 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 2009 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+#
+
+#
+# This required package information file describes characteristics of the
+# package, such as package abbreviation, full package name, package version,
+# and package architecture.
+#
+PKG=SUNWinstall-test
+NAME="OpenSolaris install test drivers"
+ARCH="ISA"
+VERSION="1.0,REV=2008.02.05"
+SUNW_PRODNAME="SunOS"
+SUNW_PRODVERS="RELEASE/VERSION"
+SUNW_PKGVERS=1.0
+SUNW_PKGTYPE=root
+MAXINST=1000
+CATEGORY=system
+DESC="Test drivers for OpenSolaris installation"
+VENDOR=Sun Microsystems, Inc.
+HOTLINE=Please contact your local service provider
+EMAIL=
+CLASSES=none
+BASEDIR=/
+SUNW_PKG_ALLZONES=false
+SUNW_PKG_THISZONE=false
+SUNW_PKG_HOLLOW=false
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/pkgdefs/SUNWinstall-test/prototype_com	Thu Jan 22 16:28:37 2009 +0100
@@ -0,0 +1,54 @@
+#
+# 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 2009 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+#
+# This required package information file contains a list of package contents.
+# The 'pkgmk' command uses this file to identify the contents of a package
+# and their location on the development machine when building the package.
+# Can be created via a text editor or through use of the 'pkgproto' command.
+
+# packaging files
+i pkginfo=pkginfo
+i copyright=copyright
+i depend=depend
+
+!default 555 root bin
+
+d none opt 755 root sys
+d none opt/install-test 755 root sys
+d none opt/install-test/bin 755 root bin
+
+#
+# Target Discovery Test Drivers
+#
+f none opt/install-test/bin/test_td 555 root bin
+f none opt/install-test/bin/test_td_static 555 root bin
+f none opt/install-test/bin/tdmgtst 555 root bin
+f none opt/install-test/bin/tdmgtst_static 555 root bin
+
+#
+# Target Instantiation Test Driver
+#
+f none opt/install-test/bin/test_ti 555 root bin
+f none opt/install-test/bin/test_ti_static 555 root bin
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/pkgdefs/SUNWinstall-test/prototype_i386	Thu Jan 22 16:28:37 2009 +0100
@@ -0,0 +1,51 @@
+#
+# 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 2009 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+#
+
+#
+# This required package information file contains a list of package contents.
+# The 'pkgmk' command uses this file to identify the contents of a package
+# and their location on the development machine when building the package.
+# Can be created via a text editor or through use of the 'pkgproto' command.
+
+#!search <pathname pathname ...>        # where to find pkg objects
+#!include <filename>                    # include another 'prototype' file
+#!default <mode> <owner> <group>        # default used if not specified on entry
+#!<param>=<value>                       # puts parameter in pkg environment
+
+#
+# Include ISA independent files (prototype_com)
+#
+!include prototype_com
+#
+#
+#
+# List files which are i386 specific here
+#
+# source locations relative to the prototype file
+#
+#
+# SUNWinstall-test
+#
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/pkgdefs/SUNWinstall-test/prototype_sparc	Thu Jan 22 16:28:37 2009 +0100
@@ -0,0 +1,51 @@
+#
+# 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 2009 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+#
+
+#
+# This required package information file contains a list of package contents.
+# The 'pkgmk' command uses this file to identify the contents of a package
+# and their location on the development machine when building the package.
+# Can be created via a text editor or through use of the 'pkgproto' command.
+
+#!search <pathname pathname ...>        # where to find pkg objects
+#!include <filename>                    # include another 'prototype' file
+#!default <mode> <owner> <group>        # default used if not specified on entry
+#!<param>=<value>                       # puts parameter in pkg environment
+
+#
+# Include ISA independent files (prototype_com)
+#
+!include prototype_com
+#
+#
+#
+# List files which are SPARC specific here
+#
+# source locations relative to the prototype file
+#
+#
+# SUNWinstall-test
+#
--- a/usr/src/pkgdefs/common_files/copyright	Wed Jan 21 18:44:40 2009 -0700
+++ b/usr/src/pkgdefs/common_files/copyright	Thu Jan 22 16:28:37 2009 +0100
@@ -1,4 +1,4 @@
-Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 Use is subject to license terms.
 
 The contents of this file are subject to the terms of the