Commit 4a2e61ff authored by Mike Hibler's avatar Mike Hibler

Failure to get CHS info should not be fatal.

That is sooooo 1990s...
parent 730d095c
/* /*
* Copyright (c) 2000-2014 University of Utah and the Flux Group. * Copyright (c) 2000-2016 University of Utah and the Flux Group.
* *
* {{{EMULAB-LICENSE * {{{EMULAB-LICENSE
* *
...@@ -24,22 +24,15 @@ ...@@ -24,22 +24,15 @@
/* /*
* "Grow" a testbed disk * "Grow" a testbed disk
* *
* Used to expand the final (DOS) partition in a testbed image to * Used to expand the final (DOS) partition in a testbed image to fill
* fill the remainder of the disk. A typical testbed disk image * the remainder of the disk. The current ("MBR3") image is laid out as:
* is sized to fit in the least-common-denominator disk we have,
* currently 13GB. This current image is laid out as:
* *
* 0 to 62: bootarea * 0 to 62: bootarea
* 63 to 6281414: FreeBSD (3GB) * 63 to 2047: unused
* 6281415 to 12562829: Linux (3GB) * 2048 to 33556479: OS (16GB)
* 12562830 to 12819869: Linux swap (128MB) * 33556480 to 39847935: unused (3GB)
* 12819870 to 26700029: unused * 39847936 to 46139391: swap (3GB)
* * 46139392 to NNNNNNNN: unused
* for multi-OS disks, or:
*
* 0 to 62: bootarea
* 63 to N-1: some OS
* N to 26700029: unused
* *
* The goal of this program is to locate the final, unused partition and * The goal of this program is to locate the final, unused partition and
* resize it to match the actual disk size. This program does *not* know * resize it to match the actual disk size. This program does *not* know
...@@ -171,7 +164,7 @@ getdiskinfo(char *disk) ...@@ -171,7 +164,7 @@ getdiskinfo(char *disk)
#else #else
#ifdef DIOCGMEDIASIZE #ifdef DIOCGMEDIASIZE
/* /*
* FreeBSD 5. * FreeBSD 5 and beyond.
* *
* Note we still use the contrived geometry here rather than the * Note we still use the contrived geometry here rather than the
* simple "gimme the disk size" DIOCGMEDIASIZE. Why? I'm glad you * simple "gimme the disk size" DIOCGMEDIASIZE. Why? I'm glad you
...@@ -205,13 +198,18 @@ getdiskinfo(char *disk) ...@@ -205,13 +198,18 @@ getdiskinfo(char *disk)
err(1, "%s: DIOCGMEDIASIZE", disk); err(1, "%s: DIOCGMEDIASIZE", disk);
diskinfo.disksize = (unsigned long)(dsize / ssize); diskinfo.disksize = (unsigned long)(dsize / ssize);
if (ioctl(fd, DIOCGFWSECTORS, &nsect) < 0) if (ioctl(fd, DIOCGFWSECTORS, &nsect) < 0)
err(1, "%s: DIOCGFWSECTORS", disk); nsect = 0;
diskinfo.spt = nsect; diskinfo.spt = nsect;
if (ioctl(fd, DIOCGFWHEADS, &nhead) < 0) if (ioctl(fd, DIOCGFWHEADS, &nhead) < 0)
err(1, "%s: DIOCGFWHEADS", disk); nhead = 0;
diskinfo.tpc = nhead; diskinfo.tpc = nhead;
diskinfo.cpu = diskinfo.disksize / (nsect * nhead); if (nsect && nhead) {
chs = diskinfo.cpu * diskinfo.tpc * diskinfo.spt; diskinfo.cpu = diskinfo.disksize / (nsect * nhead);
chs = diskinfo.cpu * diskinfo.tpc * diskinfo.spt;
} else {
diskinfo.cpu = 0;
chs = diskinfo.disksize;
}
} }
#else #else
#ifdef DIOCGDINFO #ifdef DIOCGDINFO
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment