Module Name:    src
Committed By:   bouyer
Date:           Mon May 18 19:35:14 UTC 2009

Modified Files:
        src/distrib/utils/sysinst [netbsd-5]: bsddisklabel.c defs.h disks.c
            mbr.c mbr.h msg.mi.de msg.mi.en msg.mi.es msg.mi.fr msg.mi.pl
            savenewlabel.c
        src/distrib/utils/sysinst/arch/i386 [netbsd-5]: md.c

Log Message:
Pull up following revision(s) (requested by sborrill in ticket #758):
        distrib/utils/sysinst/mbr.c: revision 1.80
        distrib/utils/sysinst/msg.mi.en: revision 1.155
        distrib/utils/sysinst/disks.c: revision 1.105
        distrib/utils/sysinst/arch/i386/md.c: revision 1.122
        distrib/utils/sysinst/savenewlabel.c: revision 1.6
        distrib/utils/sysinst/mbr.h: revision 1.23
        distrib/utils/sysinst/defs.h: revision 1.143
        distrib/utils/sysinst/msg.mi.pl: revision 1.65
        distrib/utils/sysinst/bsddisklabel.c: revision 1.52
        distrib/utils/sysinst/msg.mi.es: revision 1.26
        distrib/utils/sysinst/msg.mi.de: revision 1.49
        distrib/utils/sysinst/msg.mi.fr: revision 1.106
Support drives over 1TB in size (i.e. stop errors like drive is -654343MB in
size).
Error if drive is over 2TB in size (and thus over the disklabel limit).


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.45.4.1 src/distrib/utils/sysinst/bsddisklabel.c
cvs rdiff -u -r1.136 -r1.136.2.1 src/distrib/utils/sysinst/defs.h
cvs rdiff -u -r1.100.2.2 -r1.100.2.3 src/distrib/utils/sysinst/disks.c
cvs rdiff -u -r1.79 -r1.79.14.1 src/distrib/utils/sysinst/mbr.c
cvs rdiff -u -r1.22 -r1.22.30.1 src/distrib/utils/sysinst/mbr.h
cvs rdiff -u -r1.43.8.3 -r1.43.8.4 src/distrib/utils/sysinst/msg.mi.de
cvs rdiff -u -r1.149.14.3 -r1.149.14.4 src/distrib/utils/sysinst/msg.mi.en
cvs rdiff -u -r1.21.14.2 -r1.21.14.3 src/distrib/utils/sysinst/msg.mi.es
cvs rdiff -u -r1.101.14.2 -r1.101.14.3 src/distrib/utils/sysinst/msg.mi.fr
cvs rdiff -u -r1.60.14.2 -r1.60.14.3 src/distrib/utils/sysinst/msg.mi.pl
cvs rdiff -u -r1.5 -r1.5.42.1 src/distrib/utils/sysinst/savenewlabel.c
cvs rdiff -u -r1.119 -r1.119.2.1 src/distrib/utils/sysinst/arch/i386/md.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/utils/sysinst/bsddisklabel.c
diff -u src/distrib/utils/sysinst/bsddisklabel.c:1.45 src/distrib/utils/sysinst/bsddisklabel.c:1.45.4.1
--- src/distrib/utils/sysinst/bsddisklabel.c:1.45	Sat May 24 11:06:53 2008
+++ src/distrib/utils/sysinst/bsddisklabel.c	Mon May 18 19:35:14 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: bsddisklabel.c,v 1.45 2008/05/24 11:06:53 martin Exp $	*/
+/*	$NetBSD: bsddisklabel.c,v 1.45.4.1 2009/05/18 19:35:14 bouyer Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -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" PRIi64 "%8s%10" PRIi64 "%10" PRIi64 " %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, "%" PRIi64 "%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: src/distrib/utils/sysinst/defs.h
diff -u src/distrib/utils/sysinst/defs.h:1.136 src/distrib/utils/sysinst/defs.h:1.136.2.1
--- src/distrib/utils/sysinst/defs.h:1.136	Fri Aug  8 02:54:06 2008
+++ src/distrib/utils/sysinst/defs.h	Mon May 18 19:35:14 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.136 2008/08/08 02:54:06 simonb Exp $	*/
+/*	$NetBSD: defs.h,v 1.136.2.1 2009/05/18 19:35:14 bouyer Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -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;
+	daddr_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: src/distrib/utils/sysinst/disks.c
diff -u src/distrib/utils/sysinst/disks.c:1.100.2.2 src/distrib/utils/sysinst/disks.c:1.100.2.3
--- src/distrib/utils/sysinst/disks.c:1.100.2.2	Mon Mar  2 19:39:30 2009
+++ src/distrib/utils/sysinst/disks.c	Mon May 18 19:35:14 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: disks.c,v 1.100.2.2 2009/03/02 19:39:30 snj Exp $ */
+/*	$NetBSD: disks.c,v 1.100.2.3 2009/05/18 19:35:14 bouyer Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -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 */
@@ -218,7 +223,7 @@
 void
 fmt_fspart(menudesc *m, int ptn, void *arg)
 {
-	int poffset, psize, pend;
+	unsigned int poffset, psize, pend;
 	const char *desc;
 	static const char *Yes, *No;
 	partinfo *p = bsdlabel + ptn;

Index: src/distrib/utils/sysinst/mbr.c
diff -u src/distrib/utils/sysinst/mbr.c:1.79 src/distrib/utils/sysinst/mbr.c:1.79.14.1
--- src/distrib/utils/sysinst/mbr.c:1.79	Fri Dec 28 00:48:43 2007
+++ src/distrib/utils/sysinst/mbr.c	Mon May 18 19:35:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbr.c,v 1.79 2007/12/28 00:48:43 dholland Exp $ */
+/*	$NetBSD: mbr.c,v 1.79.14.1 2009/05/18 19:35:13 bouyer Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -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: src/distrib/utils/sysinst/mbr.h
diff -u src/distrib/utils/sysinst/mbr.h:1.22 src/distrib/utils/sysinst/mbr.h:1.22.30.1
--- src/distrib/utils/sysinst/mbr.h:1.22	Wed Apr  5 16:55:05 2006
+++ src/distrib/utils/sysinst/mbr.h	Mon May 18 19:35:14 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbr.h,v 1.22 2006/04/05 16:55:05 garbled Exp $	*/
+/*	$NetBSD: mbr.h,v 1.22.30.1 2009/05/18 19:35:14 bouyer Exp $	*/
 
 /*
  * Copyright 1997, 1988 Piermont Information Systems Inc.
@@ -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: src/distrib/utils/sysinst/msg.mi.de
diff -u src/distrib/utils/sysinst/msg.mi.de:1.43.8.3 src/distrib/utils/sysinst/msg.mi.de:1.43.8.4
--- src/distrib/utils/sysinst/msg.mi.de:1.43.8.3	Thu Jan 22 22:45:15 2009
+++ src/distrib/utils/sysinst/msg.mi.de	Mon May 18 19:35:14 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg.mi.de,v 1.43.8.3 2009/01/22 22:45:15 snj Exp $	*/
+/*	$NetBSD: msg.mi.de,v 1.43.8.4 2009/05/18 19:35:14 bouyer Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -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.)
@@ -257,7 +263,7 @@
 }
 
 message fspart_row
-{%9d %9d %10d %-10s %-5s %-5s %s}
+{%9lu %9lu %10lu %-10s %-5s %-5s %s}
 
 message show_all_unused_partitions
 {Alle unbenutzten Partitionen anzeigen}

Index: src/distrib/utils/sysinst/msg.mi.en
diff -u src/distrib/utils/sysinst/msg.mi.en:1.149.14.3 src/distrib/utils/sysinst/msg.mi.en:1.149.14.4
--- src/distrib/utils/sysinst/msg.mi.en:1.149.14.3	Thu Jan 22 22:45:15 2009
+++ src/distrib/utils/sysinst/msg.mi.en	Mon May 18 19:35:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg.mi.en,v 1.149.14.3 2009/01/22 22:45:15 snj Exp $	*/
+/*	$NetBSD: msg.mi.en,v 1.149.14.4 2009/05/18 19:35:13 bouyer Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -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.
@@ -250,7 +257,7 @@
 }
 
 message fspart_row
-{%9d %9d %9d %-10s %-5s %-5s %s}
+{%9lu %9lu %9lu %-10s %-5s %-5s %s}
 
 message show_all_unused_partitions
 {Show all unused partitions}

Index: src/distrib/utils/sysinst/msg.mi.es
diff -u src/distrib/utils/sysinst/msg.mi.es:1.21.14.2 src/distrib/utils/sysinst/msg.mi.es:1.21.14.3
--- src/distrib/utils/sysinst/msg.mi.es:1.21.14.2	Thu Jan 22 22:45:15 2009
+++ src/distrib/utils/sysinst/msg.mi.es	Mon May 18 19:35:14 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg.mi.es,v 1.21.14.2 2009/01/22 22:45:15 snj Exp $	*/
+/*	$NetBSD: msg.mi.es,v 1.21.14.3 2009/05/18 19:35:14 bouyer Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -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.
@@ -255,7 +262,7 @@
 }
 
 message fspart_row
-{%10d %9d %10d %-10s %-5s %-5s %s}
+{%10lu %9lu %10lu %-10s %-5s %-5s %s}
 
 message show_all_unused_partitions
 {Mostrar todas las particiones no usadas}

Index: src/distrib/utils/sysinst/msg.mi.fr
diff -u src/distrib/utils/sysinst/msg.mi.fr:1.101.14.2 src/distrib/utils/sysinst/msg.mi.fr:1.101.14.3
--- src/distrib/utils/sysinst/msg.mi.fr:1.101.14.2	Thu Jan 22 22:45:15 2009
+++ src/distrib/utils/sysinst/msg.mi.fr	Mon May 18 19:35:14 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg.mi.fr,v 1.101.14.2 2009/01/22 22:45:15 snj Exp $	*/
+/*	$NetBSD: msg.mi.fr,v 1.101.14.3 2009/05/18 19:35:14 bouyer Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -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:
 
@@ -252,7 +259,7 @@
 }
 
 message fspart_row
-{%9d %9d %10d %-10s %-5s %-5s %s}
+{%9lu %9lu %10lu %-10s %-5s %-5s %s}
 
 message show_all_unused_partitions
 {Afficher les partitions libres}

Index: src/distrib/utils/sysinst/msg.mi.pl
diff -u src/distrib/utils/sysinst/msg.mi.pl:1.60.14.2 src/distrib/utils/sysinst/msg.mi.pl:1.60.14.3
--- src/distrib/utils/sysinst/msg.mi.pl:1.60.14.2	Thu Jan 22 22:45:15 2009
+++ src/distrib/utils/sysinst/msg.mi.pl	Mon May 18 19:35:14 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg.mi.pl,v 1.60.14.2 2009/01/22 22:45:15 snj Exp $	*/
+/*	$NetBSD: msg.mi.pl,v 1.60.14.3 2009/05/18 19:35:14 bouyer Exp $	*/
 /*	Based on english version: */
 /*	NetBSD: msg.mi.pl,v 1.36 2004/04/17 18:55:35 atatat Exp       */
 
@@ -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:
 
@@ -244,7 +251,7 @@
 }
 
 message fspart_row
-{%9d %9d %10d %-10s %-7s %-9s %s}
+{%9lu %9lu %10lu %-10s %-7s %-9s %s}
 
 message show_all_unused_partitions
 {Pokaz wszystkie nieuzywane partycje}

Index: src/distrib/utils/sysinst/savenewlabel.c
diff -u src/distrib/utils/sysinst/savenewlabel.c:1.5 src/distrib/utils/sysinst/savenewlabel.c:1.5.42.1
--- src/distrib/utils/sysinst/savenewlabel.c:1.5	Sun Jul 27 08:57:27 2003
+++ src/distrib/utils/sysinst/savenewlabel.c	Mon May 18 19:35:14 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: savenewlabel.c,v 1.5 2003/07/27 08:57:27 dsl Exp $	*/
+/*	$NetBSD: savenewlabel.c,v 1.5.42.1 2009/05/18 19:35:14 bouyer Exp $	*/
 
 /*
  * Copyright 1997 Jonathan Stone
@@ -36,13 +36,14 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: savenewlabel.c,v 1.5 2003/07/27 08:57:27 dsl Exp $");
+__RCSID("$NetBSD: savenewlabel.c,v 1.5.42.1 2009/05/18 19:35:14 bouyer Exp $");
 #endif
 
 #include <sys/types.h>
 #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: src/distrib/utils/sysinst/arch/i386/md.c
diff -u src/distrib/utils/sysinst/arch/i386/md.c:1.119 src/distrib/utils/sysinst/arch/i386/md.c:1.119.2.1
--- src/distrib/utils/sysinst/arch/i386/md.c:1.119	Tue Oct  7 09:58:15 2008
+++ src/distrib/utils/sysinst/arch/i386/md.c	Mon May 18 19:35:14 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: md.c,v 1.119 2008/10/07 09:58:15 abs Exp $ */
+/*	$NetBSD: md.c,v 1.119.2.1 2009/05/18 19:35:14 bouyer Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -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)

Reply via email to