summaryrefslogtreecommitdiff
path: root/usr/src/cmd/format
diff options
context:
space:
mode:
authorPrasad Singamsetty <Prasad.Singamsetty@Sun.COM>2008-09-11 18:00:50 -0700
committerPrasad Singamsetty <Prasad.Singamsetty@Sun.COM>2008-09-11 18:00:50 -0700
commit342440ec94087b8c751c580ab9ed6c693d31d418 (patch)
tree87195f6bee2bb52c9f592f1ce57636b3de75b7d7 /usr/src/cmd/format
parent7ddfa2acf3cfb8a6397a0fb7b4dcd2ce701cc293 (diff)
downloadillumos-joyent-342440ec94087b8c751c580ab9ed6c693d31d418.tar.gz
PSARC/2008/336 Extended VTOC
6708609 Support booting on disks > 1TB (phase 1) 6672960 cmlb: default minor nodes for disks > 1TB is not EFI/GPT style 6727240 When a fat32 partition created in the part of the disk after 1TB, block I/O and umount fail
Diffstat (limited to 'usr/src/cmd/format')
-rw-r--r--usr/src/cmd/format/Makefile11
-rw-r--r--usr/src/cmd/format/analyze.c51
-rw-r--r--usr/src/cmd/format/analyze.h12
-rw-r--r--usr/src/cmd/format/auto_sense.c369
-rw-r--r--usr/src/cmd/format/badsec.h33
-rw-r--r--usr/src/cmd/format/ctlr_ata.c38
-rw-r--r--usr/src/cmd/format/ctlr_ata.h11
-rw-r--r--usr/src/cmd/format/ctlr_scsi.c6
-rw-r--r--usr/src/cmd/format/defect.c8
-rw-r--r--usr/src/cmd/format/disk_generic.c61
-rw-r--r--usr/src/cmd/format/global.h42
-rw-r--r--usr/src/cmd/format/hardware_structs.h31
-rw-r--r--usr/src/cmd/format/io.c155
-rw-r--r--usr/src/cmd/format/io.h13
-rw-r--r--usr/src/cmd/format/ix_altsctr.c103
-rw-r--r--usr/src/cmd/format/label.c116
-rw-r--r--usr/src/cmd/format/label.h11
-rw-r--r--usr/src/cmd/format/main.c3
-rw-r--r--usr/src/cmd/format/menu_analyze.c27
-rw-r--r--usr/src/cmd/format/menu_command.c84
-rw-r--r--usr/src/cmd/format/menu_defect.c12
-rw-r--r--usr/src/cmd/format/menu_fdisk.c35
-rw-r--r--usr/src/cmd/format/menu_partition.c27
-rw-r--r--usr/src/cmd/format/menu_scsi.c28
-rw-r--r--usr/src/cmd/format/misc.c25
-rw-r--r--usr/src/cmd/format/misc.h13
-rw-r--r--usr/src/cmd/format/modify_partition.c35
-rw-r--r--usr/src/cmd/format/param.h12
-rw-r--r--usr/src/cmd/format/partition.c21
-rw-r--r--usr/src/cmd/format/startup.c27
30 files changed, 736 insertions, 684 deletions
diff --git a/usr/src/cmd/format/Makefile b/usr/src/cmd/format/Makefile
index 2a5270a9ec..d40fff9348 100644
--- a/usr/src/cmd/format/Makefile
+++ b/usr/src/cmd/format/Makefile
@@ -2,9 +2,8 @@
# 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.
+# Common Development and Distribution License (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
# or http://www.opensolaris.org/os/licensing.
@@ -20,11 +19,9 @@
# CDDL HEADER END
#
#
-# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
-#
PROG= format
@@ -58,6 +55,8 @@ $(ROOTETCDATA) := GROUP = sys
LDLIBS += -ladm -lefi -ldiskmgt -lnvpair -ldevid
+CFLAGS += -D_EXTVTOC
+
.KEEP_STATE:
all: $(PROG) $(DATA)
diff --git a/usr/src/cmd/format/analyze.c b/usr/src/cmd/format/analyze.c
index 4368daceb8..8d8404b280 100644
--- a/usr/src/cmd/format/analyze.c
+++ b/usr/src/cmd/format/analyze.c
@@ -23,8 +23,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains routines to analyze the surface of a disk.
*/
@@ -51,7 +49,7 @@ int scan_stop = 0; /* stop after error flag */
int scan_loop = 0; /* loop forever flag */
int scan_passes = 2; /* number of passes */
int scan_random = 0; /* random patterns flag */
-int scan_size = 0; /* sectors/scan operation */
+uint_t scan_size = 0; /* sectors/scan operation */
int scan_auto = 1; /* scan after format flag */
int scan_restore_defects = 1; /* restore defect list after writing */
int scan_restore_label = 1; /* restore label after writing */
@@ -100,10 +98,10 @@ static unsigned int alpha_pattern = 0x40404040; /* 10000000... == @@@@... */
#ifdef __STDC__
static int scan_repair(diskaddr_t bn, int mode);
-static int analyze_blocks(int flags, diskaddr_t blkno, int blkcnt,
+static int analyze_blocks(int flags, diskaddr_t blkno, uint_t blkcnt,
unsigned data, int init, int driver_flags, int *xfercntp);
static int handle_error_conditions(void);
-static int verify_blocks(int flags, diskaddr_t blkno, int blkcnt,
+static int verify_blocks(int flags, diskaddr_t blkno, uint_t blkcnt,
unsigned data, int driver_flags, int *xfercntp);
#else /* __STDC__ */
@@ -125,7 +123,8 @@ do_scan(flags, mode)
int flags, mode;
{
diskaddr_t start, end, curnt;
- int pass, size, needinit, data;
+ int pass, needinit, data;
+ uint_t size;
int status, founderr, i, j;
int error = 0;
int pattern = 0;
@@ -197,8 +196,8 @@ do_scan(flags, mode)
*/
if (flags & (SCAN_PATTERN | SCAN_WRITE)) {
if (cur_label == L_TYPE_SOLARIS) {
- if (start < (daddr_t)totalsects() &&
- end >= (daddr_t)datasects()) {
+ if (start < (diskaddr_t)totalsects() &&
+ end >= (diskaddr_t)datasects()) {
if (!EMBEDDED_SCSI) {
cur_list.flags |= LIST_DIRTY;
}
@@ -577,13 +576,15 @@ scan_repair(bn, mode)
*/
static int
analyze_blocks(flags, blkno, blkcnt, data, init, driver_flags, xfercntp)
- int flags, driver_flags, blkcnt, init;
+ int flags, driver_flags, init;
+ uint_t blkcnt;
register unsigned data;
diskaddr_t blkno;
int *xfercntp;
{
- int corrupt = 0;
- register int status, i, nints;
+ int corrupt = 0;
+ int status;
+ register diskaddr_t i, nints;
register unsigned *ptr = (uint_t *)pattern_buf;
media_error = 0;
@@ -595,7 +596,7 @@ analyze_blocks(flags, blkno, blkcnt, data, init, driver_flags, xfercntp)
/*
* Initialize the pattern buffer if necessary.
*/
- nints = blkcnt * SECSIZE / sizeof (int);
+ nints = (diskaddr_t)blkcnt * SECSIZE / sizeof (int);
if ((flags & SCAN_PATTERN) && init) {
for (i = 0; i < nints; i++)
*((int *)((int *)pattern_buf + i)) = data;
@@ -663,7 +664,7 @@ analyze_blocks(flags, blkno, blkcnt, data, init, driver_flags, xfercntp)
*((int *)((int *)pattern_buf +
(nints - i))));
pr_dblock(err_print, blkno);
- err_print(", offset = 0x%x.\n",
+ err_print(", offset = 0x%llx.\n",
(nints - i) * sizeof (int));
goto bad;
}
@@ -715,7 +716,7 @@ bad:
static int
verify_blocks(int flags,
diskaddr_t blkno,
- int blkcnt,
+ uint_t blkcnt,
unsigned data,
int driver_flags,
int *xfercntp)
@@ -759,17 +760,19 @@ verify_blocks(int flags,
* compare and make sure the pattern came back intact.
*/
for (data = blkno; data < blkno + blkcnt; data++) {
- for (i = 0; i < nints; i++) {
- if (*ptr++ != data) {
- ptr--;
- err_print("Data miscompare error (expecting "
- "0x%x, got 0x%x) at ", data, *ptr);
- pr_dblock(err_print, blkno);
- err_print(", offset = 0x%x.\n", (ptr -
- (uint_t *)pattern_buf) * sizeof (int));
- goto bad;
+ for (i = 0; i < nints; i++) {
+ if (*ptr++ != data) {
+ ptr--;
+ err_print("Data miscompare error "
+ "(expecting 0x%x, got 0x%x) at ",
+ data, *ptr);
+ pr_dblock(err_print, blkno);
+ err_print(", offset = 0x%x.\n",
+ (ptr - (uint_t *)pattern_buf) *
+ sizeof (int));
+ goto bad;
+ }
}
- }
}
}
/*
diff --git a/usr/src/cmd/format/analyze.h b/usr/src/cmd/format/analyze.h
index 81d950e3bf..54e84891b6 100644
--- a/usr/src/cmd/format/analyze.h
+++ b/usr/src/cmd/format/analyze.h
@@ -2,9 +2,8 @@
* 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.
+ * Common Development and Distribution License (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
* or http://www.opensolaris.org/os/licensing.
@@ -20,15 +19,13 @@
* CDDL HEADER END
*/
/*
- * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _ANALYZE_H
#define _ANALYZE_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -44,7 +41,8 @@ extern "C" {
extern int scan_entire;
extern diskaddr_t scan_lower, scan_upper;
extern int scan_correct, scan_stop, scan_loop, scan_passes;
-extern int scan_random, scan_size, scan_auto;
+extern int scan_random, scan_auto;
+extern uint_t scan_size;
extern int scan_restore_defects, scan_restore_label;
/*
diff --git a/usr/src/cmd/format/auto_sense.c b/usr/src/cmd/format/auto_sense.c
index 9adb5242ad..9ea4cd0909 100644
--- a/usr/src/cmd/format/auto_sense.c
+++ b/usr/src/cmd/format/auto_sense.c
@@ -23,8 +23,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains functions to implement automatic configuration
* of scsi disks.
@@ -116,8 +114,8 @@ static struct part_table part_table_infinity = {
static struct default_partitions {
- long min_capacity;
- long max_capacity;
+ diskaddr_t min_capacity;
+ diskaddr_t max_capacity;
struct part_table *part_table;
} default_partitions[] = {
{ 0, 64, &part_table_64mb }, /* 0 to 64 mb */
@@ -228,14 +226,17 @@ static char *strcopy(
char *dst,
char *src,
int n);
-static int adjust_disk_geometry(int capacity, int *cyl,
- int *nsect, int *nhead);
+static int adjust_disk_geometry(diskaddr_t capacity, uint_t *cyl,
+ uint_t *nsect, uint_t *nhead);
+static void compute_chs_values(diskaddr_t total_capacity,
+ diskaddr_t usable_capacity, uint_t *pcylp,
+ uint_t *nheadp, uint_t *nsectp);
#if defined(_SUNOS_VTOC_8)
-static int square_box(
- int capacity,
- int *dim1, int lim1,
- int *dim2, int lim2,
- int *dim3, int lim3);
+static diskaddr_t square_box(
+ diskaddr_t capacity,
+ uint_t *dim1, uint_t lim1,
+ uint_t *dim2, uint_t lim2,
+ uint_t *dim3, uint_t lim3);
#endif /* defined(_SUNOS_VTOC_8) */
@@ -566,7 +567,7 @@ auto_label_init(struct dk_label *label)
label->dkl_magic = DKL_MAGIC;
(void) snprintf(label->dkl_asciilabel, sizeof (label->dkl_asciilabel),
- "%s cyl %d alt %d hd %d sec %d",
+ "%s cyl %u alt %u hd %u sec %u",
"DEFAULT", ncyl, acyl, nhead, nsect);
rval = 0;
@@ -696,8 +697,8 @@ new_direct_disk_type(
#elif defined(_SUNOS_VTOC_16)
part->pinfo_map[i].dkl_cylno =
label->dkl_vtoc.v_part[i].p_start /
- ((int)(disk->dtype_nhead *
- disk->dtype_nsect - apc));
+ ((blkaddr_t)(disk->dtype_nhead *
+ disk->dtype_nsect - apc));
part->pinfo_map[i].dkl_nblk =
label->dkl_vtoc.v_part[i].p_size;
#else
@@ -878,15 +879,15 @@ generic_disk_sense(
char *disk_name)
{
struct disk_type *disk;
- int i;
int setdefault = 0;
- int pcyl = 0;
- int ncyl = 0;
- int acyl = 0;
- int nhead = 0;
- int nsect = 0;
+ uint_t pcyl = 0;
+ uint_t ncyl = 0;
+ uint_t acyl = 0;
+ uint_t nhead = 0;
+ uint_t nsect = 0;
int rpm = 0;
- long nblocks = 0;
+ diskaddr_t nblocks = 0;
+ diskaddr_t tblocks = 0;
union {
struct mode_format page3;
uchar_t buf3[MAX_MODE_SENSE_SIZE];
@@ -899,19 +900,6 @@ generic_disk_sense(
struct mode_format *page3 = &u_page3.page3;
struct mode_geometry *page4 = &u_page4.page4;
struct scsi_ms_header header;
- /* refer cmlb_convert_geometry in cmlb.c */
- static const struct chs_values {
- uint_t max_cap; /* Max Capacity for this HS. */
- uint_t nhead; /* Heads to use. */
- uint_t nsect; /* SPT to use. */
- } CHS_values[] = {
- {0x00200000, 64, 32}, /* 1GB or smaller disk. */
- {0x01000000, 128, 32}, /* 8GB or smaller disk. */
- {MAXBLKS(255, 63)}, /* 502.02GB or smaller disk. */
- {MAXBLKS(255, 126)}, /* .98TB or smaller disk. */
- {INFINITY, 255, 189} /* Max size is just under 1TB */
- };
-
/*
* If the name of this disk appears to be "SUN", use it,
@@ -960,8 +948,13 @@ generic_disk_sense(
/*
* Get the number of blocks from Read Capacity data. Note that
* the logical block address range from 0 to capacity->sc_capacity.
+ * Limit the size to 2 TB (UINT32_MAX) to use with SMI labels.
*/
- nblocks = (long)(capacity->sc_capacity + 1);
+ tblocks = (capacity->sc_capacity + 1);
+ if (tblocks > UINT32_MAX)
+ nblocks = UINT32_MAX;
+ else
+ nblocks = tblocks;
/*
* Get current Page 3 - Format Parameters page
@@ -1000,11 +993,21 @@ generic_disk_sense(
/*
* Construct a new label out of the sense data,
* Inquiry and Capacity.
+ *
+ * If the disk capacity is > 1TB then simply compute
+ * the CHS values based on the total disk capacity and
+ * not use the values from mode-sense data.
*/
- pcyl = (page4->cyl_ub << 16) + (page4->cyl_mb << 8) +
- page4->cyl_lb;
- nhead = page4->heads;
- nsect = page3->sect_track;
+ if (tblocks > INT32_MAX) {
+ compute_chs_values(tblocks, nblocks, &pcyl, &nhead,
+ &nsect);
+ } else {
+ pcyl = (page4->cyl_ub << 16) + (page4->cyl_mb << 8) +
+ page4->cyl_lb;
+ nhead = page4->heads;
+ nsect = page3->sect_track;
+ }
+
rpm = page4->rpm;
/*
@@ -1013,10 +1016,10 @@ generic_disk_sense(
* we have atleast SUN_MIN_CYL cylinders.
*/
if (pcyl < SUN_MIN_CYL) {
- if (nhead <= 0 || nsect <= 0) {
+ if (nhead == 0 || nsect == 0) {
setdefault = 1;
} else if (adjust_disk_geometry(
- (int)(capacity->sc_capacity + 1),
+ (diskaddr_t)(capacity->sc_capacity + 1),
&pcyl, &nhead, &nsect)) {
setdefault = 1;
}
@@ -1036,20 +1039,7 @@ generic_disk_sense(
"capacity data.\n\n");
/* convert capacity to nsect * nhead * pcyl */
- /* Unlabeled SCSI floppy device */
- if (nblocks <= 0x1000) {
- nhead = 2;
- pcyl = 80;
- nsect = nblocks / (nhead * pcyl);
- } else {
- for (i = 0; CHS_values[i].max_cap < nblocks &&
- CHS_values[i].max_cap != INFINITY; i++)
- ;
-
- nhead = CHS_values[i].nhead;
- nsect = CHS_values[i].nsect;
- pcyl = nblocks / (nhead * nsect);
- }
+ compute_chs_values(tblocks, nblocks, &pcyl, &nhead, &nsect);
}
/*
@@ -1061,17 +1051,18 @@ generic_disk_sense(
if (option_msg && diag_msg) {
err_print("Geometry:\n");
- err_print(" pcyl: %d\n", pcyl);
- err_print(" ncyl: %d\n", ncyl);
- err_print(" heads: %d\n", nhead);
- err_print(" nsects: %d\n", nsect);
- err_print(" acyl: %d\n", acyl);
+ err_print(" pcyl: %u\n", pcyl);
+ err_print(" ncyl: %u\n", ncyl);
+ err_print(" heads: %u\n", nhead);
+ err_print(" nsects: %u\n", nsect);
+ err_print(" acyl: %u\n", acyl);
#if defined(_SUNOS_VTOC_16)
- err_print(" bcyl: %d\n", bcyl);
+ err_print(" bcyl: %u\n", bcyl);
#endif /* defined(_SUNOS_VTOC_16) */
err_print(" rpm: %d\n", rpm);
+ err_print(" nblocks: %llu\n", nblocks);
}
/*
@@ -1092,12 +1083,37 @@ generic_disk_sense(
* chosen so that this change below does not generate a different
* geometry for currently supported sun disks.
*/
- if ((nsect <= 0) ||
- (pcyl * nhead * nsect) < (nblocks - nblocks/32) ||
- (pcyl * nhead * nsect) > (nblocks + nblocks/4)) {
- err_print("Mode sense page(3) reports nsect value as %d, "
- "adjusting it to %ld\n", nsect, nblocks / (pcyl * nhead));
- nsect = nblocks / (pcyl * nhead);
+ if ((nsect == 0) ||
+ ((diskaddr_t)pcyl * nhead * nsect) < (nblocks - nblocks/32) ||
+ ((diskaddr_t)pcyl * nhead * nsect) > (nblocks + nblocks/4)) {
+ if (nblocks > (pcyl * nhead)) {
+ err_print("Mode sense page(3) reports nsect value"
+ " as %d, adjusting it to %llu\n",
+ nsect, nblocks / (pcyl * nhead));
+ nsect = nblocks / (pcyl * nhead);
+ } else {
+ /* convert capacity to nsect * nhead * pcyl */
+ err_print("\nWARNING: Disk geometry is based on "
+ "capacity data.\n\n");
+ compute_chs_values(tblocks, nblocks, &pcyl, &nhead,
+ &nsect);
+ ncyl = pcyl - acyl;
+ if (option_msg && diag_msg) {
+ err_print("Geometry:(after adjustment)\n");
+ err_print(" pcyl: %u\n", pcyl);
+ err_print(" ncyl: %u\n", ncyl);
+ err_print(" heads: %u\n", nhead);
+ err_print(" nsects: %u\n", nsect);
+ err_print(" acyl: %u\n", acyl);
+
+#if defined(_SUNOS_VTOC_16)
+ err_print(" bcyl: %u\n", bcyl);
+#endif
+
+ err_print(" rpm: %d\n", rpm);
+ err_print(" nblocks: %llu\n", nblocks);
+ }
+ }
}
/*
@@ -1106,16 +1122,16 @@ generic_disk_sense(
* geometry to allow for this, so we don't run off
* the end of the disk.
*/
- if ((pcyl * nhead * nsect) > nblocks) {
- int p = pcyl;
+ if (((diskaddr_t)pcyl * nhead * nsect) > nblocks) {
+ uint_t p = pcyl;
if (option_msg && diag_msg) {
- err_print("Computed capacity (%ld) exceeds actual "
- "disk capacity (%ld)\n",
- (long)(pcyl * nhead * nsect), nblocks);
+ err_print("Computed capacity (%llu) exceeds actual "
+ "disk capacity (%llu)\n",
+ (diskaddr_t)pcyl * nhead * nsect, nblocks);
}
do {
pcyl--;
- } while ((pcyl * nhead * nsect) > nblocks);
+ } while (((diskaddr_t)pcyl * nhead * nsect) > nblocks);
if (can_prompt && expert_mode && !option_f) {
/*
@@ -1123,11 +1139,12 @@ generic_disk_sense(
* can optimize. For compatability reasons do this
* only in expert mode (refer to bug 1144812).
*/
- int n = nsect;
+ uint_t n = nsect;
do {
n--;
- } while ((p * nhead * n) > nblocks);
- if ((p * nhead * n) > (pcyl * nhead * nsect)) {
+ } while (((diskaddr_t)p * nhead * n) > nblocks);
+ if (((diskaddr_t)p * nhead * n) >
+ ((diskaddr_t)pcyl * nhead * nsect)) {
u_ioparam_t ioparam;
int deflt = 1;
/*
@@ -1135,14 +1152,14 @@ generic_disk_sense(
*/
ioparam.io_bounds.lower = 1;
ioparam.io_bounds.upper = 2;
- err_print("1. Capacity = %d, with pcyl = %d "
- "nhead = %d nsect = %d\n",
- (pcyl * nhead * nsect),
- pcyl, nhead, nsect);
- err_print("2. Capacity = %d, with pcyl = %d "
- "nhead = %d nsect = %d\n",
- (p * nhead * n),
- p, nhead, n);
+ err_print("1. Capacity = %llu, with pcyl = %u "
+ "nhead = %u nsect = %u\n",
+ ((diskaddr_t)pcyl * nhead * nsect),
+ pcyl, nhead, nsect);
+ err_print("2. Capacity = %llu, with pcyl = %u "
+ "nhead = %u nsect = %u\n",
+ ((diskaddr_t)p * nhead * n),
+ p, nhead, n);
if (input(FIO_INT, "Select one of the above "
"choices ", ':', &ioparam,
&deflt, DATA_INPUT) == 2) {
@@ -1236,9 +1253,9 @@ generic_disk_sense(
if (option_msg && diag_msg &&
(capacity->sc_capacity + 1 != nblocks)) {
err_print("After adjusting geometry you lost"
- " %llu of %lld blocks.\n",
- (capacity->sc_capacity + 1 - nblocks),
- capacity->sc_capacity + 1);
+ " %llu of %llu blocks.\n",
+ (capacity->sc_capacity + 1 - nblocks),
+ capacity->sc_capacity + 1);
}
while (can_prompt && expert_mode && !option_f) {
int deflt = 1;
@@ -1247,11 +1264,11 @@ generic_disk_sense(
* Allow user to modify this by hand if desired.
*/
(void) sprintf(msg,
- "\nGeometry: %d heads, %d sectors %d "
- " cylinders result in %d out of %lld blocks.\n"
- "Do you want to modify the device geometry",
- nhead, nsect, pcyl,
- (int)nblocks, capacity->sc_capacity + 1);
+ "\nGeometry: %u heads, %u sectors %u cylinders"
+ " result in %llu out of %llu blocks.\n"
+ "Do you want to modify the device geometry",
+ nhead, nsect, pcyl,
+ nblocks, capacity->sc_capacity + 1);
ioparam.io_charlist = confirm_list;
if (input(FIO_MSTR, msg, '?', &ioparam,
@@ -1261,22 +1278,22 @@ generic_disk_sense(
ioparam.io_bounds.lower = MINIMUM_NO_HEADS;
ioparam.io_bounds.upper = MAXIMUM_NO_HEADS;
nhead = input(FIO_INT, "Number of heads", ':',
- &ioparam, &nhead, DATA_INPUT);
+ &ioparam, (int *)&nhead, DATA_INPUT);
ioparam.io_bounds.lower = MINIMUM_NO_SECTORS;
ioparam.io_bounds.upper = MAXIMUM_NO_SECTORS;
nsect = input(FIO_INT,
- "Number of sectors per track",
- ':', &ioparam, &nsect, DATA_INPUT);
+ "Number of sectors per track",
+ ':', &ioparam, (int *)&nsect, DATA_INPUT);
ioparam.io_bounds.lower = SUN_MIN_CYL;
ioparam.io_bounds.upper = MAXIMUM_NO_CYLINDERS;
pcyl = input(FIO_INT, "Number of cylinders",
- ':', &ioparam, &pcyl, DATA_INPUT);
- nblocks = nhead * nsect * pcyl;
+ ':', &ioparam, (int *)&pcyl, DATA_INPUT);
+ nblocks = (diskaddr_t)nhead * nsect * pcyl;
if (nblocks > capacity->sc_capacity + 1) {
- err_print("Warning: %ld blocks exceeds "
- "disk capacity of %lld blocks\n",
- nblocks,
- capacity->sc_capacity + 1);
+ err_print("Warning: %llu blocks exceeds "
+ "disk capacity of %llu blocks\n",
+ nblocks,
+ capacity->sc_capacity + 1);
}
}
}
@@ -1286,11 +1303,11 @@ generic_disk_sense(
if (option_msg && diag_msg) {
err_print("\nGeometry after adjusting for capacity:\n");
- err_print(" pcyl: %d\n", pcyl);
- err_print(" ncyl: %d\n", ncyl);
- err_print(" heads: %d\n", nhead);
- err_print(" nsects: %d\n", nsect);
- err_print(" acyl: %d\n", acyl);
+ err_print(" pcyl: %u\n", pcyl);
+ err_print(" ncyl: %u\n", ncyl);
+ err_print(" heads: %u\n", nhead);
+ err_print(" nsects: %u\n", nsect);
+ err_print(" acyl: %u\n", acyl);
err_print(" rpm: %d\n", rpm);
}
@@ -1299,8 +1316,8 @@ generic_disk_sense(
label->dkl_magic = DKL_MAGIC;
(void) snprintf(label->dkl_asciilabel, sizeof (label->dkl_asciilabel),
- "%s cyl %d alt %d hd %d sec %d",
- disk_name, ncyl, acyl, nhead, nsect);
+ "%s cyl %u alt %u hd %u sec %u",
+ disk_name, ncyl, acyl, nhead, nsect);
label->dkl_pcyl = pcyl;
label->dkl_ncyl = ncyl;
@@ -1312,7 +1329,8 @@ generic_disk_sense(
label->dkl_rpm = rpm;
#if defined(_FIRMWARE_NEEDS_FDISK)
- (void) auto_solaris_part(label);
+ if (auto_solaris_part(label) == -1)
+ goto err;
ncyl = label->dkl_ncyl;
#endif /* defined(_FIRMWARE_NEEDS_FDISK) */
@@ -1344,9 +1362,9 @@ generic_disk_sense(
"Changing disk type name from '%s' to '%s'\n", old_name, disk_name);
}
(void) snprintf(label->dkl_asciilabel,
- sizeof (label->dkl_asciilabel),
- "%s cyl %d alt %d hd %d sec %d",
- disk_name, ncyl, acyl, nhead, nsect);
+ sizeof (label->dkl_asciilabel),
+ "%s cyl %u alt %u hd %u sec %u",
+ disk_name, ncyl, acyl, nhead, nsect);
(void) checksum(label, CK_MAKESUM);
disk = find_scsi_disk_type(disk_name, label);
}
@@ -1431,10 +1449,10 @@ use_existing_disk_type(
if (option_msg && diag_msg) {
err_print("Format.dat geometry:\n");
- err_print(" pcyl: %d\n", pcyl);
- err_print(" heads: %d\n", nhead);
- err_print(" nsects: %d\n", nsect);
- err_print(" acyl: %d\n", acyl);
+ err_print(" pcyl: %u\n", pcyl);
+ err_print(" heads: %u\n", nhead);
+ err_print(" nsects: %u\n", nsect);
+ err_print(" acyl: %u\n", acyl);
err_print(" rpm: %d\n", rpm);
}
@@ -1443,9 +1461,9 @@ use_existing_disk_type(
label->dkl_magic = DKL_MAGIC;
(void) snprintf(label->dkl_asciilabel, sizeof (label->dkl_asciilabel),
- "%s cyl %d alt %d hd %d sec %d",
- disk_type->dtype_asciilabel,
- ncyl, acyl, nhead, nsect);
+ "%s cyl %u alt %u hd %u sec %u",
+ disk_type->dtype_asciilabel,
+ ncyl, acyl, nhead, nsect);
label->dkl_pcyl = pcyl;
label->dkl_ncyl = ncyl;
@@ -1478,12 +1496,12 @@ build_default_partition(
{
int i;
int ncyls[NDKMAP];
- int nblks;
+ diskaddr_t nblks;
int cyl;
struct dk_vtoc *vtoc;
struct part_table *pt;
struct default_partitions *dpt;
- long capacity;
+ diskaddr_t capacity;
int freecyls;
int blks_per_cyl;
int ncyl;
@@ -1509,8 +1527,8 @@ build_default_partition(
* Find a partition that matches this disk. Capacity
* is in integral number of megabytes.
*/
- capacity = (long)(label->dkl_ncyl * label->dkl_nhead *
- label->dkl_nsect) / (long)((1024 * 1024) / DEV_BSIZE);
+ capacity = ((diskaddr_t)(label->dkl_ncyl) * label->dkl_nhead *
+ label->dkl_nsect) / (1024 * 1024) / DEV_BSIZE;
dpt = default_partitions;
for (i = 0; i < DEFAULT_PARTITION_TABLE_SIZE; i++, dpt++) {
if (capacity >= dpt->min_capacity &&
@@ -1520,8 +1538,8 @@ build_default_partition(
}
if (i == DEFAULT_PARTITION_TABLE_SIZE) {
if (option_msg && diag_msg) {
- err_print("No matching default partition (%ld)\n",
- capacity);
+ err_print("No matching default partition (%llu)\n",
+ capacity);
}
return (0);
}
@@ -1556,8 +1574,8 @@ build_default_partition(
for (i = 0; i < NDKMAP; i++) {
if (ncyls[i] == 0)
continue;
- err_print("Partition %d: %d cyls\n",
- i, ncyls[i]);
+ err_print("Partition %d: %u cyls\n",
+ i, ncyls[i]);
}
err_print("Free cylinders exhausted (%d)\n",
freecyls);
@@ -1879,7 +1897,7 @@ new_scsi_disk_type(
*/
dp = ctlr->ctlr_ctype->ctype_dlist;
if (dp == NULL) {
- ctlr->ctlr_ctype->ctype_dlist = dp;
+ ctlr->ctlr_ctype->ctype_dlist = disk;
} else {
while (dp->dtype_next != NULL) {
dp = dp->dtype_next;
@@ -1947,8 +1965,8 @@ new_scsi_disk_type(
#elif defined(_SUNOS_VTOC_16)
part->pinfo_map[i].dkl_cylno =
label->dkl_vtoc.v_part[i].p_start /
- ((int)(disk->dtype_nhead *
- disk->dtype_nsect - apc));
+ ((blkaddr32_t)(disk->dtype_nhead *
+ disk->dtype_nsect - apc));
part->pinfo_map[i].dkl_nblk =
label->dkl_vtoc.v_part[i].p_size;
#else
@@ -2218,11 +2236,12 @@ strcopy(
* cylinder )
*/
int
-adjust_disk_geometry(int capacity, int *cyl, int *nhead, int *nsect)
+adjust_disk_geometry(diskaddr_t capacity, uint_t *cyl, uint_t *nhead,
+ uint_t *nsect)
{
- int lcyl = *cyl;
- int lnhead = *nhead;
- int lnsect = *nsect;
+ uint_t lcyl = *cyl;
+ uint_t lnhead = *nhead;
+ uint_t lnsect = *nsect;
assert(lcyl < SUN_MIN_CYL);
@@ -2272,14 +2291,14 @@ adjust_disk_geometry(int capacity, int *cyl, int *nhead, int *nsect)
* values will be twiddled until they are all less than or
* equal to their limit. Returns the number in the new geometry.
*/
-static int
+static diskaddr_t
square_box(
- int capacity,
- int *dim1, int lim1,
- int *dim2, int lim2,
- int *dim3, int lim3)
+ diskaddr_t capacity,
+ uint_t *dim1, uint_t lim1,
+ uint_t *dim2, uint_t lim2,
+ uint_t *dim3, uint_t lim3)
{
- int i;
+ uint_t i;
/*
* Although the routine should work with any ordering of
@@ -2347,3 +2366,73 @@ square_box(
return (*dim1 * *dim2 * *dim3);
}
#endif /* defined(_SUNOS_VTOC_8) */
+
+/*
+ * Calculate CHS values based on the capacity data.
+ *
+ * NOTE: This function is same as cmlb_convert_geomerty() function in
+ * cmlb kernel module.
+ */
+static void
+compute_chs_values(diskaddr_t total_capacity, diskaddr_t usable_capacity,
+ uint_t *pcylp, uint_t *nheadp, uint_t *nsectp)
+{
+
+ /* Unlabeled SCSI floppy device */
+ if (total_capacity <= 0x1000) {
+ *nheadp = 2;
+ *pcylp = 80;
+ *nsectp = total_capacity / (80 * 2);
+ return;
+ }
+
+ /*
+ * For all devices we calculate cylinders using the heads and sectors
+ * we assign based on capacity of the device. The algorithm is
+ * designed to be compatible with the way other operating systems
+ * lay out fdisk tables for X86 and to insure that the cylinders never
+ * exceed 65535 to prevent problems with X86 ioctls that report
+ * geometry.
+ * For some smaller disk sizes we report geometry that matches those
+ * used by X86 BIOS usage. For larger disks, we use SPT that are
+ * multiples of 63, since other OSes that are not limited to 16-bits
+ * for cylinders stop at 63 SPT we make do by using multiples of 63 SPT.
+ *
+ * The following table (in order) illustrates some end result
+ * calculations:
+ *
+ * Maximum number of blocks nhead nsect
+ *
+ * 2097152 (1GB) 64 32
+ * 16777216 (8GB) 128 32
+ * 1052819775 (502.02GB) 255 63
+ * 2105639550 (0.98TB) 255 126
+ * 3158459325 (1.47TB) 255 189
+ * 4211279100 (1.96TB) 255 252
+ * 5264098875 (2.45TB) 255 315
+ * ...
+ */
+
+ if (total_capacity <= 0x200000) {
+ *nheadp = 64;
+ *nsectp = 32;
+ } else if (total_capacity <= 0x01000000) {
+ *nheadp = 128;
+ *nsectp = 32;
+ } else {
+ *nheadp = 255;
+
+ /* make nsect be smallest multiple of 63 */
+ *nsectp = ((total_capacity +
+ (UINT16_MAX * 255 * 63) - 1) /
+ (UINT16_MAX * 255 * 63)) * 63;
+
+ if (*nsectp == 0)
+ *nsectp = (UINT16_MAX / 63) * 63;
+ }
+
+ if (usable_capacity < total_capacity)
+ *pcylp = usable_capacity / ((*nheadp) * (*nsectp));
+ else
+ *pcylp = total_capacity / ((*nheadp) * (*nsectp));
+}
diff --git a/usr/src/cmd/format/badsec.h b/usr/src/cmd/format/badsec.h
index fbc761bde6..2fdae5e670 100644
--- a/usr/src/cmd/format/badsec.h
+++ b/usr/src/cmd/format/badsec.h
@@ -2,9 +2,8 @@
* 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.
+ * Common Development and Distribution License (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
* or http://www.opensolaris.org/os/licensing.
@@ -21,7 +20,7 @@
*/
/*
- * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* copyright (c) 1990, 1991 UNIX System Laboratories, Inc.
@@ -32,8 +31,6 @@
#ifndef _BADSEC_H
#define _BADSEC_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -44,9 +41,9 @@ extern "C" {
#define MAXBLENT 4
struct badsec_lst {
- int bl_cnt;
+ uint_t bl_cnt;
struct badsec_lst *bl_nxt;
- int bl_sec[MAXBLENT];
+ uint_t bl_sec[MAXBLENT];
};
#define BADSLSZ sizeof (struct badsec_lst)
@@ -57,16 +54,16 @@ struct badsec_lst {
struct alts_mempart { /* incore alts partition info */
int ap_flag; /* flag for alternate partition */
struct alts_parttbl *ap_tblp; /* alts partition table */
- int ap_tbl_secsiz; /* alts parttbl sector size */
+ uint_t ap_tbl_secsiz; /* alts parttbl sector size */
uchar_t *ap_memmapp; /* incore alternate sector map */
uchar_t *ap_mapp; /* alternate sector map */
- int ap_map_secsiz; /* alts partmap sector size */
- int ap_map_sectot; /* alts partmap # sector */
+ uint_t ap_map_secsiz; /* alts partmap sector size */
+ uint_t ap_map_sectot; /* alts partmap # sector */
struct alts_ent *ap_entp; /* alternate sector entry table */
- int ap_ent_secsiz; /* alts entry sector size */
+ uint_t ap_ent_secsiz; /* alts entry sector size */
struct alts_ent *ap_gbadp; /* growing badsec entry table */
- int ap_gbadcnt; /* growing bad sector count */
- struct partition part; /* alts partition configuration */
+ uint_t ap_gbadcnt; /* growing bad sector count */
+ struct dkl_partition part; /* alts partition configuration */
};
/* size of incore alternate partition memory structure */
@@ -74,17 +71,17 @@ struct alts_mempart { /* incore alts partition info */
struct altsectbl { /* working alts info */
struct alts_ent *ast_entp; /* alternate sector entry table */
- int ast_entused; /* entry used */
+ uint_t ast_entused; /* entry used */
struct alt_info *ast_alttblp; /* alts info */
- int ast_altsiz; /* size of alts info */
+ uint_t ast_altsiz; /* size of alts info */
struct alts_ent *ast_gbadp; /* growing bad sector entry ptr */
- int ast_gbadcnt; /* growing bad sector entry cnt */
+ uint_t ast_gbadcnt; /* growing bad sector entry cnt */
};
/* size of incore alternate partition memory structure */
#define ALTSECTBL_SIZE sizeof (struct altsectbl)
/* macro definitions */
-#define byte_to_secsiz(APSIZE, BPS) (daddr_t) \
+#define byte_to_secsiz(APSIZE, BPS) (uint_t) \
((((APSIZE) + (BPS) - 1) \
/ (uint_t)(BPS)) * (BPS))
diff --git a/usr/src/cmd/format/ctlr_ata.c b/usr/src/cmd/format/ctlr_ata.c
index a5f616c512..2f417b9b78 100644
--- a/usr/src/cmd/format/ctlr_ata.c
+++ b/usr/src/cmd/format/ctlr_ata.c
@@ -2,9 +2,8 @@
* 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.
+ * Common Development and Distribution License (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
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains the routines for the IDE drive interface
*/
@@ -68,7 +65,7 @@ static int ata_ck_format(void);
#ifdef i386
static int ata_ex_cur(struct defect_list *);
static int ata_wr_cur(struct defect_list *);
-static int ata_repair(int, int);
+static int ata_repair(diskaddr_t, int);
#endif /* i386 */
#else /* __STDC__ */
static int ata_ck_format();
@@ -114,7 +111,7 @@ struct ctlr_ops pcmcia_ataops = {
#if defined(i386)
-static struct partition *dpart = NULL;
+static struct dkl_partition *dpart = NULL;
#endif /* defined(i386) */
extern struct badsec_lst *badsl_chain;
extern int badsl_chain_cnt;
@@ -153,9 +150,9 @@ ata_rdwr(int dir, int fd, diskaddr_t blk64, int secnt, caddr_t bufaddr,
{
int tmpsec;
struct dadkio_rwcmd dadkio_rwcmd;
- daddr_t blkno;
+ blkaddr_t blkno;
- blkno = (daddr_t)blk64;
+ blkno = (blkaddr_t)blk64;
bzero((caddr_t)&dadkio_rwcmd, sizeof (struct dadkio_rwcmd));
tmpsec = secnt * 512;
@@ -219,7 +216,8 @@ ata_ck_format()
unsigned char bufaddr[2048];
int status;
- status = ata_rdwr(DIR_READ, cur_file, 1, 4, (caddr_t)bufaddr, 0, NULL);
+ status = ata_rdwr(DIR_READ, cur_file, (diskaddr_t)1, 4,
+ (caddr_t)bufaddr, 0, NULL);
return (!status);
}
@@ -242,7 +240,7 @@ get_alts_slice()
for (i = 0; i < V_NUMPAR && alts_slice == -1; i++) {
if (cur_parts->vtoc.v_part[i].p_tag == V_ALTSCTR) {
alts_slice = i;
- dpart = (struct partition *)&cur_parts->vtoc.v_part[i];
+ dpart = &cur_parts->vtoc.v_part[i];
}
}
@@ -301,14 +299,14 @@ ata_convert_list(struct defect_list *list, int list_format)
list->header.magicno = (uint_t)DEFECT_MAGIC;
list->list = new_defect;
for (i = 0; i < ap->ap_tblp->alts_ent_used;
- i++, new_defect++) {
+ i++, new_defect++) {
new_defect->cyl =
- bn2c((ap->ap_entp)[i].bad_start);
+ bn2c((ap->ap_entp)[i].bad_start);
new_defect->head =
- bn2h((ap->ap_entp)[i].bad_start);
+ bn2h((ap->ap_entp)[i].bad_start);
new_defect->bfi = UNKNOWN;
new_defect->sect =
- bn2s((ap->ap_entp)[i].bad_start);
+ bn2s((ap->ap_entp)[i].bad_start);
new_defect->nbits = UNKNOWN;
}
@@ -365,7 +363,7 @@ ata_ex_cur(struct defect_list *list)
}
int
-ata_repair(int bn, int flag)
+ata_repair(diskaddr_t bn, int flag)
{
int status;
@@ -398,7 +396,7 @@ ata_repair(int bn, int flag)
}
blc_p = blc_p->bl_nxt;
}
- blc_p->bl_sec[blc_p->bl_cnt++] = bn;
+ blc_p->bl_sec[blc_p->bl_cnt++] = (uint_t)bn;
gbadsl_chain_cnt++;
(void) updatebadsec(dpart, 0);
@@ -460,7 +458,7 @@ ata_wr_cur(struct defect_list *list)
/* test for unsupported list format */
if ((dlist->bfi != UNKNOWN) || (dlist->nbits != UNKNOWN)) {
(void) fprintf(stderr,
- "BFI unsuported format for bad sectors\n");
+ "BFI unsuported format for bad sectors\n");
return (-1);
}
@@ -487,7 +485,7 @@ ata_wr_cur(struct defect_list *list)
blc_p = blc_p->bl_nxt;
}
blc_p->bl_sec[blc_p->bl_cnt++] =
- chs2bn(dlist->cyl, dlist->head, dlist->sect);
+ (uint_t)chs2bn(dlist->cyl, dlist->head, dlist->sect);
gbadsl_chain_cnt++;
dlist++;
}
diff --git a/usr/src/cmd/format/ctlr_ata.h b/usr/src/cmd/format/ctlr_ata.h
index 5ed0fe0be8..38e3fcdc10 100644
--- a/usr/src/cmd/format/ctlr_ata.h
+++ b/usr/src/cmd/format/ctlr_ata.h
@@ -2,9 +2,8 @@
* 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.
+ * Common Development and Distribution License (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
* or http://www.opensolaris.org/os/licensing.
@@ -21,15 +20,13 @@
*/
/*
- * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _CTLR_ATA_H
#define _CTLR_ATA_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -49,7 +46,7 @@ extern "C" {
#define TRIPLET(u, m, l) ((int)((((u))&0xff<<16) + \
(((m)&0xff)<<8) + (l&0xff)))
#if defined(i386)
-daddr_t altsec_offset; /* Alternate sector offset */
+diskaddr_t altsec_offset; /* Alternate sector offset */
#endif /* defined(i386) */
#ifdef __STDC__
diff --git a/usr/src/cmd/format/ctlr_scsi.c b/usr/src/cmd/format/ctlr_scsi.c
index d810b34559..c9ddee8f15 100644
--- a/usr/src/cmd/format/ctlr_scsi.c
+++ b/usr/src/cmd/format/ctlr_scsi.c
@@ -23,8 +23,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains the routines for embedded scsi disks
*/
@@ -327,8 +325,8 @@ scsi_ck_format(void)
/*
* Try to read the first four blocks.
*/
- status = scsi_rdwr(DIR_READ, cur_file, 0, 4, (caddr_t)cur_buf,
- F_SILENT, NULL);
+ status = scsi_rdwr(DIR_READ, cur_file, (diskaddr_t)0, 4,
+ (caddr_t)cur_buf, F_SILENT, NULL);
return (!status);
}
diff --git a/usr/src/cmd/format/defect.c b/usr/src/cmd/format/defect.c
index d30f06cde6..537a854518 100644
--- a/usr/src/cmd/format/defect.c
+++ b/usr/src/cmd/format/defect.c
@@ -19,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains routines that manipulate the defect list.
*/
@@ -214,7 +212,7 @@ checkdefsum(struct defect_list *list, int mode)
*/
lp = (int *)list->list;
for (i = 0; i < (list->header.count *
- sizeof (struct defect_entry) / sizeof (int)); i++)
+ sizeof (struct defect_entry) / sizeof (int)); i++)
sum ^= *(lp + i);
/*
* If in check mode, return whether header checksum was correct.
@@ -257,7 +255,7 @@ pr_defect(struct defect_entry *def, int num)
} else {
fmt_print(" ");
fmt_print("%8d", def->sect);
- fmt_print("%8lu", chs2bn(def->cyl, def->head, def->sect));
+ fmt_print("%8llu", chs2bn(def->cyl, def->head, def->sect));
}
fmt_print("\n");
}
diff --git a/usr/src/cmd/format/disk_generic.c b/usr/src/cmd/format/disk_generic.c
index 5c06688745..3aa205b3c0 100644
--- a/usr/src/cmd/format/disk_generic.c
+++ b/usr/src/cmd/format/disk_generic.c
@@ -2,9 +2,8 @@
* 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.
+ * Common Development and Distribution License (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
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains functions that implement the fdisk menu commands.
*/
@@ -67,9 +64,8 @@
* Local prototypes for ANSI C compilers
*/
static int generic_ck_format(void);
-static int generic_rdwr(int dir, int fd, daddr_t blkno, int secnt,
+static int generic_rdwr(int dir, int fd, diskaddr_t blkno, int secnt,
caddr_t bufaddr, int flags, int *xfercntp);
-
#else /* __STDC__ */
static int generic_ck_format();
@@ -102,7 +98,7 @@ generic_ck_format()
* Try to read the first four blocks.
*/
status = generic_rdwr(DIR_READ, cur_file, 0, 4, (caddr_t)cur_buf,
- F_SILENT, NULL);
+ F_SILENT, NULL);
return (!status);
}
@@ -115,37 +111,52 @@ static int
generic_rdwr(dir, fd, blkno, secnt, bufaddr, flags, xfercntp)
int dir;
int fd;
- daddr_t blkno;
+ diskaddr_t blkno;
int secnt;
caddr_t bufaddr;
int flags;
int *xfercntp;
{
- int tmpsec, status, tmpblk;
+ offset_t tmpsec, status, tmpblk;
+ int ret;
- tmpsec = secnt * UBSIZE;
- tmpblk = blkno * UBSIZE;
+ tmpsec = (offset_t)secnt * UBSIZE;
+ tmpblk = (offset_t)blkno * UBSIZE;
+#if defined(_FIRMWARE_NEEDS_FDISK)
+ /* Use "p0" file to seek/read the data */
+ (void) open_cur_file(FD_USE_P0_PATH);
+#endif
if (dir == DIR_READ) {
- status = lseek(fd, tmpblk, SEEK_SET);
- if (status != tmpblk)
- return (status);
+ status = llseek(fd, tmpblk, SEEK_SET);
+ if (status != tmpblk) {
+ ret = (int)status;
+ goto out;
+ }
- status = read(fd, bufaddr, tmpsec);
+ status = read(fd, bufaddr, (size_t)tmpsec);
if (status != tmpsec)
- return (tmpsec);
+ ret = (int)tmpsec;
else
- return (0);
+ ret = 0;
} else {
- status = lseek(fd, tmpblk, SEEK_SET);
- if (status != tmpblk)
- return (status);
+ status = llseek(fd, tmpblk, SEEK_SET);
+ if (status != tmpblk) {
+ ret = (int)status;
+ goto out;
+ }
- status = write(fd, bufaddr, tmpsec);
+ status = write(fd, bufaddr, (size_t)tmpsec);
if (status != tmpsec)
- return (tmpsec);
+ ret = (int)tmpsec;
else
- return (0);
+ ret = 0;
}
+out:
+#if defined(_FIRMWARE_NEEDS_FDISK)
+ /* Restore cur_file with cur_disk->disk_path */
+ (void) open_cur_file(FD_USE_CUR_DISK_PATH);
+#endif
+ return (ret);
}
diff --git a/usr/src/cmd/format/global.h b/usr/src/cmd/format/global.h
index beb1bae40a..fc3a25a938 100644
--- a/usr/src/cmd/format/global.h
+++ b/usr/src/cmd/format/global.h
@@ -19,15 +19,13 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _GLOBAL_H
#define _GLOBAL_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -44,7 +42,11 @@ extern "C" {
#endif
#ifndef UINT_MAX32
-#define UINT_MAX32 0xffffffff
+#define UINT_MAX32 0xffffffffU
+#endif
+
+#if !defined(_EXTVTOC)
+#define _EXTVTOC /* extented vtoc (struct extvtoc) format is used */
#endif
/*
@@ -114,22 +116,22 @@ struct partition_info *cur_parts; /* current disk's partitioning */
struct defect_list cur_list; /* current disk's defect list */
void *cur_buf; /* current disk's I/O buffer */
void *pattern_buf; /* current disk's pattern buffer */
-int pcyl; /* # physical cyls */
-int ncyl; /* # data cyls */
-int acyl; /* # alt cyls */
-int nhead; /* # heads */
-int phead; /* # physical heads */
-int nsect; /* # data sects/track */
-int psect; /* # physical sects/track */
-int apc; /* # alternates/cyl */
-int solaris_offset; /* Solaris offset, this value is zero */
+uint_t pcyl; /* # physical cyls */
+uint_t ncyl; /* # data cyls */
+uint_t acyl; /* # alt cyls */
+uint_t nhead; /* # heads */
+uint_t phead; /* # physical heads */
+uint_t nsect; /* # data sects/track */
+uint_t psect; /* # physical sects/track */
+uint_t apc; /* # alternates/cyl */
+uint_t solaris_offset; /* Solaris offset, this value is zero */
/* for non-fdisk machines. */
#if defined(_SUNOS_VTOC_16)
-int bcyl; /* # other cyls */
+uint_t bcyl; /* # other cyls */
#endif /* defined(_SUNOS_VTOC_16) */
struct mboot boot_sec; /* fdisk partition info */
-int xstart; /* solaris partition start */
+uint_t xstart; /* solaris partition start */
char x86_devname[MAXNAMELEN]; /* saved device name for fdisk */
/* information accesses */
struct mctlr_list *controlp; /* master controller list ptr */
@@ -140,11 +142,11 @@ struct mctlr_list *controlp; /* master controller list ptr */
* the current disk.
*/
#define sectors(h) ((h) == nhead - 1 ? nsect - apc : nsect)
-#define spc() ((int)(nhead * nsect - apc))
-#define chs2bn(c, h, s) ((daddr_t)((c) * spc() + (h) * nsect + (s)))
-#define bn2c(bn) ((bn) / (int)spc())
-#define bn2h(bn) (((bn) % (int)spc()) / (int)nsect)
-#define bn2s(bn) (((bn) % (int)spc()) % (int)nsect)
+#define spc() (nhead * nsect - apc)
+#define chs2bn(c, h, s) (((diskaddr_t)(c) * spc() + (h) * nsect + (s)))
+#define bn2c(bn) (uint_t)((diskaddr_t)(bn) / spc())
+#define bn2h(bn) (uint_t)(((diskaddr_t)(bn) % spc()) / nsect)
+#define bn2s(bn) (uint_t)(((diskaddr_t)(bn) % spc()) % nsect)
#define datasects() (ncyl * spc())
#define totalsects() ((ncyl + acyl) * spc())
#define physsects() (pcyl * spc())
diff --git a/usr/src/cmd/format/hardware_structs.h b/usr/src/cmd/format/hardware_structs.h
index 6162cd863a..b72ebdf308 100644
--- a/usr/src/cmd/format/hardware_structs.h
+++ b/usr/src/cmd/format/hardware_structs.h
@@ -2,9 +2,8 @@
* 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.
+ * Common Development and Distribution License (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
* or http://www.opensolaris.org/os/licensing.
@@ -20,15 +19,13 @@
* CDDL HEADER END
*/
/*
- * Copyright 1991-2002 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _HARDWARE_STRUCTS_H
#define _HARDWARE_STRUCTS_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -81,19 +78,19 @@ struct disk_type {
ulong_t dtype_options; /* flags for options */
uint_t dtype_fmt_time; /* format time */
uint_t dtype_bpt; /* # bytes per track */
- int dtype_ncyl; /* # of data cylinders */
- int dtype_acyl; /* # of alternate cylinders */
- int dtype_pcyl; /* # of physical cylinders */
- int dtype_nhead; /* # of heads */
- int dtype_phead; /* # of physical heads */
- int dtype_nsect; /* # of data sectors/track */
- int dtype_psect; /* # physical sectors/track */
- int dtype_rpm; /* rotations per minute */
+ uint_t dtype_ncyl; /* # of data cylinders */
+ uint_t dtype_acyl; /* # of alternate cylinders */
+ uint_t dtype_pcyl; /* # of physical cylinders */
+ uint_t dtype_nhead; /* # of heads */
+ uint_t dtype_phead; /* # of physical heads */
+ uint_t dtype_nsect; /* # of data sectors/track */
+ uint_t dtype_psect; /* # physical sectors/track */
+ uint_t dtype_rpm; /* rotations per minute */
int dtype_cyl_skew; /* cylinder skew */
int dtype_trk_skew; /* track skew */
- int dtype_trks_zone; /* # tracks per zone */
- int dtype_atrks; /* # alt. tracks */
- int dtype_asect; /* # alt. sectors */
+ uint_t dtype_trks_zone; /* # tracks per zone */
+ uint_t dtype_atrks; /* # alt. tracks */
+ uint_t dtype_asect; /* # alt. sectors */
int dtype_cache; /* cache control */
int dtype_threshold; /* cache prefetch threshold */
int dtype_read_retries; /* read retries */
diff --git a/usr/src/cmd/format/io.c b/usr/src/cmd/format/io.c
index ba4c312b38..1aa2413c65 100644
--- a/usr/src/cmd/format/io.c
+++ b/usr/src/cmd/format/io.c
@@ -19,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains I/O related functions.
*/
@@ -71,7 +69,7 @@ static void pushchar(int c);
static int checkeof(void);
static void flushline(void);
static int strcnt(char *s1, char *s2);
-static int getbn(char *str, daddr_t *iptr);
+static int getbn(char *str, diskaddr_t *iptr);
static void print_input_choices(int type, u_ioparam_t *param);
static int slist_widest_str(slist_t *slist);
static void ljust_print(char *str, int width);
@@ -89,7 +87,7 @@ static void pushchar(int c);
static int checkeof(void);
static void flushline(void);
static int strcnt(char *s1, char *s2);
-static int getbn(char *str, daddr_t *iptr);
+static int getbn(char *str, diskaddr_t *iptr);
static void print_input_choices(int type, u_ioparam_t *param);
static int slist_widest_str(slist_t *slist);
static void ljust_print(char *str, int width);
@@ -347,10 +345,12 @@ geti64(str, iptr, wild)
static int
getbn(str, iptr)
char *str;
- daddr_t *iptr;
+ diskaddr_t *iptr;
{
char *cptr, *hptr, *sptr;
- int cyl, head, sect, wild;
+ int cyl, head, sect;
+ int wild;
+ diskaddr_t wild64;
TOKEN buf;
/*
@@ -366,8 +366,8 @@ getbn(str, iptr)
* If there wasn't one, convert string to an integer and return it.
*/
if (*str == '\0') {
- wild = physsects() - 1;
- if (geti(cptr, (int *)iptr, &wild))
+ wild64 = physsects() - 1;
+ if (geti64(cptr, iptr, &wild64))
return (-1);
return (0);
}
@@ -449,7 +449,7 @@ input(type, promptstr, delim, param, deflt, cmdflag)
int cmdflag;
{
int interactive, help, i, length, index, tied;
- daddr_t bn;
+ blkaddr_t bn;
diskaddr_t bn64;
char **str, **strings;
TOKEN token, cleantoken;
@@ -499,9 +499,11 @@ reprompt:
if (deflt != NULL) {
switch (type) {
case FIO_BN:
- fmt_print("[%d, ", *deflt);
- pr_dblock(fmt_print, (daddr_t)*deflt);
+#if !defined(lint) /* caller has aligned the pointer specifying FIO_BN */
+ fmt_print("[%llu, ", *(diskaddr_t *)deflt);
+ pr_dblock(fmt_print, *(diskaddr_t *)deflt);
fmt_print("]");
+#endif
break;
case FIO_INT:
fmt_print("[%d]", *deflt);
@@ -544,8 +546,9 @@ reprompt:
* Old-style partition size input, used to
* modify complete partition tables
*/
- fmt_print("[%db, %dc, %1.2fmb, %1.2fgb]", *deflt,
- bn2c(*deflt), bn2mb(*deflt), bn2gb(*deflt));
+ blokno = *(blkaddr32_t *)deflt;
+ fmt_print("[%llub, %uc, %1.2fmb, %1.2fgb]", blokno,
+ bn2c(blokno), bn2mb(blokno), bn2gb(blokno));
break;
case FIO_ECYL:
/*
@@ -578,14 +581,13 @@ reprompt:
if (part_deflt->deflt_size == 0) {
cylno = part_deflt->start_cyl;
} else if (part_deflt->start_cyl == 0) {
- cylno = bn2c(part_deflt->deflt_size)
- - 1;
+ cylno = bn2c(part_deflt->deflt_size) - 1;
} else {
cylno = (bn2c(part_deflt->deflt_size) +
part_deflt->start_cyl) - 1;
}
- fmt_print("[%db, %dc, %de, %1.2fmb, %1.2fgb]",
+ fmt_print("[%ub, %uc, %de, %1.2fmb, %1.2fgb]",
part_deflt->deflt_size,
bn2c(part_deflt->deflt_size),
cylno,
@@ -813,31 +815,22 @@ reprompt:
(uint64_t *)NULL))
break;
} else {
- if (getbn(cleantoken, &bn))
- break;
- }
- if (cur_label == L_TYPE_EFI) {
- if ((bn64 < bounds->lower) || (bn64 > bounds->upper)) {
- err_print("`");
- pr_dblock(err_print, bn64);
- err_print("' is out of range.\n");
+ if (getbn(cleantoken, &bn64))
break;
- }
- return (bn64);
}
/*
* Check to be sure it is within the legal bounds.
*/
- if ((bn < bounds->lower) || (bn > bounds->upper)) {
+ if ((bn64 < bounds->lower) || (bn64 > bounds->upper)) {
err_print("`");
- pr_dblock(err_print, bn);
+ pr_dblock(err_print, bn64);
err_print("' is out of range.\n");
break;
}
/*
- * If it's ok, return it.
+ * It's ok, return it.
*/
- return (bn);
+ return (bn64);
/*
* Expecting an integer.
*/
@@ -864,7 +857,7 @@ reprompt:
* Check to be sure it is within the legal bounds.
*/
if ((bn < bounds->lower) || (bn > bounds->upper)) {
- err_print("`%ld' is out of range.\n", bn);
+ err_print("`%lu' is out of range.\n", bn);
break;
}
/*
@@ -928,14 +921,15 @@ reprompt:
* Check to be sure it is within the legal bounds.
*/
if ((bn < bounds->lower) || (bn > bounds->upper)) {
- err_print("`%ld' is out of range.\n", bn);
+ err_print("`%lu' is out of range.\n", bn);
break;
}
/*
* For optional case, return 1 indicating that
* the user actually did enter something.
*/
- *deflt = bn;
+ if (!deflt)
+ *deflt = bn;
return (1);
/*
* Expecting a closed string. This means that the input
@@ -1107,7 +1101,7 @@ reprompt:
if (help) {
fmt_print("Expecting up to %llu blocks,",
bounds->upper);
- fmt_print(" %llu cylinders, ", bn2c(bounds->upper));
+ fmt_print(" %u cylinders, ", bn2c(bounds->upper));
fmt_print(" %1.2f megabytes, ", bn2mb(bounds->upper));
fmt_print("or %1.2f gigabytes\n", bn2gb(bounds->upper));
break;
@@ -1159,34 +1153,33 @@ reprompt:
/*
* Convert token to a disk block number.
*/
- i = bounds->upper;
- if (geti(cleantoken, &value, &i))
+ if (geti64(cleantoken, &bn64, &bounds->upper))
break;
- bn = value;
/*
* Check to be sure it is within the legal bounds.
*/
- if ((bn < bounds->lower) || (bn > bounds->upper)) {
+ if ((bn64 < bounds->lower) || (bn64 > bounds->upper)) {
err_print(
-"`%ldb' is out of the range %llu to %llu\n",
- bn, bounds->lower, bounds->upper);
+ "`%llub' is out of the range %llu "
+ "to %llu\n",
+ bn64, bounds->lower, bounds->upper);
break;
}
/*
* Verify the block lies on a cylinder boundary
*/
- if ((bn % spc()) != 0) {
+ if ((bn64 % spc()) != 0) {
err_print(
-"partition size must be a multiple of %d blocks to lie on a cylinder \
-boundary\n",
+ "partition size must be a multiple of "
+ "%u blocks to lie on a cylinder boundary\n",
spc());
err_print(
-"%ld blocks is approximately %ld cylinders, %1.2f megabytes or %1.2f\
-gigabytes\n",
- bn, bn2c(bn), bn2mb(bn), bn2gb(bn));
+ "%llu blocks is approximately %u cylinders,"
+ " %1.2f megabytes or %1.2f gigabytes\n",
+ bn64, bn2c(bn64), bn2mb(bn64), bn2gb(bn64));
break;
}
- return (bn);
+ return (bn64);
case 'c':
/*
* Convert token from a number of cylinders to
@@ -1225,13 +1218,13 @@ gigabytes\n",
/*
* Convert to blocks
*/
- bn = mb2bn(nmegs);
+ bn64 = mb2bn(nmegs);
/*
* Round value up to nearest cylinder
*/
i = spc();
- bn = ((bn + (i-1)) / i) * i;
- return (bn);
+ bn64 = ((bn64 + (i-1)) / i) * i;
+ return (bn64);
case 'g':
/*
* Convert token from gigabytes to a block number.
@@ -1251,13 +1244,13 @@ gigabytes\n",
/*
* Convert to blocks
*/
- bn = gb2bn(ngigs);
+ bn64 = gb2bn(ngigs);
/*
* Round value up to nearest cylinder
*/
i = spc();
- bn = ((bn + (i-1)) / i) * i;
- return (bn);
+ bn64 = ((bn64 + (i-1)) / i) * i;
+ return (bn64);
default:
err_print(
"Please specify units in either b(blocks), c(cylinders), m(megabytes) \
@@ -1279,10 +1272,10 @@ or g(gigabytes)\n");
if (help) {
fmt_print("Expecting up to %llu blocks,",
bounds->upper);
- fmt_print(" %llu cylinders, ",
+ fmt_print(" %u cylinders, ",
bn2c(bounds->upper));
- fmt_print(" %llu end cylinder, ",
- (bounds->upper / spc()));
+ fmt_print(" %u end cylinder, ",
+ (uint_t)(bounds->upper / spc()));
fmt_print(" %1.2f megabytes, ",
bn2mb(bounds->upper));
fmt_print("or %1.2f gigabytes\n",
@@ -1345,18 +1338,16 @@ or g(gigabytes)\n");
/*
* Convert token to a disk block number.
*/
- i = bounds->upper;
- if (geti(cleantoken, &value, &i))
+ if (geti64(cleantoken, &bn64, &bounds->upper))
break;
- bn = value;
/*
* Check to be sure it is within the
* legal bounds.
*/
- if ((bn < bounds->lower) || (bn > bounds->upper)) {
+ if ((bn64 < bounds->lower) || (bn64 > bounds->upper)) {
err_print(
-"`%ldb' is out of the range %llu to %llu\n",
- bn, bounds->lower, bounds->upper);
+"`%llub' is out of the range %llu to %llu\n",
+ bn64, bounds->lower, bounds->upper);
break;
}
@@ -1364,19 +1355,19 @@ or g(gigabytes)\n");
* Verify the block lies on a cylinder
* boundary
*/
- if ((bn % spc()) != 0) {
+ if ((bn64 % spc()) != 0) {
err_print(
-"partition size must be a multiple of %d blocks to lie on a cylinder \
-boundary\n",
+ "partition size must be a multiple of %u "
+ "blocks to lie on a cylinder boundary\n",
spc());
err_print(
-"%ld blocks is approximately %ld cylinders, %1.2f \
-megabytes or %1.2f gigabytes\n",
- bn, bn2c(bn), bn2mb(bn), bn2gb(bn));
+ "%llu blocks is approximately %u cylinders,"
+ " %1.2f megabytes or %1.2f gigabytes\n",
+ bn64, bn2c(bn64), bn2mb(bn64), bn2gb(bn64));
break;
}
- return (bn);
+ return (bn64);
case 'e':
/*
@@ -1396,7 +1387,7 @@ megabytes or %1.2f gigabytes\n",
*/
if (cylno < part_deflt->start_cyl) {
err_print(
-"End cylinder must fall on or after start cylinder %d\n",
+"End cylinder must fall on or after start cylinder %u\n",
part_deflt->start_cyl);
break;
}
@@ -1467,14 +1458,14 @@ megabytes or %1.2f gigabytes\n",
/*
* Convert to blocks
*/
- bn = mb2bn(nmegs);
+ bn64 = mb2bn(nmegs);
/*
* Round value up to nearest cylinder
*/
i = spc();
- bn = ((bn + (i-1)) / i) * i;
- return (bn);
+ bn64 = ((bn64 + (i-1)) / i) * i;
+ return (bn64);
case 'g':
/*
@@ -1498,14 +1489,14 @@ megabytes or %1.2f gigabytes\n",
/*
* Convert to blocks
*/
- bn = gb2bn(ngigs);
+ bn64 = gb2bn(ngigs);
/*
* Round value up to nearest cylinder
*/
i = spc();
- bn = ((bn + (i-1)) / i) * i;
- return (bn);
+ bn64 = ((bn64 + (i-1)) / i) * i;
+ return (bn64);
default:
err_print(
@@ -2106,7 +2097,7 @@ pr_diskline(disk, num)
fmt_print(" %4d. %s ", num, disk->disk_name);
if ((type != NULL) && (disk->label_type == L_TYPE_SOLARIS)) {
- fmt_print("<%s cyl %d alt %d hd %d sec %d>",
+ fmt_print("<%s cyl %u alt %u hd %u sec %u>",
type->dtype_asciilabel, type->dtype_ncyl,
type->dtype_acyl, type->dtype_nhead,
type->dtype_nsect);
@@ -2145,7 +2136,7 @@ pr_diskline(disk, num)
fmt_print("\n");
if (type != NULL) {
fmt_print(
-" %s%d: <%s cyl %d alt %d hd %d sec %d>\n",
+" %s%d: <%s cyl %u alt %u hd %u sec %u>\n",
ctlr->ctlr_dname, disk->disk_dkinfo.dki_unit,
type->dtype_asciilabel, type->dtype_ncyl,
type->dtype_acyl, type->dtype_nhead,
@@ -2160,15 +2151,13 @@ pr_diskline(disk, num)
/*
* This routine prints out a given disk block number in cylinder/head/sector
* format. It uses the printing routine passed in to do the actual output.
- * Downcasting bn is okay for L_TYPE_SOLARIS because the number of blocks
- * on a Solaris (VTOC) label will never exceed 4 bytes (daddr_t).
*/
void
pr_dblock(void (*func)(char *, ...), diskaddr_t bn)
{
if (cur_label == L_TYPE_SOLARIS) {
- (*func)("%d/%d/%d", bn2c((daddr_t)bn),
- bn2h((daddr_t)bn), bn2s((daddr_t)bn));
+ (*func)("%u/%u/%u", bn2c(bn),
+ bn2h(bn), bn2s(bn));
} else {
(*func)("%llu", bn);
}
diff --git a/usr/src/cmd/format/io.h b/usr/src/cmd/format/io.h
index 059f887dfd..e20c719c02 100644
--- a/usr/src/cmd/format/io.h
+++ b/usr/src/cmd/format/io.h
@@ -2,9 +2,8 @@
* 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.
+ * Common Development and Distribution License (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
* or http://www.opensolaris.org/os/licensing.
@@ -20,15 +19,13 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _IO_H
#define _IO_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -55,8 +52,8 @@ typedef struct slist {
* Input structure for current partition information
*/
typedef struct partition_defaults {
- int start_cyl;
- int deflt_size;
+ uint_t start_cyl;
+ uint_t deflt_size;
} part_deflt_t;
typedef struct efi_defaults {
diff --git a/usr/src/cmd/format/ix_altsctr.c b/usr/src/cmd/format/ix_altsctr.c
index 33c7933cbd..03770bc422 100644
--- a/usr/src/cmd/format/ix_altsctr.c
+++ b/usr/src/cmd/format/ix_altsctr.c
@@ -2,9 +2,8 @@
* 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.
+ * Common Development and Distribution License (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
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* copyright (c) 1990, 1991 UNIX System Laboratories, Inc.
@@ -34,8 +33,6 @@
* All rights reserved.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/types.h>
#include <ctype.h>
#include <fcntl.h>
@@ -60,8 +57,6 @@
#define CMD_READ 0
#define CMD_WRITE 1
-extern daddr_t altsec_offset; /* Alternate sector offset */
-
struct badsec_lst *badsl_chain = NULL;
int badsl_chain_cnt = 0;
struct badsec_lst *gbadsl_chain = NULL;
@@ -72,8 +67,8 @@ struct alts_mempart *ap = &alts_part; /* pointer to incore */
/* alts tables */
/* prototypes */
-int updatebadsec(struct partition *, int);
-int read_altsctr(struct partition *);
+int updatebadsec(struct dkl_partition *, int);
+int read_altsctr(struct dkl_partition *);
static int chk_badsec();
static int init_altsctr();
static int get_altsctr();
@@ -84,14 +79,14 @@ static int gen_alts_ent();
static int assign_altsctr();
static void expand_map();
static void compress_map();
-static int altsmap_getbit(daddr_t);
-static int altsmap_alloc(daddr_t, daddr_t, int, int);
+static int altsmap_getbit(blkaddr_t);
+static blkaddr_t altsmap_alloc(blkaddr_t, blkaddr_t, int, int);
static void ent_sort(struct alts_ent *, int);
static void ent_compress(struct alts_ent *, int);
static int ent_merge(struct alts_ent *, struct alts_ent *, int,
struct alts_ent *, int);
static int ent_bsearch(struct alts_ent *, int, struct alts_ent *);
-static int chk_bad_altsctr(daddr_t);
+static int chk_bad_altsctr(blkaddr_t);
/*
* updatebadsec () -- update bad sector/track mapping tables
@@ -99,7 +94,7 @@ static int chk_bad_altsctr(daddr_t);
int
updatebadsec(part, init_flag)
int init_flag;
-struct partition *part;
+struct dkl_partition *part;
{
if (init_flag)
ap->ap_flag |= ALTS_ADDPART;
@@ -118,7 +113,7 @@ struct partition *part;
*/
int
read_altsctr(part)
-struct partition *part;
+struct dkl_partition *part;
{
if (ap->ap_tblp == NULL) {
/* allocate buffer for the alts partition table (sector size) */
@@ -180,9 +175,9 @@ struct partition *part;
static int
chk_badsec()
{
- daddr_t badsec;
- daddr_t altsp_srtsec = ap->part.p_start;
- daddr_t altsp_endsec = ap->part.p_start + ap->part.p_size - 1;
+ blkaddr_t badsec;
+ blkaddr_t altsp_srtsec = ap->part.p_start;
+ blkaddr_t altsp_endsec = ap->part.p_start + ap->part.p_size - 1;
int cnt;
int status;
@@ -213,10 +208,10 @@ chk_badsec()
return (55);
}
(ap->ap_memmapp)[badsec - altsp_srtsec] = ALTS_BAD;
- (ap->ap_gbadp)[cnt].bad_start = ALTS_ENT_EMPTY;
+ (ap->ap_gbadp)[cnt].bad_start = (uint32_t)ALTS_ENT_EMPTY;
} else {
status = chk_bad_altsctr(badsec);
- (ap->ap_gbadp)[cnt].bad_start = ALTS_ENT_EMPTY;
+ (ap->ap_gbadp)[cnt].bad_start = (uint32_t)ALTS_ENT_EMPTY;
}
} else {
/*
@@ -229,7 +224,7 @@ chk_badsec()
* then ignore the bad sector
*/
if (status != -1) {
- (ap->ap_gbadp)[cnt].bad_start = ALTS_ENT_EMPTY;
+ (ap->ap_gbadp)[cnt].bad_start = (uint32_t)ALTS_ENT_EMPTY;
}
}
}
@@ -242,9 +237,9 @@ chk_badsec()
static int
init_altsctr()
{
- daddr_t badsec;
- daddr_t altsp_srtsec = ap->part.p_start;
- daddr_t altsp_endsec = ap->part.p_start + ap->part.p_size - 1;
+ blkaddr_t badsec;
+ blkaddr_t altsp_srtsec = ap->part.p_start;
+ blkaddr_t altsp_endsec = ap->part.p_start + ap->part.p_size - 1;
int cnt;
ap->ap_entp = NULL;
@@ -268,7 +263,7 @@ init_altsctr()
return (56);
}
(ap->ap_memmapp)[badsec - altsp_srtsec] = ALTS_BAD;
- (ap->ap_gbadp)[cnt].bad_start = ALTS_ENT_EMPTY;
+ (ap->ap_gbadp)[cnt].bad_start = (uint32_t)ALTS_ENT_EMPTY;
}
}
@@ -393,8 +388,8 @@ get_badsec()
{
int cnt;
struct badsec_lst *blc_p;
- daddr_t curbad;
- long maxsec = (long)cur_dtype->dtype_nhead *
+ blkaddr_t curbad;
+ blkaddr_t maxsec = cur_dtype->dtype_nhead *
cur_dtype->dtype_ncyl *
cur_dtype->dtype_nsect;
struct alts_ent *growbadp;
@@ -417,7 +412,7 @@ get_badsec()
blc_p; blc_p = blc_p->bl_nxt) {
for (i = 0; i < blc_p->bl_cnt; i++) {
curbad = blc_p->bl_sec[i];
- if (curbad < (daddr_t)cur_dtype->dtype_nsect) {
+ if (curbad < (blkaddr_t)cur_dtype->dtype_nsect) {
(void) fprintf(stderr,
"Ignoring bad sector %ld which is in first track of the drive.\n", curbad);
continue;
@@ -466,7 +461,7 @@ count_badsec()
*/
static int
gen_alts_ent() {
- int ent_used;
+ uint_t ent_used;
struct alts_ent *entp;
if (ap->ap_gbadcnt == 0)
@@ -498,8 +493,8 @@ gen_alts_ent() {
/* allocate the alts_entry on disk skipping possible bad sectors */
ap->ap_tblp->alts_ent_base =
- altsmap_alloc(ap->ap_tblp->alts_map_base + ap->ap_map_sectot,
- ap->part.p_size,
+ altsmap_alloc((blkaddr_t)ap->ap_tblp->alts_map_base +
+ ap->ap_map_sectot, (blkaddr_t)ap->part.p_size,
ap->ap_ent_secsiz / NBPSCTR, ALTS_MAP_UP);
if (ap->ap_tblp->alts_ent_base == NULL) {
perror("Unable to allocate alternate entry table on disk: ");
@@ -518,13 +513,13 @@ gen_alts_ent() {
static int
assign_altsctr()
{
- int i;
- int j;
- daddr_t alts_ind;
- int cluster;
+ uint_t i;
+ uint_t j;
+ blkaddr_t alts_ind;
+ uint_t cluster;
for (i = 0; i < ap->ap_tblp->alts_ent_used; i++) {
- if ((ap->ap_entp)[i].bad_start == ALTS_ENT_EMPTY)
+ if ((ap->ap_entp)[i].bad_start == (uint32_t)ALTS_ENT_EMPTY)
continue;
if ((ap->ap_entp)[i].good_start != 0)
continue;
@@ -596,10 +591,10 @@ compress_map()
*/
static int
altsmap_getbit(badsec)
-daddr_t badsec;
+blkaddr_t badsec;
{
- int slot = badsec / 8;
- int field = badsec % 8;
+ uint_t slot = badsec / 8;
+ uint_t field = badsec % 8;
uchar_t mask;
mask = ALTS_BAD<<7;
@@ -613,16 +608,16 @@ daddr_t badsec;
/*
* allocate a range of sectors from the alternate partition
*/
-static int
+static blkaddr_t
altsmap_alloc(srt_ind, end_ind, cnt, dir)
-daddr_t srt_ind;
-daddr_t end_ind;
+blkaddr_t srt_ind;
+blkaddr_t end_ind;
int cnt;
int dir;
{
- int i;
- int total;
- int first_ind;
+ blkaddr_t i;
+ blkaddr_t total;
+ blkaddr_t first_ind;
for (i = srt_ind, first_ind = srt_ind, total = 0;
i != end_ind; i += dir) {
@@ -688,15 +683,15 @@ int movp;
int i;
for (i = 0; i < cnt; i++) {
- if (buf[i].bad_start == ALTS_ENT_EMPTY)
+ if (buf[i].bad_start == (uint32_t)ALTS_ENT_EMPTY)
continue;
for (keyp = i, movp = i+1; movp < cnt; movp++) {
- if (buf[movp].bad_start == ALTS_ENT_EMPTY)
+ if (buf[movp].bad_start == (uint32_t)ALTS_ENT_EMPTY)
continue;
if (buf[keyp].bad_end+1 != buf[movp].bad_start)
break;
buf[keyp].bad_end++;
- buf[movp].bad_start = ALTS_ENT_EMPTY;
+ buf[movp].bad_start = (uint32_t)ALTS_ENT_EMPTY;
}
if (movp == cnt) break;
}
@@ -719,11 +714,11 @@ int lcnt2;
int j1, j2;
for (i = 0, j1 = 0, j2 = 0; j1 < lcnt1 && j2 < lcnt2; ) {
- if (list1[j1].bad_start == ALTS_ENT_EMPTY) {
+ if (list1[j1].bad_start == (uint32_t)ALTS_ENT_EMPTY) {
j1++;
continue;
}
- if (list2[j2].bad_start == ALTS_ENT_EMPTY) {
+ if (list2[j2].bad_start == (uint32_t)ALTS_ENT_EMPTY) {
j2++;
continue;
}
@@ -733,12 +728,12 @@ int lcnt2;
buf[i++] = list2[j2++];
}
for (; j1 < lcnt1; j1++) {
- if (list1[j1].bad_start == ALTS_ENT_EMPTY)
+ if (list1[j1].bad_start == (uint32_t)ALTS_ENT_EMPTY)
continue;
buf[i++] = list1[j1];
}
for (; j2 < lcnt2; j2++) {
- if (list2[j2].bad_start == ALTS_ENT_EMPTY)
+ if (list2[j2].bad_start == (uint32_t)ALTS_ENT_EMPTY)
continue;
buf[i++] = list2[j2];
}
@@ -791,10 +786,10 @@ struct alts_ent *key;
*/
static int
chk_bad_altsctr(badsec)
-daddr_t badsec;
+blkaddr_t badsec;
{
int i;
- daddr_t numsec;
+ blkaddr_t numsec;
int cnt = ap->ap_tblp->alts_ent_used;
/*
* daddr_t intv[3];
diff --git a/usr/src/cmd/format/label.c b/usr/src/cmd/format/label.c
index d4362250a2..3f172c5806 100644
--- a/usr/src/cmd/format/label.c
+++ b/usr/src/cmd/format/label.c
@@ -23,8 +23,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains the code relating to label manipulation.
*/
@@ -60,10 +58,10 @@
* Prototypes for ANSI C compilers
*/
static int do_geometry_sanity_check(void);
-static int vtoc_to_label(struct dk_label *label, struct vtoc *vtoc,
+static int vtoc_to_label(struct dk_label *label, struct extvtoc *vtoc,
struct dk_geom *geom, struct dk_cinfo *cinfo);
-extern int read_vtoc(int, struct vtoc *);
-extern int write_vtoc(int, struct vtoc *);
+extern int read_extvtoc(int, struct extvtoc *);
+extern int write_extvtoc(int, struct extvtoc *);
static int vtoc64_to_label(struct efi_info *, struct dk_gpt *);
#else /* __STDC__ */
@@ -73,12 +71,16 @@ static int vtoc64_to_label(struct efi_info *, struct dk_gpt *);
*/
static int do_geometry_sanity_check();
static int vtoc_to_label();
-extern int read_vtoc();
-extern int write_vtoc();
+extern int read_extvtoc();
+extern int write_extvtoc();
static int vtoc64_to_label();
#endif /* __STDC__ */
+#ifdef DEBUG
+static void dump_label(struct dk_label *label);
+#endif
+
/*
* This routine checks the given label to see if it is valid.
*/
@@ -212,7 +214,7 @@ do_geometry_sanity_check()
/*
* create a clear EFI partition table when format is used
- * to convert a SMI label to an EFI lable
+ * to convert an SMI label to an EFI label
*/
int
SMI_vtoc_to_EFI(int fd, struct dk_gpt **new_vtoc)
@@ -269,7 +271,7 @@ write_label()
int error = 0, head, sec;
struct dk_label label;
struct dk_label new_label;
- struct vtoc vtoc;
+ struct extvtoc vtoc;
struct dk_geom geom;
struct dk_gpt *vtoc64;
int nbackups;
@@ -420,7 +422,7 @@ write_label()
* always use an ioctl to read the vtoc from the
* driver, so it can do as it likes.
*/
- if (write_vtoc(cur_file, &vtoc) != 0) {
+ if (write_extvtoc(cur_file, &vtoc) != 0) {
err_print("Warning: error writing VTOC.\n");
error = -1;
}
@@ -470,17 +472,17 @@ write_label()
/*
* Read the label from the disk.
- * Do this via the read_vtoc() library routine, then convert it to a label.
+ * Do this via the read_extvtoc() library routine, then convert it to a label.
* We also need a DKIOCGGEOM ioctl to get the disk's geometry.
*/
int
read_label(int fd, struct dk_label *label)
{
- struct vtoc vtoc;
+ struct extvtoc vtoc;
struct dk_geom geom;
struct dk_cinfo dkinfo;
- if (read_vtoc(fd, &vtoc) < 0 ||
+ if (read_extvtoc(fd, &vtoc) < 0 ||
ioctl(fd, DKIOCGGEOM, &geom) == -1 ||
ioctl(fd, DKIOCINFO, &dkinfo) == -1) {
return (-1);
@@ -667,8 +669,8 @@ vtoc64_to_label(struct efi_info *label, struct dk_gpt *vtoc)
* Convert vtoc/geom to label.
*/
static int
-vtoc_to_label(struct dk_label *label, struct vtoc *vtoc, struct dk_geom *geom,
- struct dk_cinfo *cinfo)
+vtoc_to_label(struct dk_label *label, struct extvtoc *vtoc,
+ struct dk_geom *geom, struct dk_cinfo *cinfo)
{
#if defined(_SUNOS_VTOC_8)
struct dk_map32 *lmap;
@@ -678,8 +680,8 @@ vtoc_to_label(struct dk_label *label, struct vtoc *vtoc, struct dk_geom *geom,
#error No VTOC format defined.
#endif /* defined(_SUNOS_VTOC_8) */
- struct partition *vpart;
- long nblks;
+ struct extpartition *vpart;
+ ulong_t nblks;
int i;
(void) memset((char *)label, 0, sizeof (struct dk_label));
@@ -740,13 +742,15 @@ vtoc_to_label(struct dk_label *label, struct vtoc *vtoc, struct dk_geom *geom,
for (i = 0; i < V_NUMPAR; i++) {
label->dkl_vtoc.v_part[i].p_tag = vtoc->v_part[i].p_tag;
label->dkl_vtoc.v_part[i].p_flag = vtoc->v_part[i].p_flag;
+ label->dkl_vtoc.v_timestamp[i] = vtoc->timestamp[i];
}
- (void) memcpy((char *)label->dkl_vtoc.v_bootinfo,
- (char *)vtoc->v_bootinfo, sizeof (vtoc->v_bootinfo));
- (void) memcpy((char *)label->dkl_vtoc.v_reserved,
- (char *)vtoc->v_reserved, sizeof (vtoc->v_reserved));
- (void) memcpy((char *)label->dkl_vtoc.v_timestamp,
- (char *)vtoc->timestamp, sizeof (vtoc->timestamp));
+
+ for (i = 0; i < 10; i++)
+ label->dkl_vtoc.v_reserved[i] = vtoc->v_reserved[i];
+
+ label->dkl_vtoc.v_bootinfo[0] = vtoc->v_bootinfo[0];
+ label->dkl_vtoc.v_bootinfo[1] = vtoc->v_bootinfo[1];
+ label->dkl_vtoc.v_bootinfo[2] = vtoc->v_bootinfo[2];
(void) memcpy(label->dkl_asciilabel, vtoc->v_asciilabel,
LEN_DKL_ASCII);
@@ -772,7 +776,7 @@ vtoc_to_label(struct dk_label *label, struct vtoc *vtoc, struct dk_geom *geom,
vpart = vtoc->v_part;
- nblks = (int)label->dkl_nsect * (int)label->dkl_nhead;
+ nblks = label->dkl_nsect * label->dkl_nhead;
for (i = 0; i < NDKMAP; i++, lmap++, vpart++) {
if (cinfo->dki_ctype != DKC_VBD) {
@@ -782,12 +786,12 @@ vtoc_to_label(struct dk_label *label, struct vtoc *vtoc, struct dk_geom *geom,
}
}
#if defined(_SUNOS_VTOC_8)
- lmap->dkl_cylno = vpart->p_start / nblks;
- lmap->dkl_nblk = vpart->p_size;
+ lmap->dkl_cylno = (blkaddr32_t)(vpart->p_start / nblks);
+ lmap->dkl_nblk = (blkaddr32_t)vpart->p_size;
#elif defined(_SUNOS_VTOC_16)
- lmap->p_start = vpart->p_start;
- lmap->p_size = vpart->p_size;
+ lmap->p_start = (blkaddr32_t)vpart->p_start;
+ lmap->p_size = (blkaddr32_t)vpart->p_size;
#else
#error No VTOC format defined.
#endif /* defined(_SUNOS_VTOC_8) */
@@ -798,6 +802,10 @@ vtoc_to_label(struct dk_label *label, struct vtoc *vtoc, struct dk_geom *geom,
*/
(void) checksum(label, CK_MAKESUM);
+#ifdef DEBUG
+ if (option_msg && diag_msg)
+ dump_label(label);
+#endif
return (0);
}
@@ -807,12 +815,12 @@ vtoc_to_label(struct dk_label *label, struct vtoc *vtoc, struct dk_geom *geom,
* Extract a vtoc structure out of a valid label
*/
int
-label_to_vtoc(struct vtoc *vtoc, struct dk_label *label)
+label_to_vtoc(struct extvtoc *vtoc, struct dk_label *label)
{
#if defined(_SUNOS_VTOC_8)
struct dk_map2 *lpart;
struct dk_map32 *lmap;
- long nblks;
+ ulong_t nblks;
#elif defined(_SUNOS_VTOC_16)
struct dkl_partition *lpart;
@@ -820,10 +828,10 @@ label_to_vtoc(struct vtoc *vtoc, struct dk_label *label)
#error No VTOC format defined.
#endif /* defined(_SUNOS_VTOC_8) */
- struct partition *vpart;
+ struct extpartition *vpart;
int i;
- (void) memset((char *)vtoc, 0, sizeof (struct vtoc));
+ (void) memset((char *)vtoc, 0, sizeof (struct extvtoc));
switch (label->dkl_vtoc.v_version) {
case 0:
@@ -846,21 +854,20 @@ label_to_vtoc(struct vtoc *vtoc, struct dk_label *label)
vpart->p_flag = lpart->p_flag;
#if defined(_SUNOS_VTOC_16)
- vpart->p_start = lpart->p_start;
- vpart->p_size = lpart->p_size;
+ vpart->p_start = (diskaddr_t)lpart->p_start;
+ vpart->p_size = (diskaddr_t)lpart->p_size;
#endif /* defined(_SUNOS_VTOC_16) */
+ vtoc->timestamp[i] = label->dkl_vtoc.v_timestamp[i];
}
(void) memcpy(vtoc->v_volume, label->dkl_vtoc.v_volume,
LEN_DKL_VVOL);
- (void) memcpy((char *)vtoc->v_bootinfo,
- (char *)label->dkl_vtoc.v_bootinfo,
- sizeof (vtoc->v_bootinfo));
- (void) memcpy((char *)vtoc->v_reserved,
- (char *)label->dkl_vtoc.v_reserved,
- sizeof (vtoc->v_reserved));
- (void) memcpy((char *)vtoc->timestamp,
- (char *)label->dkl_vtoc.v_timestamp,
- sizeof (vtoc->timestamp));
+
+ for (i = 0; i < 10; i++)
+ vtoc->v_reserved[i] = label->dkl_vtoc.v_reserved[i];
+
+ vtoc->v_bootinfo[0] = label->dkl_vtoc.v_bootinfo[0];
+ vtoc->v_bootinfo[1] = label->dkl_vtoc.v_bootinfo[1];
+ vtoc->v_bootinfo[2] = label->dkl_vtoc.v_bootinfo[2];
break;
default:
@@ -890,8 +897,8 @@ label_to_vtoc(struct vtoc *vtoc, struct dk_label *label)
vpart = vtoc->v_part;
nblks = label->dkl_nsect * label->dkl_nhead;
for (i = 0; i < V_NUMPAR; i++, vpart++, lmap++) {
- vpart->p_start = lmap->dkl_cylno * nblks;
- vpart->p_size = lmap->dkl_nblk;
+ vpart->p_start = (diskaddr_t)(lmap->dkl_cylno * nblks);
+ vpart->p_size = (diskaddr_t)lmap->dkl_nblk;
}
#endif /* defined(_SUNOS_VTOC_8) */
@@ -900,18 +907,17 @@ label_to_vtoc(struct vtoc *vtoc, struct dk_label *label)
/*
* Input: File descriptor
- * Output: 1 if disk is >1TB OR has an EFI label, 0 otherwise.
+ * Output: 1 if disk has an EFI label, 0 otherwise.
*/
int
is_efi_type(int fd)
{
- struct vtoc vtoc;
+ struct extvtoc vtoc;
- if (ioctl(fd, DKIOCGVTOC, &vtoc) == -1) {
- if (errno == ENOTSUP) {
- return (1);
- }
+ if (read_extvtoc(fd, &vtoc) == VT_ENOTSUP) {
+ /* assume the disk has EFI label */
+ return (1);
}
return (0);
}
@@ -1005,8 +1011,8 @@ err_check(struct dk_gpt *vtoc)
}
}
-#ifdef FOR_DEBUGGING_ONLY
-int
+#ifdef DEBUG
+static void
dump_label(label)
struct dk_label *label;
{
@@ -1064,7 +1070,7 @@ dump_label(label)
label->dkl_map[i].dkl_nblk);
#elif defined(_SUNOS_VTOC_16)
- fmt_print("%c: start=%d, blocks=%d", i+'a',
+ fmt_print("%c: start=%u, blocks=%u", i+'a',
label->dkl_vtoc.v_part[i].p_start,
label->dkl_vtoc.v_part[i].p_size);
#else
@@ -1107,4 +1113,4 @@ dump_label(label)
fmt_print("\n\n");
}
-#endif /* FOR_DEBUGGING_ONLY */
+#endif /* DEBUG */
diff --git a/usr/src/cmd/format/label.h b/usr/src/cmd/format/label.h
index 0e5563a507..e7dbba9d36 100644
--- a/usr/src/cmd/format/label.h
+++ b/usr/src/cmd/format/label.h
@@ -2,9 +2,8 @@
* 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.
+ * Common Development and Distribution License (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
* or http://www.opensolaris.org/os/licensing.
@@ -20,15 +19,13 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _LABEL_H
#define _LABEL_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -43,7 +40,7 @@ int write_label(void);
int read_label(int fd, struct dk_label *label);
int read_efi_label(int fd, struct efi_info *label);
int get_disk_info(int fd, struct efi_info *label);
-int label_to_vtoc(struct vtoc *vtoc, struct dk_label *label);
+int label_to_vtoc(struct extvtoc *vtoc, struct dk_label *label);
int SMI_vtoc_to_EFI(int fd, struct dk_gpt **new_vtoc);
void err_check(struct dk_gpt *vtoc);
extern int is_efi_type(int fd);
diff --git a/usr/src/cmd/format/main.c b/usr/src/cmd/format/main.c
index a1a5b28297..5d1d9c6c81 100644
--- a/usr/src/cmd/format/main.c
+++ b/usr/src/cmd/format/main.c
@@ -23,7 +23,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This file contains the main entry point of the program and other
* routines relating to the general flow.
@@ -542,7 +541,7 @@ Continue"))
* Check to see if there are any mounted file systems on the
* disk. If there are, print a warning.
*/
- if ((found_mount = checkmount((daddr_t)-1, (daddr_t)-1)) != 0)
+ if ((found_mount = checkmount((diskaddr_t)-1, (diskaddr_t)-1)) != 0)
err_print("Warning: Current Disk has mounted partitions.\n");
/*
diff --git a/usr/src/cmd/format/menu_analyze.c b/usr/src/cmd/format/menu_analyze.c
index 0f6bb31031..727a8b8695 100644
--- a/usr/src/cmd/format/menu_analyze.c
+++ b/usr/src/cmd/format/menu_analyze.c
@@ -2,9 +2,8 @@
* 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.
+ * Common Development and Distribution License (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
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 1991-2002 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains functions implementing the analyze menu commands.
*/
@@ -193,7 +190,7 @@ a_print()
for (j = 0; j < 6; j++)
if (i + j < scan_size * SECSIZE / sizeof (int))
fmt_print("0x%08x ",
- *((int *)((int *)cur_buf + i + j)));
+ *((int *)((int *)cur_buf + i + j)));
fmt_print("\n");
lines++;
@@ -274,11 +271,11 @@ a_setup()
ioparam.io_bounds.lower = 0;
if ((cur_ctype->ctype_flags & CF_SCSI) &&
(cur_disk->label_type == L_TYPE_SOLARIS)) {
- ioparam.io_bounds.upper = datasects() - 1;
+ ioparam.io_bounds.upper = datasects() - 1;
} else if (cur_disk->label_type == L_TYPE_SOLARIS) {
- ioparam.io_bounds.upper = physsects() - 1;
+ ioparam.io_bounds.upper = physsects() - 1;
} else if (cur_disk->label_type == L_TYPE_EFI) {
- ioparam.io_bounds.upper = cur_parts->etoc->efi_last_lba;
+ ioparam.io_bounds.upper = cur_parts->etoc->efi_last_lba;
}
scan_lower = (diskaddr_t)input(FIO_BN,
@@ -331,8 +328,8 @@ a_setup()
ioparam.io_bounds.upper = min(size, BUF_SECTS);
if (scan_size > ioparam.io_bounds.upper)
scan_size = ioparam.io_bounds.upper;
- scan_size = input(FIO_BN, "Enter number of blocks per transfer", ':',
- &ioparam, &scan_size, DATA_INPUT);
+ scan_size = input(FIO_INT, "Enter number of blocks per transfer", ':',
+ &ioparam, (int *)&scan_size, DATA_INPUT);
deflt = !scan_auto;
ioparam.io_charlist = confirm_list;
scan_auto = !input(FIO_MSTR, "Verify media after formatting", '?',
@@ -391,7 +388,7 @@ a_config()
fmt_print(scan_random ? "yes\n" : "no\n");
fmt_print(" Number of blocks per transfer: %d (", scan_size);
- pr_dblock(fmt_print, (daddr_t)scan_size);
+ pr_dblock(fmt_print, (diskaddr_t)scan_size);
fmt_print(")\n");
fmt_print(" Verify media after formatting? ");
@@ -436,9 +433,9 @@ a_purge()
if (scan_passes < NPPATTERNS) {
fmt_print("The purge command runs for a minimum of ");
fmt_print("%d passes plus a last pass if the\n",
- NPPATTERNS);
+ NPPATTERNS);
fmt_print("first %d passes were successful.\n",
- NPPATTERNS);
+ NPPATTERNS);
}
scan_passes = NPPATTERNS + 1;
}
diff --git a/usr/src/cmd/format/menu_command.c b/usr/src/cmd/format/menu_command.c
index e0bfc0b40a..1eedba1c85 100644
--- a/usr/src/cmd/format/menu_command.c
+++ b/usr/src/cmd/format/menu_command.c
@@ -147,7 +147,7 @@ c_disk()
/*
* Convert the token into an integer.
*/
- if (geti(cleantoken, (int *)&index, (int *)NULL))
+ if (geti(cleantoken, &index, (int *)NULL))
return (0);
/*
@@ -400,7 +400,7 @@ c_type()
*/
if (index == auto_conf_choice) {
float scaled;
- long nblks;
+ diskaddr_t nblks;
int nparts;
/*
@@ -415,7 +415,7 @@ c_type()
}
fmt_print("%s: configured with capacity of ",
cur_disk->disk_name);
- nblks = tptr->dtype_ncyl * tptr->dtype_nhead *
+ nblks = (diskaddr_t)tptr->dtype_ncyl * tptr->dtype_nhead *
tptr->dtype_nsect;
scaled = bn2mb(nblks);
if (scaled > 1024.0) {
@@ -593,7 +593,7 @@ c_type()
* running from a file.
*/
if ((tptr != oldtype) &&
- checkmount((daddr_t)-1, (daddr_t)-1)) {
+ checkmount((diskaddr_t)-1, (diskaddr_t)-1)) {
err_print(
"Cannot set disk type while it has mounted partitions.\n\n");
return (-1);
@@ -602,7 +602,7 @@ c_type()
* check for partitions being used for swapping in format zone
*/
if ((tptr != oldtype) &&
- checkswap((daddr_t)-1, (daddr_t)-1)) {
+ checkswap((diskaddr_t)-1, (diskaddr_t)-1)) {
err_print("Cannot set disk type while its partition are \
currently being used for swapping.\n");
return (-1);
@@ -770,7 +770,8 @@ c_format()
time_t clock;
int format_time, format_tracks, format_cyls;
int format_interval;
- int deflt, status;
+ diskaddr_t deflt;
+ int status;
u_ioparam_t ioparam;
/*
@@ -827,12 +828,12 @@ c_format()
deflt = ioparam.io_bounds.lower;
start = input(FIO_BN,
"Enter starting block number", ':',
- &ioparam, &deflt, DATA_INPUT);
+ &ioparam, (int *)&deflt, DATA_INPUT);
ioparam.io_bounds.lower = start;
deflt = ioparam.io_bounds.upper;
end = input(FIO_BN,
"Enter ending block number", ':',
- &ioparam, &deflt, DATA_INPUT);
+ &ioparam, (int *)&deflt, DATA_INPUT);
}
/*
* Some disks can format tracks. Make sure the whole track is
@@ -1277,7 +1278,7 @@ int
c_show()
{
u_ioparam_t ioparam;
- daddr_t bn;
+ diskaddr_t bn;
/*
* There must be a current disk type, so we will know the geometry.
@@ -1295,12 +1296,12 @@ c_show()
} else {
ioparam.io_bounds.upper = cur_parts->etoc->efi_last_lba;
}
- bn = (daddr_t)input(FIO_BN, "Enter a disk block", ':',
+ bn = input(FIO_BN, "Enter a disk block", ':',
&ioparam, (int *)NULL, DATA_INPUT);
/*
* Echo it back.
*/
- fmt_print("Disk block = %ld = 0x%lx = (", bn, bn);
+ fmt_print("Disk block = %lld = 0x%llx = (", bn, bn);
pr_dblock(fmt_print, bn);
fmt_print(")\n\n");
return (0);
@@ -1342,7 +1343,7 @@ c_label()
* only if the partitions would change for the mounted partitions.
*
*/
- if (checkmount((daddr_t)-1, (daddr_t)-1)) {
+ if (checkmount((diskaddr_t)-1, (diskaddr_t)-1)) {
/* Bleagh, too descriptive */
if (check_label_with_mount()) {
err_print("Cannot label disk while it has "
@@ -1356,7 +1357,7 @@ c_label()
* on the current disk. If so, refuse to label the disk, but
* only if the partitions would change for the mounted partitions.
*/
- if (checkswap((daddr_t)-1, (daddr_t)-1)) {
+ if (checkswap((diskaddr_t)-1, (diskaddr_t)-1)) {
if (check_label_with_swap()) {
err_print("Cannot label disk while its "
"partitions are currently being used for "
@@ -1402,19 +1403,13 @@ c_label()
#endif
int choice;
u_ioparam_t ioparam;
- struct vtoc vtoc;
+ struct extvtoc vtoc;
struct dk_label label;
struct dk_gpt *vtoc64;
struct efi_info efinfo;
struct disk_type *dptr;
- /* If capacity > 1TB then offer no choice */
- if (cur_label == L_TYPE_EFI) {
- if (cur_dtype->capacity > INFINITY) {
- goto expert_end;
- }
- }
- /* Ask user what label to use */
+ /* Ask user what label to use */
fmt_print("[0] SMI Label\n");
fmt_print("[1] EFI Label\n");
ioparam.io_bounds.lower = 0;
@@ -1437,29 +1432,34 @@ c_label()
* EFI label to SMI label
*/
if (cur_dtype->capacity > INFINITY) {
- fmt_print("SMI Label not supported on this disk\n");
- return (-1);
+ fmt_print("Warning: SMI labels only support up to 2 TB.\n");
}
-
- fmt_print("Warning: This disk has an EFI label. Changing to "
- "SMI label will erase all\ncurrent partitions.\n");
-
- if (check("Continue"))
+ if (cur_disk->fdisk_part.systid == EFI_PMBR) {
+ fmt_print("Warning: This disk has an EFI label. Changing to"
+ " SMI label will erase all\ncurrent partitions.\n");
+ if (check("Continue"))
return (-1);
-
- (void) memset((char *)&label, 0, sizeof (struct dk_label));
-
- if ((cur_disk->fdisk_part.systid == EFI_PMBR) ||
- (((cur_disk->fdisk_part.systid == SUNIXOS) ||
- (cur_disk->fdisk_part.systid == SUNIXOS2)) &&
- (cur_disk->fdisk_part.numsect == 0))) {
- fmt_print("You must use fdisk to delete the current "
+#if defined(_FIRMWARE_NEEDS_FDISK)
+ fmt_print("You must use fdisk to delete the current "
"EFI partition and create a new\n"
"Solaris partition before you can convert the "
"label.\n");
+ return (-1);
+#endif
+ }
+
+#if defined(_FIRMWARE_NEEDS_FDISK)
+ if (!(((cur_disk->fdisk_part.systid != SUNIXOS) ||
+ (cur_disk->fdisk_part.systid != SUNIXOS2)) &&
+ (cur_disk->fdisk_part.numsect > 0))) {
+ fmt_print("You must use fdisk to create a Solaris "
+ "partition before you can convert the label.\n");
return (-1);
}
+#endif
+
+ (void) memset((char *)&label, 0, sizeof (struct dk_label));
(void) strcpy(x86_devname, cur_disk->disk_name);
if (cur_ctype->ctype_ctype == DKC_DIRECT)
@@ -1696,7 +1696,7 @@ c_backup()
struct dk_label label;
struct disk_type *dtype;
struct partition_info *parts, *plist;
- daddr_t bn;
+ diskaddr_t bn;
int sec, head, i;
/*
@@ -1757,7 +1757,7 @@ c_backup()
/*
* Attempt to read it.
*/
- if ((*cur_ops->op_rdwr)(DIR_READ, cur_file, (diskaddr_t)bn,
+ if ((*cur_ops->op_rdwr)(DIR_READ, cur_file, bn,
1, (char *)&label, F_NORMAL, NULL)) {
continue;
}
@@ -1922,7 +1922,7 @@ c_verify()
{
struct dk_label p_label, b_label, *label;
struct partition_info tmp_pinfo;
- daddr_t bn;
+ diskaddr_t bn;
int sec, head, i, status;
int p_label_bad = 0;
int b_label_bad = 0;
@@ -2008,7 +2008,7 @@ Warning: Primary label on disk appears to be different from\ncurrent label.\n");
/*
* Attempt to read it.
*/
- if ((*cur_ops->op_rdwr)(DIR_READ, cur_file, (diskaddr_t)bn,
+ if ((*cur_ops->op_rdwr)(DIR_READ, cur_file, bn,
1, (char *)&b_label, F_NORMAL, NULL))
continue;
/*
@@ -2220,7 +2220,7 @@ c_volname()
* only if the partitions would change for the mounted partitions.
*
*/
- if (checkmount((daddr_t)-1, (daddr_t)-1)) {
+ if (checkmount((diskaddr_t)-1, (diskaddr_t)-1)) {
/* Bleagh, too descriptive */
if (check_label_with_mount()) {
err_print(
@@ -2235,7 +2235,7 @@ c_volname()
* only if the partitions would change for the swap partitions.
*
*/
- if (checkswap((daddr_t)-1, (daddr_t)-1)) {
+ if (checkswap((diskaddr_t)-1, (diskaddr_t)-1)) {
/* Bleagh, too descriptive */
if (check_label_with_swap()) {
err_print(
diff --git a/usr/src/cmd/format/menu_defect.c b/usr/src/cmd/format/menu_defect.c
index e8c20dccaf..9a31134ec9 100644
--- a/usr/src/cmd/format/menu_defect.c
+++ b/usr/src/cmd/format/menu_defect.c
@@ -2,9 +2,8 @@
* 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.
+ * Common Development and Distribution License (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
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 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 the defect menu commands.
*/
@@ -264,7 +261,8 @@ and may take a long while. Continue"))
int
d_add()
{
- int type, bn, deflt, index;
+ int type, deflt, index;
+ diskaddr_t bn;
u_ioparam_t ioparam;
struct defect_entry def;
diff --git a/usr/src/cmd/format/menu_fdisk.c b/usr/src/cmd/format/menu_fdisk.c
index d5c6d21f35..4ebadee5ab 100644
--- a/usr/src/cmd/format/menu_fdisk.c
+++ b/usr/src/cmd/format/menu_fdisk.c
@@ -19,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains functions that implement the fdisk menu commands.
*/
@@ -335,15 +333,6 @@ c_fdisk()
}
/*
- * If disk is larger than 1TB then an EFI label is required
- * and there is no point in running fdisk
- */
- if (cur_dtype->capacity > INFINITY) {
- err_print("This disk must use an EFI label.\n");
- return (-1);
- }
-
- /*
* Before running the fdisk command, get file status of
* /dev/rdsk/cn[tn]dnp0 path to see if this disk
* supports fixed disk partition table.
@@ -494,7 +483,7 @@ get_solaris_part(int fd, struct ipart *ipart)
}
#endif /* DEBUG */
- solaris_offset = lel(ip.relsect);
+ solaris_offset = (uint_t)lel(ip.relsect);
break;
}
}
@@ -515,13 +504,20 @@ get_solaris_part(int fd, struct ipart *ipart)
/* if the disk partitioning has changed - get the VTOC */
if (status) {
- status = ioctl(fd, DKIOCGVTOC, &cur_parts->vtoc);
+ struct extvtoc exvtoc;
+ struct vtoc vtoc;
+
+ status = ioctl(fd, DKIOCGEXTVTOC, &exvtoc);
if (status == -1) {
i = errno;
- err_print("Bad ioctl DKIOCGVTOC.\n");
- err_print("errno=%d %s\n", i, strerror(i));
- err_print("Cannot read vtoc information.\n");
- return (-1);
+ /* Try the old ioctl DKIOCGVTOC */
+ status = ioctl(fd, DKIOCGVTOC, &vtoc);
+ if (status == -1) {
+ err_print("Bad ioctl DKIOCGEXTVTOC.\n");
+ err_print("errno=%d %s\n", i, strerror(i));
+ err_print("Cannot read vtoc information.\n");
+ return (-1);
+ }
}
status = read_label(fd, &update_label);
@@ -530,6 +526,9 @@ get_solaris_part(int fd, struct ipart *ipart)
return (-1);
}
+ /* copy vtoc information */
+ cur_parts->vtoc = update_label.dkl_vtoc;
+
#if defined(_SUNOS_VTOC_16)
/*
* this is to update the slice table on x86
diff --git a/usr/src/cmd/format/menu_partition.c b/usr/src/cmd/format/menu_partition.c
index 9b5b5b6749..aea7354f12 100644
--- a/usr/src/cmd/format/menu_partition.c
+++ b/usr/src/cmd/format/menu_partition.c
@@ -23,8 +23,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains functions to implement the partition menu commands.
*/
@@ -201,9 +199,9 @@ p_select()
struct partition_info *pptr, *parts;
u_ioparam_t ioparam;
int i, index, deflt, *defltptr = NULL;
- long b_cylno;
+ blkaddr_t b_cylno;
#if defined(i386)
- long cyl_offset;
+ blkaddr_t cyl_offset;
#endif
parts = cur_dtype->dtype_plist;
@@ -291,13 +289,14 @@ p_select()
pptr->pinfo_map[i].dkl_cylno);
return (0);
}
- if (pptr->pinfo_map[i].dkl_nblk < 0 ||
+ if (pptr->pinfo_map[i].dkl_nblk == 0 ||
(int)pptr->pinfo_map[i].dkl_nblk > ((ncyl -
pptr->pinfo_map[i].dkl_cylno) * spc())) {
err_print(
-"partition %c: specified # of blocks, %d, is out of range\n",
- (PARTITION_BASE+i),
- pptr->pinfo_map[i].dkl_nblk);
+ "partition %c: specified # of blocks, %u, "
+ "is out of range\n",
+ (PARTITION_BASE+i),
+ pptr->pinfo_map[i].dkl_nblk);
return (0);
}
}
@@ -319,10 +318,10 @@ p_select()
#if defined(_SUNOS_VTOC_16)
for (i = 0; i < NDKMAP; i++) {
cur_parts->vtoc.v_part[i].p_start =
- (daddr_t)(cur_parts->pinfo_map[i].dkl_cylno *
+ (blkaddr_t)(cur_parts->pinfo_map[i].dkl_cylno *
(nhead * nsect));
cur_parts->vtoc.v_part[i].p_size =
- (long)cur_parts->pinfo_map[i].dkl_nblk;
+ (blkaddr_t)cur_parts->pinfo_map[i].dkl_nblk;
}
#endif /* defined(_SUNOS_VTOC_16) */
@@ -561,15 +560,15 @@ void
print_partition(struct partition_info *pinfo, int partnum, int want_header)
{
int i;
- uint_t nblks;
+ blkaddr_t nblks;
int cyl1;
int cyl2;
float scaled;
int maxcyl2;
int ncyl2_digits;
char *s;
- daddr_t maxnblks = 0;
- size_t len;
+ blkaddr_t maxnblks = 0;
+ blkaddr_t len;
/*
* To align things nicely, we need to know the maximum
@@ -662,7 +661,7 @@ print_partition(struct partition_info *pinfo, int partnum, int want_header)
*/
len = strlen(" %") + ndigits(ndigits(maxnblks)) + strlen("d\n") + 1;
s = zalloc(len);
- (void) snprintf(s, len, "%s%d%s", " %", ndigits(maxnblks), "u\n");
+ (void) snprintf(s, len, "%s%u%s", " %", ndigits(maxnblks), "u\n");
fmt_print(s, nblks);
(void) free(s);
}
diff --git a/usr/src/cmd/format/menu_scsi.c b/usr/src/cmd/format/menu_scsi.c
index 99ccafb72c..491aa79f84 100644
--- a/usr/src/cmd/format/menu_scsi.c
+++ b/usr/src/cmd/format/menu_scsi.c
@@ -2,9 +2,8 @@
* 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.
+ * Common Development and Distribution License (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
* or http://www.opensolaris.org/os/licensing.
@@ -21,12 +20,10 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains functions implementing the scsi menu commands.
*
@@ -282,7 +279,7 @@ c_scsi()
(void) do_mode_sense(pageno);
} else if (*p == 'b') {
if (parse_change_spec(s, p, pageno,
- &change_item)) {
+ &change_item)) {
(void) do_mode_select(&change_item);
}
}
@@ -293,9 +290,9 @@ Please display the page on which you'd like to do a mode select\n");
goto error;
}
chg_item = (struct chg_list *)
- zalloc(sizeof (struct chg_list));
+ zalloc(sizeof (struct chg_list));
if (parse_change_spec(s, s, current_page,
- chg_item)) {
+ chg_item)) {
add_new_change_list_item(chg_item);
} else {
destroy_data((char *)chg_item);
@@ -552,7 +549,7 @@ do_format()
/*
* Are there mounted partitions?
*/
- if (checkmount((daddr_t)-1, (daddr_t)-1)) {
+ if (checkmount((diskaddr_t)-1, (diskaddr_t)-1)) {
err_print("Cannot format disk with mounted partitions\n\n");
return (-1);
}
@@ -560,7 +557,7 @@ do_format()
/*
* Is any of the partitions being used for swapping.
*/
- if (checkswap((daddr_t)-1, (daddr_t)-1)) {
+ if (checkswap((diskaddr_t)-1, (diskaddr_t)-1)) {
err_print("Cannot format disk while its partitions are \
currently being used for swapping.\n\n");
return (-1);
@@ -582,7 +579,7 @@ currently being used for swapping.\n\n");
deflt = 0;
ioparam.io_charlist = confirm_list;
grown_list = !input(FIO_MSTR, "Format with the Grown Defects list",
- '?', &ioparam, &deflt, DATA_INPUT);
+ '?', &ioparam, &deflt, DATA_INPUT);
/*
* Construct the uscsi format ioctl.
@@ -766,7 +763,7 @@ do_display()
break;
case CHG_MODE_CLR:
fmt_print("&= ~0x%x\n",
- (~(cp->value)) & 0xff);
+ (~(cp->value)) & 0xff);
break;
default:
impossible("do_display");
@@ -968,8 +965,7 @@ default_all_pages()
ucmd.uscsi_cdblen = CDB_GROUP0;
ucmd.uscsi_bufaddr = msbuf;
ucmd.uscsi_buflen = nbytes;
- status = uscsi_cmd(cur_file, &ucmd,
- (option_msg) ? F_NORMAL : F_SILENT);
+ status = uscsi_cmd(cur_file, &ucmd, (option_msg) ? F_NORMAL : F_SILENT);
if (status) {
if (!option_msg) {
err_print("\nMode sense page 0x3f failed\n");
@@ -984,7 +980,7 @@ default_all_pages()
*/
mh = (struct mode_header *)msbuf;
nbytes = mh->length - sizeof (struct mode_header) -
- mh->bdesc_length + 1;
+ mh->bdesc_length + 1;
p = msbuf + sizeof (struct mode_header) + mh->bdesc_length;
while (nbytes > 0) {
diff --git a/usr/src/cmd/format/misc.c b/usr/src/cmd/format/misc.c
index 9e43e3f318..f148cc3115 100644
--- a/usr/src/cmd/format/misc.c
+++ b/usr/src/cmd/format/misc.c
@@ -2,9 +2,8 @@
* 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.
+ * Common Development and Distribution License (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
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains miscellaneous routines.
*/
@@ -447,7 +444,7 @@ echo_off()
*/
if (ttystate.ttyflags == 0) {
if ((ttystate.ttyfile = open("/dev/tty",
- O_RDWR | O_NDELAY)) < 0) {
+ O_RDWR | O_NDELAY)) < 0) {
err_print("Unable to open /dev/tty.\n");
fullabort();
}
@@ -508,7 +505,7 @@ charmode_on()
*/
if (ttystate.ttyflags == 0) {
if ((ttystate.ttyfile = open("/dev/tty",
- O_RDWR | O_NDELAY)) < 0) {
+ O_RDWR | O_NDELAY)) < 0) {
err_print("Unable to open /dev/tty.\n");
fullabort();
}
@@ -874,12 +871,12 @@ bn2mb(uint64_t nblks)
}
-uint_t
+diskaddr_t
mb2bn(float mb)
{
- uint_t n;
+ diskaddr_t n;
- n = (uint_t)(mb * 1024.0 * (1024.0 / DEV_BSIZE));
+ n = (diskaddr_t)(mb * 1024.0 * (1024.0 / DEV_BSIZE));
return (n);
}
@@ -902,12 +899,12 @@ bn2tb(uint64_t nblks)
return ((n/1024.0) * DEV_BSIZE);
}
-uint_t
+diskaddr_t
gb2bn(float gb)
{
- uint_t n;
+ diskaddr_t n;
- n = (uint_t)(gb * 1024.0 * 1024.0 * (1024.0 / DEV_BSIZE));
+ n = (diskaddr_t)(gb * 1024.0 * 1024.0 * (1024.0 / DEV_BSIZE));
return (n);
}
diff --git a/usr/src/cmd/format/misc.h b/usr/src/cmd/format/misc.h
index 27ceaebab9..ca3050b02b 100644
--- a/usr/src/cmd/format/misc.h
+++ b/usr/src/cmd/format/misc.h
@@ -2,9 +2,8 @@
* 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.
+ * Common Development and Distribution License (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
* or http://www.opensolaris.org/os/licensing.
@@ -20,15 +19,13 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _MISC_H
#define _MISC_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -169,10 +166,10 @@ void canonicalize_name(char *dst, char *src);
int match_substr(char *s1, char *s2);
void dump(char *, caddr_t, int, int);
float bn2mb(uint64_t);
-uint_t mb2bn(float);
+diskaddr_t mb2bn(float);
float bn2gb(uint64_t);
float bn2tb(uint64_t);
-uint_t gb2bn(float);
+diskaddr_t gb2bn(float);
int get_tty_lines();
diff --git a/usr/src/cmd/format/modify_partition.c b/usr/src/cmd/format/modify_partition.c
index 94b56b47fe..b2bc580e69 100644
--- a/usr/src/cmd/format/modify_partition.c
+++ b/usr/src/cmd/format/modify_partition.c
@@ -19,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 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 the partition menu commands.
*/
@@ -104,7 +102,7 @@ p_modify()
/*
* If the disk has mounted partitions, cannot modify
*/
- if (checkmount((daddr_t)-1, (daddr_t)-1)) {
+ if (checkmount((diskaddr_t)-1, (diskaddr_t)-1)) {
err_print(
"Cannot modify disk partitions while it has mounted partitions.\n\n");
return (-1);
@@ -114,7 +112,7 @@ p_modify()
* If the disk has partitions currently being used for
* swapping, cannot modify
*/
- if (checkswap((daddr_t)-1, (daddr_t)-1)) {
+ if (checkswap((diskaddr_t)-1, (diskaddr_t)-1)) {
err_print(
"Cannot modify disk partitions while it is \
currently being used for swapping.\n");
@@ -396,9 +394,9 @@ static int
check_map(map)
struct dk_map32 *map;
{
- int i;
- int cyloffset = 0;
- int tot_blks = 0;
+ int i;
+ int cyloffset = 0;
+ blkaddr32_t tot_blks = 0;
#ifdef i386
/*
@@ -413,17 +411,16 @@ check_map(map)
* not modify the table.
*/
for (i = 0; i < NDKMAP; i++) {
- if (map[i].dkl_cylno < 0 ||
- map[i].dkl_cylno > (daddr_t)ncyl-1) {
+ if (map[i].dkl_cylno > (blkaddr32_t)ncyl-1) {
err_print("\
Warning: Partition %c starting cylinder %d is out of range.\n",
(PARTITION_BASE+i), map[i].dkl_cylno);
return (-1);
}
- if (map[i].dkl_nblk < 0 || map[i].dkl_nblk > (daddr_t)(ncyl -
- map[i].dkl_cylno) * spc()) {
+ if (map[i].dkl_nblk >
+ (blkaddr32_t)(ncyl - map[i].dkl_cylno) * spc()) {
err_print("\
-Warning: Partition %c, specified # of blocks, %d, is out of range.\n",
+Warning: Partition %c, specified # of blocks, %u, is out of range.\n",
(PARTITION_BASE+i), map[i].dkl_nblk);
return (-1);
}
@@ -464,8 +461,8 @@ get_user_map(map, float_part)
int float_part;
{
int i;
- int newsize;
- int deflt;
+ blkaddr32_t newsize;
+ blkaddr32_t deflt;
char tmpstr[80];
u_ioparam_t ioparam;
@@ -491,8 +488,8 @@ Warning: no space available for '%s' from Free Hog partition\n",
(void) snprintf(tmpstr, sizeof (tmpstr),
"Enter size of partition '%s' ",
partn_list[i]);
- newsize = input(FIO_CYL, tmpstr, ':',
- &ioparam, &deflt, DATA_INPUT);
+ newsize = (blkaddr32_t)input(FIO_CYL, tmpstr, ':',
+ &ioparam, (int *)&deflt, DATA_INPUT);
map[float_part].dkl_nblk -= (newsize - map[i].dkl_nblk);
map[i].dkl_nblk = newsize;
}
@@ -539,8 +536,8 @@ struct disk_type *tptr;
part->pinfo_map[i] = label->dkl_map[i];
#else
part->pinfo_map[i].dkl_cylno =
- label->dkl_vtoc.v_part[i].p_start /
- ((int)(tptr->dtype_nhead * tptr->dtype_nsect - apc));
+ label->dkl_vtoc.v_part[i].p_start /
+ (blkaddr32_t)(tptr->dtype_nhead * tptr->dtype_nsect - apc);
part->pinfo_map[i].dkl_nblk =
label->dkl_vtoc.v_part[i].p_size;
#endif /* ifdefined(_SUNOS_VTOC_8) */
diff --git a/usr/src/cmd/format/param.h b/usr/src/cmd/format/param.h
index e92005e2e5..553ee1ebb1 100644
--- a/usr/src/cmd/format/param.h
+++ b/usr/src/cmd/format/param.h
@@ -27,8 +27,6 @@
#ifndef _PARAM_H
#define _PARAM_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -37,6 +35,14 @@ extern "C" {
#define UINT16_MAX 0xffffU
#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX 0xffffffffU
+#endif
+
+#ifndef INT32_MAX
+#define INT32_MAX 0x7fffffff
+#endif
+
/*
* This file contains declarations of miscellaneous parameters.
*/
@@ -56,7 +62,7 @@ extern "C" {
#define AVG_BPS 600 /* default bytes/sector */
#define MAX_BPS 1000 /* max legal bytes/sector */
-#define INFINITY 0x7fffffff /* a big number */
+#define INFINITY 0xffffffffU /* a big number */
#define MAXBLKS(heads, spt) UINT16_MAX * heads * spt, heads, spt
#ifdef __cplusplus
diff --git a/usr/src/cmd/format/partition.c b/usr/src/cmd/format/partition.c
index 20439696f7..11ae4488a1 100644
--- a/usr/src/cmd/format/partition.c
+++ b/usr/src/cmd/format/partition.c
@@ -2,9 +2,8 @@
* 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.
+ * Common Development and Distribution License (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
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains functions that operate on partition tables.
*/
@@ -117,16 +114,16 @@ maxofN(struct dk_gpt *map)
void
change_partition(int num)
{
- int i;
+ uint_t i;
uint64_t i64, j64;
- int j;
+ uint_t j;
int deflt;
part_deflt_t p_deflt;
u_ioparam_t ioparam;
int tag;
int flag;
char msg[256];
- long cyl_offset = 0;
+ blkaddr32_t cyl_offset = 0;
efi_deflt_t efi_deflt;
/*
@@ -251,7 +248,7 @@ change_partition(int num)
ioparam.io_bounds.upper = ncyl - 1;
deflt = max(cur_parts->pinfo_map[num].dkl_cylno,
cyl_offset);
- i = input(FIO_INT, "Enter new starting cyl", ':', &ioparam,
+ i = (uint_t)input(FIO_INT, "Enter new starting cyl", ':', &ioparam,
&deflt, DATA_INPUT);
ioparam.io_bounds.lower = 0;
@@ -264,7 +261,7 @@ change_partition(int num)
ioparam.io_bounds.upper);
/* call input, passing p_deflt's address, typecast to (int *) */
- j = input(FIO_ECYL, "Enter partition size", ':', &ioparam,
+ j = (uint_t)input(FIO_ECYL, "Enter partition size", ':', &ioparam,
(int *)&p_deflt, DATA_INPUT);
/*
@@ -310,7 +307,7 @@ change_partition(int num)
* return an Error.
*/
if (tag == V_BACKUP) {
- int fullsz;
+ uint_t fullsz;
fullsz = ncyl * nhead * nsect;
if (fullsz != j) {
diff --git a/usr/src/cmd/format/startup.c b/usr/src/cmd/format/startup.c
index 7d3144c250..99aa8d9d34 100644
--- a/usr/src/cmd/format/startup.c
+++ b/usr/src/cmd/format/startup.c
@@ -19,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains the code to perform program startup. This
* includes reading the data file and the search for disks.
@@ -80,7 +78,7 @@ static void check_dtypes_for_inconsistency(struct disk_type *dp1,
struct disk_type *dp2);
static void check_pinfo_for_inconsistency(struct partition_info *pp1,
struct partition_info *pp2);
-static int str2blks(char *str);
+static uint_t str2blks(char *str);
static int str2cyls(char *str);
static struct chg_list *new_chg_list(struct disk_type *);
static char *get_physical_name(char *);
@@ -106,7 +104,7 @@ static void search_duplicate_dtypes();
static void search_duplicate_pinfo();
static void check_dtypes_for_inconsistency();
static void check_pinfo_for_inconsistency();
-static int str2blks();
+static uint_t str2blks();
static int str2cyls();
static struct chg_list *new_chg_list();
static char *get_physical_name();
@@ -943,7 +941,8 @@ sup_setpart()
struct ctlr_type *ctype = NULL;
struct partition_info *pinfo, *parts;
char *pinfo_name;
- int i, index, status, val1, val2, flags = 0;
+ int i, index, status, flags = 0;
+ uint_t val1, val2;
ushort_t vtoc_tag;
ushort_t vtoc_flag;
struct mctlr_list *mlp;
@@ -1207,7 +1206,7 @@ sup_setpart()
* is the starting cylinder number of the partition.
*/
val1 = str2cyls(cleaned);
- if (val1 == -1) {
+ if (val1 == (uint_t)(-1)) {
datafile_error("Expecting an integer, found '%s'",
cleaned);
return;
@@ -1237,7 +1236,7 @@ sup_setpart()
* they choose to be so specific.
*/
val2 = str2blks(cleaned);
- if (val2 == -1) {
+ if (val2 == (uint_t)(-1)) {
datafile_error("Expecting an integer, found '%s'",
cleaned);
return;
@@ -1454,7 +1453,7 @@ do_search(char *arglist[])
i = 0;
for (disk = disk_list; disk != NULL; disk = disk->disk_next) {
float scaled;
- long nblks;
+ diskaddr_t nblks;
struct disk_type *type;
if (disk->disk_flags & DSK_AUTO_CONFIG) {
if (i++ == 0) {
@@ -1709,7 +1708,7 @@ add_device_to_disklist(char *devname, char *devpath)
* generic check for reserved disks here, including intel disks.
*/
if (dkinfo.dki_ctype == DKC_SCSI_CCS) {
- i = scsi_rdwr(DIR_READ, search_file, (daddr_t)0,
+ i = scsi_rdwr(DIR_READ, search_file, (diskaddr_t)0,
1, (char *)&search_label, F_SILENT, NULL);
switch (i) {
case DSK_RESERVED:
@@ -1860,7 +1859,7 @@ add_device_to_disklist(char *devname, char *devpath)
/*
* If reading the label failed, and this is a SCSI
* disk, we can attempt to auto-sense the disk
- * configuration.
+ * Configuration.
*/
ctlr = search_ctlr->ctlr_ctype;
if ((status == -1) && (ctlr->ctype_ctype == DKC_SCSI_CCS)) {
@@ -2087,7 +2086,7 @@ add_device_to_disklist(char *devname, char *devpath)
#elif defined(_SUNOS_VTOC_16)
search_parts->pinfo_map[i].dkl_cylno =
search_label.dkl_vtoc.v_part[i].p_start /
- ((int)(search_label.dkl_nhead *
+ ((blkaddr32_t)(search_label.dkl_nhead *
search_label.dkl_nsect));
search_parts->pinfo_map[i].dkl_nblk =
search_label.dkl_vtoc.v_part[i].p_size;
@@ -2540,7 +2539,7 @@ check_pinfo_for_inconsistency(pp1, pp2)
*
* Returns -1 in the case of an error.
*/
-static int
+static uint_t
str2blks(char *str)
{
int blks;
@@ -2591,7 +2590,7 @@ str2cyls(char *str)
*/
if (*p != 0) {
/*
- * Units specifier of 'c': convert cylinders to blocks
+ * Units specifier of 'c': accept it.
*/
if (*p == 'c') {
p++;