Subject: install/6947: sysinst can generate bogus disk labels because of swap defaults
To: None <gnats-bugs@gnats.netbsd.org>
From: Christoph Badura <bad@klicman.de>
List: netbsd-bugs
Date: 02/05/1999 20:46:59
>Number: 6947
>Category: install
>Synopsis: sysinst can create disklabels with the swap partition extending beyond the end of the disc
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: gnats-admin (GNATS administrator)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Feb 5 11:50:02 1999
>Last-Modified:
>Originator: Christoph Badura
>Organization:
>Release: 1.3I as of 1999/01/30 and 1.3.3 too.
>Environment:
System: NetBSD klic3.klicman.de 1.3I NetBSD 1.3I (BUFTEST) #127: Tue Feb 2 14:55:46 MET 1999 bad@klic3.klicman.de:/u/0/src/sys/arch/i386/compile/BUFTEST i386
>Description:
In md_make_bsd_partitions() the remaining space on the BSD partition isn't
been taken into account when the default swap partition size is computed.
>How-To-Repeat:
Start a 1.3.3 boot floppy, create a small NetBSD partition (say, 80MB),
select the custom installation partitioning option. Create a 60 MB root FS.
Select the default size for the swap partition (e.g. 32MB on i386).
Watch disklabel fail because the swap extends beyond the end of the 'c'
partition.
>Fix:
The following patch to sysinst fixes that problem for the "custom" layout
case. Note the patch to menuc/menu_sys.def at the end.
XXX md_make_bsd_partitions should be MI really and get defaults passed
in via parameters.
Index: defs.h
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/defs.h,v
retrieving revision 1.34
diff -r1.34 defs.h
64a65,69
> #ifndef MIN /* XXX some files pull in sys/param.h which defines this too */
> #define MIN(a,b) (((a)<(b))?(a):(b))
> #define MAX(a,b) (((a)<(b))?(a):(b))
> #endif
>
Index: arch/alpha/md.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/alpha/md.c,v
retrieving revision 1.8
diff -r1.8 md.c
159c159
< int i, part;
---
> int i, part, swapsz;
263,264c263,264
< i = NUMSEC(2 * (rammb < 32 ? 32 : rammb),
< MEG/sectorsize, dlcylsize) + partstart;
---
> swapsz = MIN(remain, 2 * (rammb < 32 ? 32 : rammb));
> i = NUMSEC(swapsz, MEG/sectorsize, dlcylsize) + partstart;
Index: arch/arm32/md.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/arm32/md.c,v
retrieving revision 1.12
diff -r1.12 md.c
276c276
< int i, part;
---
> int i, part, swapsz;
394,395c394,395
< i = NUMSEC(4 * (rammb < 32 ? 32 : rammb),
< MEG/sectorsize, dlcylsize) + partstart;
---
> swapsz = MIN(remain, 4 * (rammb < 32 ? 32 : rammb));
> i = NUMSEC(swapsz, MEG/sectorsize, dlcylsize) + partstart;
Index: arch/bebox/md.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/bebox/md.c,v
retrieving revision 1.5
diff -r1.5 md.c
155c155
< int part;
---
> int part, swapsz;
254,255c254,255
< i = NUMSEC( 2 * (rammb < 16 ? 16 : rammb),
< MEG/sectorsize, dlcylsize) + partstart;
---
> swapsz = MIN(remain, 2 * (rammb < 16 ? 16 : rammb)):
> i = NUMSEC(swapsz, MEG/sectorsize, dlcylsize) + partstart;
Index: arch/i386/md.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/i386/md.c,v
retrieving revision 1.19
diff -r1.19 md.c
155c155
< int part;
---
> int part, swapsz;
254,255c254,255
< i = NUMSEC( 2 * (rammb < 16 ? 16 : rammb),
< MEG/sectorsize, dlcylsize) + partstart;
---
> swapsz = MIN(remain, 2 * (rammb < 16 ? 16 : rammb));
> i = NUMSEC(swapsz, MEG/sectorsize, dlcylsize) + partstart;
Index: arch/macppc/md.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/macppc/md.c,v
retrieving revision 1.5
diff -r1.5 md.c
160c160
< int i, part;
---
> int i, part, swapsz;
264,265c264,265
< i = NUMSEC(2 * (rammb < 32 ? 32 : rammb),
< MEG/sectorsize, dlcylsize) + partstart;
---
> swapsz = MIN(remain, 2 * (rammb < 32 ? 32 : rammb));
> i = NUMSEC(swapsz, MEG/sectorsize, dlcylsize) + partstart;
Index: arch/pc532/md.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/pc532/md.c,v
retrieving revision 1.12
diff -r1.12 md.c
132c132
< int part, partsize, partstart, remain;
---
> int part, swapsz, partsize, partstart, remain;
228,229c228,229
< i = NUMSEC( 2 * (rammb < 16 ? 16 : rammb),
< MEG/sectorsize, dlcylsize) + partstart;
---
> swapsz = MIN(remain, 2 * (rammb < 16 ? 16 : rammb));
> i = NUMSEC(swapsz, MEG/sectorsize, dlcylsize) + partstart;
Index: arch/pmax/md.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/pmax/md.c,v
retrieving revision 1.23
diff -r1.23 md.c
166a167
> int swapsz;
271,272c272,273
< i = NUMSEC(layoutkind * 2 * (rammb < 32 ? 32 : rammb),
< MEG/sectorsize, dlcylsize) + partstart;
---
> swapsz = MIN(remain, 2 * (rammb < 32 ? 32 : rammb));
> i = NUMSEC(swapsz, MEG/sectorsize, dlcylsize) + partstart;
Index: arch/sparc/md.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/sparc/md.c,v
retrieving revision 1.7
diff -r1.7 md.c
159c159
< int remain;
---
> int remain, swapsz;
262,263c262,263
< i = NUMSEC(2 * (rammb < 32 ? 32 : rammb),
< MEG/sectorsize, dlcylsize) + partstart;
---
> swapsz = MIN(remain, 2 * (rammb < 32 ? 32 : rammb));
> i = NUMSEC(swapsz, MEG/sectorsize, dlcylsize) + partstart;
Index: arch/vax/md.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/vax/md.c,v
retrieving revision 1.2
diff -r1.2 md.c
163c163
< int remain;
---
> int remain, swapsz;
266,267c266,267
< i = NUMSEC(2 * (rammb < 32 ? 32 : rammb),
< MEG/sectorsize, dlcylsize) + partstart;
---
> swapsz = MIN(remain, 2 * (rammb < 32 ? 32 : rammb));
> i = NUMSEC(swapsz, MEG/sectorsize, dlcylsize) + partstart;
? menu_sys.defs
Plus this patch to usr.bin/menuc/menu_sys.def
Index: menu_sys.def
===================================================================
RCS file: /cvsroot/src/usr.bin/menuc/menu_sys.def,v
retrieving revision 1.15
diff -r1.15 menu_sys.def
96,97d95
< #define MAX(x,y) ((x)>(y)?(x):(y))
< #define MIN(x,y) ((x)<(y)?(x):(y))
>Audit-Trail:
>Unformatted: