auto_sense.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This file contains functions to implement automatic configuration
* of scsi disks.
*/
#include "global.h"
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <ctype.h>
#include "misc.h"
#include "param.h"
#include "ctlr_scsi.h"
#include "auto_sense.h"
#include "partition.h"
#include "label.h"
#include "startup.h"
#include "analyze.h"
#include "io.h"
#include "hardware_structs.h"
#include "menu_fdisk.h"
#define DISK_NAME_MAX 256
extern int nctypes;
extern struct ctlr_type ctlr_types[];
/*
* Marker for free hog partition
*/
#define HOG (-1)
/*
* Default partition tables
*
* Disk capacity root swap usr
* ------------- ---- ---- ---
* 0mb to 64mb 0 0 remainder
* 64mb to 180mb 16mb 16mb remainder
* 180mb to 280mb 16mb 32mb remainder
* 280mb to 380mb 24mb 32mb remainder
* 380mb to 600mb 32mb 32mb remainder
* 600mb to 1gb 32mb 64mb remainder
* 1gb to 2gb 64mb 128mb remainder
* 2gb on up 128mb 128mb remainder
*/
struct part_table {
int partitions[NDKMAP];
};
static struct part_table part_table_64mb = {
{ 0, 0, 0, 0, 0, 0, HOG, 0}
};
static struct part_table part_table_180mb = {
};
static struct part_table part_table_280mb = {
};
static struct part_table part_table_380mb = {
};
static struct part_table part_table_600mb = {
};
static struct part_table part_table_1gb = {
};
static struct part_table part_table_2gb = {
};
static struct part_table part_table_infinity = {
};
static struct default_partitions {
long min_capacity;
long max_capacity;
struct part_table *part_table;
} default_partitions[] = {
};
#define DEFAULT_PARTITION_TABLE_SIZE \
(sizeof (default_partitions) / sizeof (struct default_partitions))
/*
* msgs for check()
*/
#define FORMAT_MSG "Auto configuration via format.dat"
#define GENERIC_MSG "Auto configuration via generic SCSI-2"
/*
* Disks on symbios(Hardwire raid controller) return a fixed number
* of heads(64)/cylinders(64) and adjust the cylinders depending
* capacity of the configured lun.
* In such a case we get number of physical cylinders < 3 which
* is the minimum required by solaris(2 reserved + 1 data cylinders).
*
*/
/*
* assuming a minimum of 32 block cylinders.
*/
#define MINIMUM_NO_HEADS 2
#define MINIMUM_NO_SECTORS 16
#define MINIMUM_NO_CYLINDERS 128
#if defined(_SUNOS_VTOC_8)
/* These are 16-bit fields */
#define MAXIMUM_NO_HEADS 65535
#define MAXIMUM_NO_SECTORS 65535
#define MAXIMUM_NO_CYLINDERS 65535
#endif /* defined(_SUNOS_VTOC_8) */
/*
* minimum number of cylinders required by Solaris.
*/
#define SUN_MIN_CYL 3
/*
* ANSI prototypes for local static functions
*/
static struct disk_type *generic_disk_sense(
int fd,
int can_prompt,
struct scsi_inquiry *inquiry,
struct scsi_capacity_16 *capacity,
char *disk_name);
static int use_existing_disk_type(
int fd,
int can_prompt,
struct scsi_inquiry *inquiry,
struct scsi_capacity_16 *capacity);
int ctrl_type);
static struct disk_type *find_scsi_disk_type(
char *disk_name,
static struct disk_type *find_scsi_disk_by_name(
char *disk_name);
static struct ctlr_type *find_scsi_ctlr_type(void);
static struct ctlr_info *find_scsi_ctlr_info(
static struct disk_type *new_scsi_disk_type(
int fd,
char *disk_name,
static struct disk_info *find_scsi_disk_info(
static char *get_sun_disk_name(
char *disk_name,
struct scsi_inquiry *inquiry);
static char *get_generic_disk_name(
char *disk_name,
struct scsi_inquiry *inquiry);
static int force_blocksize(int fd);
static int raw_format(int fd);
static char *strcopy(
char *dst,
char *src,
int n);
#if defined(_SUNOS_VTOC_8)
static int square_box(
int capacity,
#endif /* defined(_SUNOS_VTOC_8) */
/*
* We need to get information necessary to construct a *new* efi
* label type
*/
struct disk_type *
{
int i;
struct partition_info *part;
/*
* get vendor, product, revision and capacity info.
*/
}
/*
* Now build the default partition table
*/
err_print("efi_alloc_and_init failed. \n");
}
}
/*
* Make constants first
* and variable partitions later
*/
/* root partition - s0 128 MB */
/* partition - s1 128 MB */
/* partition -s2 is NOT the Backup disk */
/* partition -s6 /usr partition - HOG */
- (1024 * 16);
/* efi reserved partition - s9 16K */
/*
* Now stick all of it into the disk_type struct
*/
if (option_msg && diag_msg) {
err_print("DKIOCINFO failed\n");
}
return (NULL);
}
} else {
}
}
part = (struct partition_info *)
zalloc(sizeof (struct partition_info));
return (disk);
}
/*
* Auto-sense a scsi disk configuration, ie get the information
* necessary to construct a label. We have two different
* ways to auto-sense a scsi disk:
* - format.dat override, via inquiry name
* - generic scsi, via standard mode sense and inquiry
* change geometry and reformat.
*/
struct disk_type *
int fd,
int can_prompt,
{
struct scsi_inquiry inquiry;
struct scsi_capacity_16 capacity;
char disk_name[DISK_NAME_MAX];
int force_format_dat = 0;
int force_generic = 0;
int deflt;
/*
* First, if expert mode, find out if the user
* wants to override any of the standard methods.
*/
if (can_prompt && expert_mode) {
deflt = 1;
&deflt, DATA_INPUT) == 0) {
force_format_dat = 1;
&deflt, DATA_INPUT) == 0) {
force_generic = 1;
}
}
/*
* Get the Inquiry data. If this fails, there's
* no hope for this disk, so give up.
*/
}
if (option_msg && diag_msg) {
err_print("Product id: ");
err_print("\n");
}
/*
* Get the Read Capacity
*/
}
if (option_msg && diag_msg) {
err_print("blocks: %llu (0x%llx)\n",
}
/*
* Extract the disk name for the format.dat override
*/
if (option_msg && diag_msg) {
}
/*
* Figure out which method we use for auto sense.
* If a particular method fails, we fall back to
* the next possibility.
*/
if (force_generic) {
}
/*
* Try for an existing format.dat first
*/
return (disk_type);
}
if (force_format_dat) {
return (NULL);
}
}
/*
* Otherwise, try using generic SCSI-2 sense and inquiry.
*/
}
/*ARGSUSED*/
static struct disk_type *
int fd,
int can_prompt,
struct scsi_inquiry *inquiry,
struct scsi_capacity_16 *capacity,
char *disk_name)
{
int pcyl;
int ncyl;
int acyl;
int nhead;
int nsect;
int rpm;
long nblocks;
union {
struct mode_format page3;
} u_page3;
union {
struct mode_geometry page4;
} u_page4;
struct scsi_capacity_16 new_capacity;
struct scsi_ms_header header;
/*
* If the name of this disk appears to be "SUN", use it,
* otherwise construct a name out of the generic
* Inquiry info. If it turns out that we already
* have a SUN disk type of this name that differs
* in geometry, we will revert to the generic name
* anyway.
*/
}
/*
* If the device's block size is not 512, we have to
* change block size, reformat, and then sense the
* geometry. To do this, we must be able to prompt
* the user.
*/
if (!can_prompt) {
return (NULL);
}
if (force_blocksize(fd)) {
goto err;
}
/*
* Get the capacity again, since this has changed
*/
goto err;
}
if (option_msg && diag_msg) {
err_print("blocks: %llu (0x%llx)\n",
}
capacity = &new_capacity;
goto err;
}
}
/*
* Get current Page 3 - Format Parameters page
*/
goto err;
}
/*
* Get current Page 4 - Drive Geometry page
*/
goto err;
}
/*
* Correct for byte order if necessary
*/
/*
* Construct a new label out of the sense data,
* Inquiry and Capacity.
*/
/*
* If the number of physical cylinders reported is less
* the SUN_MIN_CYL(3) then try to adjust the geometry so that
* we have atleast SUN_MIN_CYL cylinders.
*/
if (pcyl < SUN_MIN_CYL) {
goto err;
}
}
/*
* The sd driver reserves 2 cylinders the backup disk label and
* the deviceid. Set the number of data cylinders to pcyl-acyl.
*/
if (option_msg && diag_msg) {
err_print("Geometry:\n");
#if defined(_SUNOS_VTOC_16)
#endif /* defined(_SUNOS_VTOC_16) */
}
/*
* Some drives report 0 for page4->rpm, adjust it to AVG_RPM, 3600.
*/
err_print("Mode sense page(4) reports rpm value as %d,"
}
/*
* Get the number of blocks from Read Capacity data. Note that
* the logical block address range from 0 to capacity->sc_capacity.
*/
/*
* Some drives report 0 for nsect (page 3, byte 10 and 11) if they
* have variable number of sectors per track. So adjust nsect.
* Also the value is defined as vendor specific, hence check if
* it is in a tolerable range. The values (32 and 4 below) are
* chosen so that this change below does not generate a different
* geometry for currently supported sun disks.
*/
if ((nsect <= 0) ||
err_print("Mode sense page(3) reports nsect value as %d, "
}
/*
* Some drives report their physical geometry such that
* it is greater than the actual capacity. Adjust the
* geometry to allow for this, so we don't run off
* the end of the disk.
*/
int p = pcyl;
if (option_msg && diag_msg) {
err_print("Computed capacity (%ld) exceeds actual "
"disk capacity (%ld)\n",
}
do {
pcyl--;
/*
* Try to adjust nsect instead of pcyl to see if we
* can optimize. For compatability reasons do this
* only in expert mode (refer to bug 1144812).
*/
int n = nsect;
do {
n--;
int deflt = 1;
/*
* Ask the user for a choice here.
*/
err_print("1. Capacity = %d, with pcyl = %d "
"nhead = %d nsect = %d\n",
err_print("2. Capacity = %d, with pcyl = %d "
"nhead = %d nsect = %d\n",
(p * nhead * n),
p, nhead, n);
pcyl = p;
nsect = n;
}
}
}
}
#if defined(_SUNOS_VTOC_8)
/*
* Finally, we need to make sure we don't overflow any of the
* fields in our disk label. To do this we need to `square
* the box' so to speak. We will lose bits here.
*/
if ((pcyl > MAXIMUM_NO_CYLINDERS &&
((nsect > MAXIMUM_NO_SECTORS) ||
(nhead > MAXIMUM_NO_HEADS))) ||
((nsect > MAXIMUM_NO_SECTORS) &&
(nhead > MAXIMUM_NO_HEADS))) {
err_print("This disk is too big to label. "
" You will lose some blocks.\n");
}
if ((pcyl > MAXIMUM_NO_CYLINDERS) ||
(nsect > MAXIMUM_NO_SECTORS) ||
(nhead > MAXIMUM_NO_HEADS)) {
int order;
char msg[256];
switch (order) {
case 0x7: /* ncyl > nhead > nsect */
nblocks =
break;
case 0x6: /* ncyl > nsect > nhead */
nblocks =
break;
case 0x4: /* nsect > ncyl > nhead */
nblocks =
break;
case 0x0: /* nsect > nhead > ncyl */
nblocks =
break;
case 0x3: /* nhead > ncyl > nsect */
nblocks =
break;
case 0x1: /* nhead > nsect > ncyl */
nblocks =
break;
default:
/* How did we get here? */
impossible("label overflow adjustment");
/* Do something useful */
nblocks =
break;
}
if (option_msg && diag_msg &&
err_print("After adjusting geometry you lost"
" %llu of %lld blocks.\n",
}
int deflt = 1;
/*
* Allow user to modify this by hand if desired.
*/
"\nGeometry: %d heads, %d sectors %d "
" cylinders result in %d out of %lld blocks.\n"
"Do you want to modify the device geometry",
&deflt, DATA_INPUT) != 0)
break;
"Number of sectors per track",
err_print("Warning: %ld blocks exceeds "
"disk capacity of %lld blocks\n",
}
}
}
#endif /* defined(_SUNOS_VTOC_8) */
if (option_msg && diag_msg) {
err_print("\nGeometry after adjusting for capacity:\n");
}
"%s cyl %d alt %d hd %d sec %d",
#if defined(_FIRMWARE_NEEDS_FDISK)
(void) auto_solaris_part(label);
#endif /* defined(_FIRMWARE_NEEDS_FDISK) */
goto err;
}
/*
* Find an existing disk type defined for this disk.
* For this to work, both the name and geometry must
* match. If there is no such type, but there already
* is a disk defined with that name, but with a different
* geometry, construct a new generic disk name out of
* the inquiry information. Whatever name we're
* finally using, if there's no such disk type defined,
* build a new disk definition.
*/
char old_name[DISK_NAME_MAX];
(void) get_generic_disk_name(disk_name,
inquiry);
if (option_msg && diag_msg) {
}
sizeof (label->dkl_asciilabel),
"%s cyl %d alt %d hd %d sec %d",
}
goto err;
}
}
return (disk);
err:
if (option_msg && diag_msg) {
"Configuration via generic SCSI-2 information failed\n");
}
return (NULL);
}
/*ARGSUSED*/
static int
int fd,
int can_prompt,
struct scsi_inquiry *inquiry,
struct scsi_capacity_16 *capacity)
{
struct scsi_capacity_16 new_capacity;
int pcyl;
int acyl;
int nhead;
int nsect;
int rpm;
/*
* If the device's block size is not 512, we have to
* change block size, reformat, and then sense the
* geometry. To do this, we must be able to prompt
* the user.
*/
if (!can_prompt) {
return (0);
}
if (force_blocksize(fd)) {
goto err;
}
/*
* Get the capacity again, since this has changed
*/
goto err;
}
if (option_msg && diag_msg) {
err_print("blocks: %llu (0x%llx)\n",
}
capacity = &new_capacity;
goto err;
}
}
/*
* Construct a new label out of the format.dat
*/
if (option_msg && diag_msg) {
err_print("Format.dat geometry:\n");
}
"%s cyl %d alt %d hd %d sec %d",
goto err;
}
return (1);
err:
if (option_msg && diag_msg) {
"Configuration via format.dat geometry failed\n");
}
return (0);
}
int
int ctrl_type)
{
int i;
int nblks;
int cyl;
struct part_table *pt;
struct default_partitions *dpt;
long capacity;
int freecyls;
int blks_per_cyl;
int ncyl;
#ifdef lint
#endif
/*
* Install a default vtoc
*/
for (i = 0; i < NDKMAP; i++) {
}
/*
* Find a partition that matches this disk. Capacity
* is in integral number of megabytes.
*/
for (i = 0; i < DEFAULT_PARTITION_TABLE_SIZE; i++, dpt++) {
break;
}
}
if (i == DEFAULT_PARTITION_TABLE_SIZE) {
if (option_msg && diag_msg) {
err_print("No matching default partition (%ld)\n",
capacity);
}
return (0);
}
/*
* Go through default partition table, finding fixed
* sized entries.
*/
for (i = 0; i < NDKMAP; i++) {
ncyls[i] = 0;
} else {
/*
* Calculate number of cylinders necessary
* for specified size, rounding up to
* the next greatest integral number of
* cylinders. Always give what they
* asked or more, never less.
*/
}
}
if (freecyls < 0) {
if (option_msg && diag_msg) {
for (i = 0; i < NDKMAP; i++) {
if (ncyls[i] == 0)
continue;
err_print("Partition %d: %d cyls\n",
i, ncyls[i]);
}
err_print("Free cylinders exhausted (%d)\n",
freecyls);
}
return (0);
}
#if defined(i386)
/*
* Set the default boot partition to 1 cylinder
*/
freecyls -= 1;
/*
* If current disk type is not a SCSI disk,
* set the default alternates partition to 2 cylinders
*/
if (ctrl_type != DKC_SCSI_CCS) {
freecyls -= 2;
}
#endif /* defined(i386) */
/*
* Set the free hog partition to whatever space remains.
* It's an error to have more than one HOG partition,
* but we don't verify that here.
*/
for (i = 0; i < NDKMAP; i++) {
break;
}
}
/*
* Error checking
*/
ncyl = 0;
for (i = 0; i < NDKMAP; i++) {
}
/*
* Finally, install the partition in the label.
*/
cyl = 0;
#if defined(_SUNOS_VTOC_16)
if (i == 2 || ncyls[i] == 0)
continue;
}
for (i = 0; i < NDKMAP/2; i++) {
#elif defined(_SUNOS_VTOC_8)
for (i = 0; i < NDKMAP; i++) {
#else
#endif /* defined(_SUNOS_VTOC_16) */
if (i == 2 || ncyls[i] == 0)
continue;
#if defined(_SUNOS_VTOC_8)
#elif defined(_SUNOS_VTOC_16)
#else
#endif /* defined(_SUNOS_VTOC_8) */
}
/*
* Set the whole disk partition
*/
#if defined(_SUNOS_VTOC_8)
#elif defined(_SUNOS_VTOC_16)
#else
#endif /* defined(_SUNOS_VTOC_8) */
if (option_msg && diag_msg) {
float scaled;
err_print("\n");
for (i = 0; i < NDKMAP; i++) {
#if defined(_SUNOS_VTOC_8)
#elif defined(_SUNOS_VTOC_16)
#else
#endif /* defined(_SUNOS_VTOC_8) */
continue;
err_print("Partition %d: ", i);
#if defined(_SUNOS_VTOC_8)
#elif defined(_SUNOS_VTOC_16)
#else
#endif /* defined(_SUNOS_VTOC_8) */
if (scaled > 1024.0) {
} else {
}
err_print(" %6d cylinders\n",
#if defined(_SUNOS_VTOC_8)
#elif defined(_SUNOS_VTOC_16)
#else
#endif /* defined(_SUNOS_VTOC_8) */
}
err_print("\n");
}
return (1);
}
/*
* Find an existing scsi disk definition by this name,
* if possible.
*/
static struct disk_type *
char *disk_name,
{
ctlr = find_scsi_ctlr_type();
if (dp->dtype_asciilabel) {
return (dp);
}
}
}
}
/*
* Find an existing scsi disk definition by this name,
* if possible.
*/
static struct disk_type *
char *disk_name)
{
ctlr = find_scsi_ctlr_type();
if (dp->dtype_asciilabel) {
return (dp);
}
}
}
}
/*
* Return a pointer to the ctlr_type structure for SCSI
* disks. This list is built into the program, so there's
* no chance of not being able to find it, unless someone
* totally mangles the code.
*/
static struct ctlr_type *
{
struct mctlr_list *mlp;
}
}
impossible("no SCSI controller type");
/*NOTREACHED*/
}
/*
* Return a pointer to the scsi ctlr_info structure. This
* structure is allocated the first time format sees a
* disk on this controller, so it must be present.
*/
static struct ctlr_info *
{
return (NULL);
}
DKC_SCSI_CCS) {
return (ctlr);
}
}
impossible("no SCSI controller info");
/*NOTREACHED*/
}
static struct disk_type *
int fd,
char *disk_name,
{
struct partition_info *part;
struct partition_info *pt;
int i;
/*
* Get the disk controller info for this disk
*/
if (option_msg && diag_msg) {
err_print("DKIOCINFO failed\n");
}
return (NULL);
}
/*
* Find the ctlr_info for this disk.
*/
/*
* Allocate a new disk type for the SCSI controller.
*/
/*
* Find the disk_info instance for this disk.
*/
/*
* The controller and the disk should match.
*/
/*
* Link the disk into the list of disks
*/
} else {
}
}
/*
* Allocate and initialize the disk name.
*/
/*
* Initialize disk geometry info
*/
/*
* Attempt to match the partition map in the label
* with a know partition for this disk type.
*/
break;
}
}
/*
* If no match was made, we need to create a partition
* map for this disk.
*/
part = (struct partition_info *)
zalloc(sizeof (struct partition_info));
} else {
}
}
/*
* Set up the partition name
*/
/*
* Fill in the partition info from the label
*/
for (i = 0; i < NDKMAP; i++) {
#if defined(_SUNOS_VTOC_8)
#elif defined(_SUNOS_VTOC_16)
((int)(disk->dtype_nhead *
#else
#endif /* defined(_SUNOS_VTOC_8) */
}
}
/*
* Use the VTOC if valid, or install a default
*/
} else {
}
/*
* Link the disk to the partition map
*/
return (disk);
}
static struct disk_info *
{
return (disk);
}
}
impossible("No SCSI disk info instance\n");
/*NOTREACHED*/
}
static char *
char *disk_name,
struct scsi_inquiry *inquiry)
{
/*
* Extract the sun name of the disk
*/
return (disk_name);
}
static char *
char *disk_name,
struct scsi_inquiry *inquiry)
{
char *p;
*p++ = '-';
*p++ = '-';
sizeof (inquiry->inq_revision));
return (disk_name);
}
static int
int fd)
{
union {
struct mode_format page3;
} u_page3;
struct scsi_ms_header header;
if (check("\
Must reformat device to 512-byte blocksize. Continue") == 0) {
/*
* Get current Page 3 - Format Parameters page
*/
MAX_MODE_SENSE_SIZE, &header)) {
goto err;
}
/*
* Make our changes to the geometry
*/
/*
* make sure that logical block size is of
* DEV_BSIZE.
*/
/*
* Select current Page 3 - Format Parameters page
*/
goto err;
}
/*
* Now reformat the device
*/
if (raw_format(fd)) {
goto err;
}
return (0);
}
err:
if (option_msg && diag_msg) {
"Reformat device to 512-byte blocksize failed\n");
}
return (1);
}
static int
int fd)
{
struct scsi_defect_hdr defect_hdr;
/*
* Issue the format ioctl
*/
fmt_print("Formatting...\n");
return (1);
}
return (0);
}
/*
* Copy a string of characters from src to dst, for at
* most n bytes. Strip all leading and trailing spaces,
* and stop if there are any non-printable characters.
* Return ptr to the next character to be filled.
*/
static char *
char *dst,
char *src,
int n)
{
int i;
while (*src == ' ' && n > 0) {
src++;
n--;
}
if (*src == ' ') {
i++;
} else {
while (i-- > 0)
*dst++ = ' ';
}
}
*dst = 0;
return (dst);
}
/*
* adjust disk geometry.
* This is used when disk reports a disk geometry page having
* no of physical cylinders is < 3 which is the minimum required
* by Solaris (2 for storing labels and at least one as a data
* cylinder )
*/
int
{
/*
* reduce nsect by 2 for each iteration and re-calculate
* the number of cylinders.
*/
while (lnsect > MINIMUM_NO_SECTORS &&
lcyl < MINIMUM_NO_CYLINDERS) {
/*
* make sure that we do not go below MINIMUM_NO_SECTORS.
*/
}
/*
* If the geometry still does not satisfy
* MINIMUM_NO_CYLINDERS then try to reduce the
* no of heads.
*/
while (lnhead > MINIMUM_NO_HEADS &&
(lcyl < MINIMUM_NO_CYLINDERS)) {
}
/*
* now we should have atleast SUN_MIN_CYL cylinders.
* If we still do not get SUN_MIN_CYL with MINIMUM_NO_HEADS
* and MINIMUM_NO_HEADS then return error.
*/
if (lcyl < SUN_MIN_CYL)
return (1);
else {
return (0);
}
}
#if defined(_SUNOS_VTOC_8)
/*
* Reduce the size of one dimention below a specified
* limit with a minimum loss of volume. Dimenstions are
* assumed to be passed in form the largest value (the one
* that needs to be reduced) to the smallest value. The
* values will be twiddled until they are all less than or
* equal to their limit. Returns the number in the new geometry.
*/
static int
int capacity,
{
int i;
/*
* Although the routine should work with any ordering of
* parameters, it's most efficient if they are passed in
* in decreasing magnitude.
*/
/*
* This is done in a very arbitrary manner. We could try to
* find better values but I can't come up with a method that
* would run in a reasonable amount of time. That could take
* approximately 65535 * 65535 iterations of a dozen flops each
* or well over 4G flops.
*
* First:
*
* Let's see how far we can go with bitshifts w/o losing
* any blocks.
*/
if (i) {
}
double d[4];
/*
* Second:
*
* Set the highest value at its limit then calculate errors,
* adjusting the 2nd highest value (we get better resolution
* that way).
*/
d[1] = lim1;
d[3] = *dim3;
/*
* If we overflowed the middle term, set it to its limit and
* chose a new low term.
*/
if (d[2] > lim2) {
d[2] = lim2;
}
/*
* Convert to integers.
*/
*dim1 = (int)d[1];
*dim2 = (int)d[2];
*dim3 = (int)d[3];
}
/*
* Fixup any other possible problems.
* If this happens, we need a new disklabel format.
*/
}
#endif /* defined(_SUNOS_VTOC_8) */