Index: distrib/utils/sysinst/bsddisklabel.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/bsddisklabel.c,v
retrieving revision 1.45
diff -u -r1.45 bsddisklabel.c
--- distrib/utils/sysinst/bsddisklabel.c	24 May 2008 11:06:53 -0000	1.45
+++ distrib/utils/sysinst/bsddisklabel.c	21 Apr 2009 12:22:15 -0000
@@ -92,7 +92,7 @@
 #endif
 
 int
-save_ptn(int ptn, int start, int size, int fstype, const char *mountpt)
+save_ptn(int ptn, daddr_t start, daddr_t size, int fstype, const char *mountpt)
 {
 	static int maxptn;
 	partinfo *p;
@@ -143,7 +143,7 @@
 	struct ptn_info *pi = arg;
 	struct ptn_size *p;
 	int sm = MEG / sectorsize;
-	int size;
+	daddr_t size;
 	char inc_free[12];
 
 	p = &pi->ptn_sizes[opt];
@@ -153,11 +153,11 @@
 	}
 	size = p->size;
 	if (p == pi->pool_part)
-		snprintf(inc_free, sizeof inc_free, "(%u)", 
+		snprintf(inc_free, sizeof inc_free, "(%" PRIi64 ")", 
 		    (size + pi->free_space) / sm);
 	else
 		inc_free[0] = 0;
-	wprintw(m->mw, "%6u%8s%10u%10u %c %s",
+	wprintw(m->mw, "%6" PRIu64 "%8s%10" PRIu64 "%10" PRIu64 " %c %s",
 		size / sm, inc_free, size / dlcylsize, size,
 		p == pi->pool_part ? '+' : ' ', p->mount);
 }
@@ -187,11 +187,11 @@
 	if (pi->free_space >= 0)
 		snprintf(pi->exit_msg, sizeof pi->exit_msg,
 			msg_string(MSG_fssizesok),
-			pi->free_space / sizemult, multname, pi->free_parts);
+			(int)(pi->free_space / sizemult), multname, pi->free_parts);
 	else
 		snprintf(pi->exit_msg, sizeof pi->exit_msg,
 			msg_string(MSG_fssizesbad),
-			-pi->free_space / sizemult, multname, -pi->free_space);
+			(int)(-pi->free_space / sizemult), multname, (uint) -pi->free_space);
 
 	set_menu_numopts(pi->menu_no, m - pi->ptn_menus);
 }
@@ -204,7 +204,7 @@
 	char answer[10];
 	char dflt[10];
 	char *cp;
-	int size, old_size;
+	daddr_t size, old_size;
 	int mult;
 
 	p = pi->ptn_sizes + m->cursel;
@@ -225,7 +225,7 @@
 	if (size == 0)
 		size = p->dflt_size;
 	size /= sizemult;
-	snprintf(dflt, sizeof dflt, "%d%s",
+	snprintf(dflt, sizeof dflt, "%" PRIu64 "%s",
 	    size, p == pi->pool_part ? "+" : "");
 
 	for (;;) {
@@ -334,13 +334,13 @@
 }
 
 void
-get_ptn_sizes(int part_start, int sectors, int no_swap)
+get_ptn_sizes(daddr_t part_start, daddr_t sectors, int no_swap)
 {
 	int i;
 	int maxpart = getmaxpartitions();
 	int sm;				/* sectors in 1MB */
 	struct ptn_size *p;
-	int size;
+	daddr_t size;
 
 	static struct ptn_info pi = { -1, {
 #define PI_ROOT 0
@@ -516,9 +516,9 @@
 	int i;
 	int part;
 	int maxpart = getmaxpartitions();
-	int partstart;
+	daddr_t partstart;
 	int part_raw, part_bsd;
-	int ptend;
+	daddr_t ptend;
 	int no_swap = 0, valid_part = -1;
 	partinfo *p;
 
@@ -536,7 +536,7 @@
 
 	/* Ask for layout type -- standard or special */
 	msg_display(MSG_layout,
-		    ptsize / (MEG / sectorsize),
+		    (int) (ptsize / (MEG / sectorsize)),
 		    DEFROOTSIZE + DEFSWAPSIZE + DEFUSRSIZE,
 		    DEFROOTSIZE + DEFSWAPSIZE + DEFUSRSIZE + XNEEDMB);
 
Index: distrib/utils/sysinst/defs.h
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/defs.h,v
retrieving revision 1.136
diff -u -r1.136 defs.h
--- distrib/utils/sysinst/defs.h	8 Aug 2008 02:54:06 -0000	1.136
+++ distrib/utils/sysinst/defs.h	21 Apr 2009 12:22:15 -0000
@@ -198,14 +198,14 @@
 	struct ptn_size {
 		int	ptn_id;
 		char	mount[20];
-		int	dflt_size;
-		int	size;
+		daddr_t	dflt_size;
+		daddr_t	size;
 		int	limit;
 		int	changed;
 	}		ptn_sizes[MAXPARTITIONS + 1];	/* +1 for delete code */
 	menu_ent	ptn_menus[MAXPARTITIONS + 1];	/* +1 for unit chg */
 	int		free_parts;
-	int		free_space;
+	int64_t		free_space;
 	struct ptn_size	*pool_part;
 	char		exit_msg[70];
 };
@@ -239,13 +239,14 @@
 const char *disktype;		/* ST506, SCSI, ... */
 
 /* Area of disk we can allocate, start and size in disk sectors. */
-int ptstart, ptsize;
+daddr_t ptstart, ptsize;
 /* If we have an MBR boot partition, start and size in sectors */
 int bootstart, bootsize;
 
 /* Actual values for current disk - set by find_disks() or md_get_info() */
 int sectorsize;
-int dlcyl, dlhead, dlsec, dlsize, dlcylsize;
+int dlcyl, dlhead, dlsec, dlcylsize;
+daddr_t dlsize;
 int current_cylsize;
 unsigned int root_limit;		/* BIOS (etc) read limit */
 
@@ -448,11 +449,11 @@
 
 /* from bsddisklabel.c */
 int	make_bsd_partitions(void);
-int	save_ptn(int, int, int, int, const char *);
+int	save_ptn(int, daddr_t, daddr_t, int, const char *);
 void	set_ptn_titles(menudesc *, int, void *);
 void	set_ptn_menu(struct ptn_info *);
 int	set_ptn_size(menudesc *, void *);
-void	get_ptn_sizes(int, int, int);
+void	get_ptn_sizes(daddr_t, daddr_t, int);
 
 /* from aout2elf.c */
 int move_aout_libs(void);
Index: distrib/utils/sysinst/disks.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/disks.c,v
retrieving revision 1.100.2.2
diff -u -r1.100.2.2 disks.c
--- distrib/utils/sysinst/disks.c	2 Mar 2009 19:39:30 -0000	1.100.2.2
+++ distrib/utils/sysinst/disks.c	21 Apr 2009 12:22:15 -0000
@@ -203,6 +203,11 @@
 	no_mbr = disk->dd_no_mbr;
 	if (dlsize == 0)
 		dlsize = disk->dd_cyl * disk->dd_head * disk->dd_sec;
+	if (dlsize > UINT32_MAX) {
+		msg_display(MSG_toobigdisklabel);	
+		process_menu(MENU_ok, NULL);
+		return -1;	
+	}
 	dlcylsize = dlhead * dlsec;
 
 	/* Get existing/default label */
Index: distrib/utils/sysinst/mbr.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/mbr.c,v
retrieving revision 1.79
diff -u -r1.79 mbr.c
--- distrib/utils/sysinst/mbr.c	28 Dec 2007 00:48:43 -0000	1.79
+++ distrib/utils/sysinst/mbr.c	21 Apr 2009 12:22:15 -0000
@@ -1682,11 +1682,12 @@
  */
 
 int
-guess_biosgeom_from_mbr(mbr_info_t *mbri, int *cyl, int *head, int *sec)
+guess_biosgeom_from_mbr(mbr_info_t *mbri, int *cyl, int *head, daddr_t *sec)
 {
 	struct mbr_sector *mbrs = &mbri->mbr;
 	struct mbr_partition *parts = &mbrs->mbr_parts[0];
-	int xcylinders, xheads, xsectors, i, j;
+	int xcylinders, xheads, i, j;
+	daddr_t xsectors;
 	int c1, h1, s1, c2, h2, s2;
 	unsigned long a1, a2;
 	uint64_t num, denom;
Index: distrib/utils/sysinst/mbr.h
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/mbr.h,v
retrieving revision 1.22
diff -u -r1.22 mbr.h
--- distrib/utils/sysinst/mbr.h	5 Apr 2006 16:55:05 -0000	1.22
+++ distrib/utils/sysinst/mbr.h	21 Apr 2009 12:22:15 -0000
@@ -113,7 +113,7 @@
 int     read_mbr(const char *, mbr_info_t *);
 int     write_mbr(const char *, mbr_info_t *, int);
 int     valid_mbr(struct mbr_sector *);
-int	guess_biosgeom_from_mbr(mbr_info_t *, int *, int *, int *);
+int	guess_biosgeom_from_mbr(mbr_info_t *, int *, int *, daddr_t *);
 int	md_bios_info(char *);
 void	set_bios_geom(int, int, int);
 int	otherpart(int);
Index: distrib/utils/sysinst/msg.mi.de
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/msg.mi.de,v
retrieving revision 1.43.8.3
diff -u -r1.43.8.3 msg.mi.de
--- distrib/utils/sysinst/msg.mi.de	22 Jan 2009 22:45:15 -0000	1.43.8.3
+++ distrib/utils/sysinst/msg.mi.de	21 Apr 2009 12:22:16 -0000
@@ -230,7 +230,7 @@
 {Akzeptieren. Freier Speicherplatz: %d %s, %d freie Partitionen.}
 
 message fssizesbad
-{Reduzieren der Partitionsgrößen um %d %s (%d Sektoren).}
+{Reduzieren der Partitionsgrößen um %d %s (%u Sektoren).}
 
 message startoutsidedisk
 {Der Startwert, den Sie angegeben haben, liegt jenseits des Endes der
@@ -245,6 +245,12 @@
 Drücken Sie die Eingabetaste um fortzufahren.
 }
 
+message toobigdisklabel
+{
+Diese Platte ist zu groß für eine
+disklabel-Partitionstabelle und kann deswegen weder für
+boot- noch für root-Partitionen benutzt werden}
+
 message fspart
 {Nachfolgend sehen Sie Ihre BSD-Disklabel-Partitionen:
 (Dies ist die letzte Chance, diese zu ändern.)
Index: distrib/utils/sysinst/msg.mi.en
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/msg.mi.en,v
retrieving revision 1.149.14.3
diff -u -r1.149.14.3 msg.mi.en
--- distrib/utils/sysinst/msg.mi.en	22 Jan 2009 22:45:15 -0000	1.149.14.3
+++ distrib/utils/sysinst/msg.mi.en	21 Apr 2009 12:22:16 -0000
@@ -225,7 +225,7 @@
 {Accept partition sizes.  Free space %d %s, %d free partitions.}
 
 message fssizesbad
-{Reduce partition sizes by %d %s (%d sectors).}
+{Reduce partition sizes by %d %s (%u sectors).}
 
 message startoutsidedisk
 {The start value you specified is beyond the end of the disk.
@@ -238,6 +238,13 @@
 Type enter to continue
 }
 
+message toobigdisklabel
+{
+This disk is too large for a disklabel partition table to be used
+and hence cannot be used as a bootable disk or to hold the root
+partition.
+}
+
 message fspart
 {We now have your BSD-disklabel partitions as: 
 This is your last chance to change them.
Index: distrib/utils/sysinst/msg.mi.es
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/msg.mi.es,v
retrieving revision 1.21.14.2
diff -u -r1.21.14.2 msg.mi.es
--- distrib/utils/sysinst/msg.mi.es	22 Jan 2009 22:45:15 -0000	1.21.14.2
+++ distrib/utils/sysinst/msg.mi.es	21 Apr 2009 12:22:16 -0000
@@ -230,7 +230,7 @@
 {Aceptar los tamaños de las particiones.  Espacio libre %d %s, %d particiones libres.}
 
 message fssizesbad
-{Reducir los tamaños de las particiones en %d %s (%d sectores).}
+{Reducir los tamaños de las particiones en %d %s (%u sectores).}
 
 message startoutsidedisk
 {El valor del comienzo que ha especificado está mas allá del final del disco.
@@ -243,6 +243,13 @@
 Presione Intro para continuar
 }
 
+message toobigdisklabel
+{
+This disk is too large for a disklabel partition table to be used
+and hence cannot be used as a bootable disk or to hold the root
+partition.
+}
+
 message fspart
 {Sus particiones con etiquetas BSD están ahora así.
 Ésta es su última oportunidad para cambiarlas.
Index: distrib/utils/sysinst/msg.mi.fr
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/msg.mi.fr,v
retrieving revision 1.101.14.2
diff -u -r1.101.14.2 msg.mi.fr
--- distrib/utils/sysinst/msg.mi.fr	22 Jan 2009 22:45:15 -0000	1.101.14.2
+++ distrib/utils/sysinst/msg.mi.fr	21 Apr 2009 12:22:16 -0000
@@ -230,7 +230,7 @@
 {Taille de la partition acceptée. Libre: espace %d %s, %d partition}
 
 message fssizesbad
-{Réduire la taille de la partition de %d %s (%d secteurs).}
+{Réduire la taille de la partition de %d %s (%u secteurs).}
 
 message startoutsidedisk
 {La valeur que vous avez spécifiée est en dehors du disque
@@ -241,6 +241,13 @@
 La taille de la partition a été tronquée à %d %s.
 }
 
+message toobigdisklabel
+{
+Ce disque est trop grand pour qu'une table de partition soit utilisée.
+Il ne peut donc pas être utilisé en tant que disque démarrable ou
+contenir la partition racine.
+}
+
 message fspart
 {Vos partitions NetBSD sont les suivantes:
 
Index: distrib/utils/sysinst/msg.mi.pl
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/msg.mi.pl,v
retrieving revision 1.60.14.2
diff -u -r1.60.14.2 msg.mi.pl
--- distrib/utils/sysinst/msg.mi.pl	22 Jan 2009 22:45:15 -0000	1.60.14.2
+++ distrib/utils/sysinst/msg.mi.pl	21 Apr 2009 12:22:17 -0000
@@ -222,7 +222,7 @@
 {Zaakceptuj rozmiary partycji. Wolne miejsce %d %s, %d wolnych partycji.}
 
 message fssizesbad
-{Zmniejsz rozmiary partycji o %d %s (%d sektorow).}
+{Zmniejsz rozmiary partycji o %d %s (%u sektorow).}
 
 message startoutsidedisk
 {Wartosc poczatkowa ktora podales jest poza koncem dysku.
@@ -233,6 +233,13 @@
 twojej partycji zostal zmniejszony do %d %s.
 }
 
+message toobigdisklabel
+{
+This disk is too large for a disklabel partition table to be used
+and hence cannot be used as a bootable disk or to hold the root
+partition.
+}
+
 message fspart
 {Mamy teraz twoje partycje BSD-disklabel jako:
 
Index: distrib/utils/sysinst/savenewlabel.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/savenewlabel.c,v
retrieving revision 1.5
diff -u -r1.5 savenewlabel.c
--- distrib/utils/sysinst/savenewlabel.c	27 Jul 2003 08:57:27 -0000	1.5
+++ distrib/utils/sysinst/savenewlabel.c	21 Apr 2009 12:22:17 -0000
@@ -43,6 +43,7 @@
 #include <errno.h>
 #include <stdio.h>
 #include <fcntl.h>
+#include <inttypes.h>
 #include <util.h>
 #include <unistd.h>
 #include <sys/dkio.h>
@@ -59,6 +60,12 @@
 	FILE *f;
 	int i;
 
+	/*
+	  N.B. disklabels only support up to 2TB (32-bit field for sectors).
+	  This function explicitly narrows from daddr_t (64-bit unsigned) to
+	  uint32_t when writing the disklabel.
+	 */
+
 	/* Create the disktab.preinstall */
 	f = fopen("/tmp/disktab", "w");
 	if (logging)
@@ -75,17 +82,18 @@
 	scripting_fprintf(f, "%s|NetBSD installation generated:\\\n", bsddiskname);
 	scripting_fprintf(f, "\t:dt=%s:ty=winchester:\\\n", disktype);
 	scripting_fprintf(f, "\t:nc#%d:nt#%d:ns#%d:\\\n", dlcyl, dlhead, dlsec);
-	scripting_fprintf(f, "\t:sc#%d:su#%d:\\\n", dlhead*dlsec, dlsize);
+	scripting_fprintf(f, "\t:sc#%d:su#%" PRIu32 ":\\\n", dlhead*dlsec,
+	    (uint32_t)dlsize);
 	scripting_fprintf(f, "\t:se#%d:%s\\\n", sectorsize, doessf);
 	for (i = 0; i < nparts; i++) {
-		scripting_fprintf(f, "\t:p%c#%d:o%c#%d:t%c=%s:",
-		    'a'+i, bsdlabel[i].pi_size,
-		    'a'+i, bsdlabel[i].pi_offset,
+		scripting_fprintf(f, "\t:p%c#%" PRIu32 ":o%c#%" PRIu32 ":t%c=%s:",
+		    'a'+i, (uint32_t)bsdlabel[i].pi_size,
+		    'a'+i, (uint32_t)bsdlabel[i].pi_offset,
 		    'a'+i, fstypenames[bsdlabel[i].pi_fstype]);
 		if (PI_ISBSDFS(&bsdlabel[i]))
-			scripting_fprintf (f, "b%c#%d:f%c#%d:ta=4.2BSD:",
-			   'a'+i, bsdlabel[i].pi_fsize * bsdlabel[i].pi_frag,
-			   'a'+i, bsdlabel[i].pi_fsize);
+			scripting_fprintf (f, "b%c#%" PRIu32 ":f%c#%" PRIu32 ":ta=4.2BSD:",
+			   'a'+i, (uint32_t)(bsdlabel[i].pi_fsize * bsdlabel[i].pi_frag),
+			   'a'+i, (uint32_t)bsdlabel[i].pi_fsize);
 	
 		if (i < nparts - 1)
 			scripting_fprintf(f, "\\\n");
Index: distrib/utils/sysinst/arch/i386/md.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/i386/md.c,v
retrieving revision 1.119
diff -u -r1.119 md.c
--- distrib/utils/sysinst/arch/i386/md.c	7 Oct 2008 09:58:15 -0000	1.119
+++ distrib/utils/sysinst/arch/i386/md.c	21 Apr 2009 12:22:18 -0000
@@ -497,7 +497,8 @@
 	size_t len;
 	struct biosdisk_info *bip;
 	struct nativedisk_info *nip = NULL, *nat;
-	int cyl, head, sec;
+	int cyl, head;
+	daddr_t sec;
 
 	if (disklist == NULL) {
 		if (sysctl(mib, 2, NULL, &len, NULL, 0) < 0)
