Correct bad memory reference when dumpdev == NODEV (i.e. DISKLESS).

This commit is contained in:
gwr 1994-08-14 22:47:28 +00:00
parent 8a15866490
commit 486ad2cc03
2 changed files with 49 additions and 13 deletions

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91
* $Id: autoconf.c,v 1.9 1994/07/27 00:21:16 mycroft Exp $
* $Id: autoconf.c,v 1.10 1994/08/14 22:47:28 gwr Exp $
*/
/*
@ -87,6 +87,7 @@ configure()
* parameter based on device(s) used.
*/
swapconf();
dumpconf();
cold = 0;
}
@ -111,13 +112,6 @@ swapconf()
swp->sw_nblks = ctod(dtoc(swp->sw_nblks));
}
}
/* XXXX needs more work */
if (dumplo == 0 && bdevsw[major(dumpdev)].d_psize)
/*dumplo = (*bdevsw[major(dumpdev)].d_psize)(dumpdev) - physmem;*/
dumplo = (*bdevsw[major(dumpdev)].d_psize)(dumpdev) -
ctob(physmem)/DEV_BSIZE;
if (dumplo < btodb(CLBYTES))
dumplo = btodb(CLBYTES);
}
#define DOSWAP /* change swdevt and dumpdev */

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
* $Id: machdep.c,v 1.115 1994/08/03 06:28:10 mycroft Exp $
* $Id: machdep.c,v 1.116 1994/08/14 22:47:33 gwr Exp $
*/
#include <sys/param.h>
@ -122,8 +122,6 @@ static vm_size_t avail_remaining;
int _udatasel, _ucodesel, _gsel_tss;
long dumplo;
void dumpsys __P((void));
caddr_t allocsys();
@ -714,8 +712,52 @@ boot(howto)
/*NOTREACHED*/
}
unsigned dumpmag = 0x8fca0101; /* magic number for savecore */
int dumpsize = 0; /* also for savecore */
/*
* These variables are needed by /sbin/savecore
*/
u_long dumpmag = 0x8fca0101; /* magic number */
int dumpsize = 0; /* pages */
long dumplo = 0; /* blocks */
/*
* This is called by configure to set dumplo, dumpsize.
* Dumps always skip the first CLBYTES of disk space
* in case there might be a disk label stored there.
* If there is extra space, put dump at the end to
* reduce the chance that swapping trashes it.
*/
void
dumpconf()
{
int nblks; /* size of dump area */
int maj;
int (*getsize)();
if (dumpdev == NODEV)
return;
maj = major(dumpdev);
if (maj < 0 || maj >= nblkdev)
panic("dumpconf: bad dumpdev=0x%x", dumpdev);
getsize = bdevsw[maj].d_psize;
if (getsize == NULL)
return;
nblks = (*getsize)(dumpdev);
if (nblks <= ctod(1))
return;
/* Position dump image near end of space, page aligned. */
dumpsize = physmem; /* pages */
dumplo = nblks - ctod(dumpsize);
dumplo &= ~(ctod(1)-1);
/* If it does not fit, truncate it by moving dumplo. */
if (dumplo < ctod(1)) {
dumplo = ctod(1);
dumpsize = dtoc(nblks - dumplo);
}
}
/*
* Doadump comes here after turning off memory management and
* getting on the dump stack, either when called above, or by