17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5342440ecSPrasad Singamsetty * Common Development and Distribution License (the "License").
6342440ecSPrasad Singamsetty * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate /*
22*65908c77Syu, larry liu - Sun Microsystems - Beijing China * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
237c478bd9Sstevel@tonic-gate * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate /*
277c478bd9Sstevel@tonic-gate * diskscan:
287c478bd9Sstevel@tonic-gate * performs a verification pass over a device specified on command line;
297c478bd9Sstevel@tonic-gate * display progress on stdout, and print bad sector numbers to stderr
307c478bd9Sstevel@tonic-gate */
317c478bd9Sstevel@tonic-gate #include <stdio.h>
327c478bd9Sstevel@tonic-gate #include <stdlib.h>
337c478bd9Sstevel@tonic-gate #include <fcntl.h>
347c478bd9Sstevel@tonic-gate #include <unistd.h>
357c478bd9Sstevel@tonic-gate #include <stropts.h>
367c478bd9Sstevel@tonic-gate #include <memory.h>
377c478bd9Sstevel@tonic-gate #include <ctype.h>
387c478bd9Sstevel@tonic-gate #include <malloc.h>
397c478bd9Sstevel@tonic-gate #include <signal.h>
407c478bd9Sstevel@tonic-gate #include <sys/types.h>
417c478bd9Sstevel@tonic-gate #include <sys/param.h>
427c478bd9Sstevel@tonic-gate #include <sys/stat.h>
437c478bd9Sstevel@tonic-gate #include <sys/vtoc.h>
447c478bd9Sstevel@tonic-gate #include <sys/dkio.h>
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gate static void verexit(); /* signal handler and exit routine */
477c478bd9Sstevel@tonic-gate static void report(); /* tell user how we're getting on */
487c478bd9Sstevel@tonic-gate static void scandisk(char *device, int devfd, int writeflag);
49342440ecSPrasad Singamsetty static void report(char *what, diskaddr_t sector);
507c478bd9Sstevel@tonic-gate static void verexit(int code);
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gate #define TRUE 1
537c478bd9Sstevel@tonic-gate #define FALSE 0
547c478bd9Sstevel@tonic-gate #define VER_WRITE 1
557c478bd9Sstevel@tonic-gate #define VER_READ 2
567c478bd9Sstevel@tonic-gate
577c478bd9Sstevel@tonic-gate static char *progname;
587c478bd9Sstevel@tonic-gate static struct dk_geom dkg; /* physical device boot info */
597c478bd9Sstevel@tonic-gate static char replybuf[64]; /* used for user replies to questions */
60342440ecSPrasad Singamsetty static diskaddr_t unix_base; /* first sector of UNIX System partition */
61342440ecSPrasad Singamsetty static diskaddr_t unix_size; /* # sectors in UNIX System partition */
627c478bd9Sstevel@tonic-gate static long numbadrd = 0; /* number of bad sectors on read */
637c478bd9Sstevel@tonic-gate static long numbadwr = 0; /* number of bad sectors on write */
647c478bd9Sstevel@tonic-gate static char eol = '\n'; /* end-of-line char (if -n, we set to '\n') */
657c478bd9Sstevel@tonic-gate static int print_warn = 1; /* should the warning message be printed? */
667c478bd9Sstevel@tonic-gate static int do_scan = VER_READ;
677c478bd9Sstevel@tonic-gate
68052b6e8aSbg159949 int
main(int argc,char * argv[])697c478bd9Sstevel@tonic-gate main(int argc, char *argv[]) {
707c478bd9Sstevel@tonic-gate extern int optind;
717c478bd9Sstevel@tonic-gate int devfd; /* device file descriptor */
727c478bd9Sstevel@tonic-gate struct stat statbuf;
737c478bd9Sstevel@tonic-gate struct part_info part_info;
74342440ecSPrasad Singamsetty struct extpart_info extpartinfo;
757c478bd9Sstevel@tonic-gate int c;
767c478bd9Sstevel@tonic-gate int errflag = 0;
777c478bd9Sstevel@tonic-gate char *device;
787c478bd9Sstevel@tonic-gate progname = argv[0];
797c478bd9Sstevel@tonic-gate
807c478bd9Sstevel@tonic-gate /* Don't buffer stdout - we don't want to see bursts */
817c478bd9Sstevel@tonic-gate
827c478bd9Sstevel@tonic-gate setbuf(stdout, NULL);
837c478bd9Sstevel@tonic-gate
847c478bd9Sstevel@tonic-gate while ((c = getopt(argc, argv, "Wny")) != -1)
857c478bd9Sstevel@tonic-gate {
867c478bd9Sstevel@tonic-gate switch (c) {
877c478bd9Sstevel@tonic-gate case 'W':
887c478bd9Sstevel@tonic-gate do_scan = VER_WRITE;
897c478bd9Sstevel@tonic-gate break;
907c478bd9Sstevel@tonic-gate
917c478bd9Sstevel@tonic-gate case 'n':
927c478bd9Sstevel@tonic-gate eol = '\r';
937c478bd9Sstevel@tonic-gate break;
947c478bd9Sstevel@tonic-gate
957c478bd9Sstevel@tonic-gate case 'y':
967c478bd9Sstevel@tonic-gate print_warn = 0;
977c478bd9Sstevel@tonic-gate break;
987c478bd9Sstevel@tonic-gate
997c478bd9Sstevel@tonic-gate default:
1007c478bd9Sstevel@tonic-gate ++errflag;
1017c478bd9Sstevel@tonic-gate break;
1027c478bd9Sstevel@tonic-gate }
1037c478bd9Sstevel@tonic-gate }
1047c478bd9Sstevel@tonic-gate
1057c478bd9Sstevel@tonic-gate if ((argc - optind) < 1)
1067c478bd9Sstevel@tonic-gate errflag++;
1077c478bd9Sstevel@tonic-gate
1087c478bd9Sstevel@tonic-gate if (errflag) {
1097c478bd9Sstevel@tonic-gate (void) fprintf(stderr,
1107c478bd9Sstevel@tonic-gate "\nUsage: %s [-W] [-n] [-y] <phys_device_name> \n",
1117c478bd9Sstevel@tonic-gate progname);
1127c478bd9Sstevel@tonic-gate exit(1);
1137c478bd9Sstevel@tonic-gate }
1147c478bd9Sstevel@tonic-gate
1157c478bd9Sstevel@tonic-gate device = argv[optind];
1167c478bd9Sstevel@tonic-gate
1177c478bd9Sstevel@tonic-gate if (stat(device, &statbuf)) {
1187c478bd9Sstevel@tonic-gate (void) fprintf(stderr,
1197c478bd9Sstevel@tonic-gate "%s: invalid device %s, stat failed\n", progname, device);
1207c478bd9Sstevel@tonic-gate perror("");
1217c478bd9Sstevel@tonic-gate exit(4);
1227c478bd9Sstevel@tonic-gate }
1237c478bd9Sstevel@tonic-gate if ((statbuf.st_mode & S_IFMT) != S_IFCHR) {
1247c478bd9Sstevel@tonic-gate (void) fprintf(stderr,
1257c478bd9Sstevel@tonic-gate "%s: device %s is not character special\n",
1267c478bd9Sstevel@tonic-gate progname, device);
1277c478bd9Sstevel@tonic-gate exit(5);
1287c478bd9Sstevel@tonic-gate }
1297c478bd9Sstevel@tonic-gate if ((devfd = open(device, O_RDWR)) == -1) {
1307c478bd9Sstevel@tonic-gate (void) fprintf(stderr,
1317c478bd9Sstevel@tonic-gate "%s: open of %s failed\n", progname, device);
1327c478bd9Sstevel@tonic-gate perror("");
1337c478bd9Sstevel@tonic-gate exit(8);
1347c478bd9Sstevel@tonic-gate }
1357c478bd9Sstevel@tonic-gate
1367c478bd9Sstevel@tonic-gate if ((ioctl(devfd, DKIOCGGEOM, &dkg)) == -1) {
1377c478bd9Sstevel@tonic-gate (void) fprintf(stderr,
1387c478bd9Sstevel@tonic-gate "%s: unable to get disk geometry.\n", progname);
1397c478bd9Sstevel@tonic-gate perror("");
1407c478bd9Sstevel@tonic-gate exit(9);
1417c478bd9Sstevel@tonic-gate }
142342440ecSPrasad Singamsetty
143342440ecSPrasad Singamsetty if ((ioctl(devfd, DKIOCEXTPARTINFO, &extpartinfo)) == 0) {
144342440ecSPrasad Singamsetty unix_base = extpartinfo.p_start;
145342440ecSPrasad Singamsetty unix_size = extpartinfo.p_length;
146342440ecSPrasad Singamsetty } else {
147342440ecSPrasad Singamsetty if ((ioctl(devfd, DKIOCPARTINFO, &part_info)) == 0) {
148342440ecSPrasad Singamsetty unix_base = (ulong_t)part_info.p_start;
149342440ecSPrasad Singamsetty unix_size = (uint_t)part_info.p_length;
150342440ecSPrasad Singamsetty } else {
151342440ecSPrasad Singamsetty (void) fprintf(stderr, "%s: unable to get partition "
152342440ecSPrasad Singamsetty "info.\n", progname);
1537c478bd9Sstevel@tonic-gate perror("");
1547c478bd9Sstevel@tonic-gate exit(9);
1557c478bd9Sstevel@tonic-gate }
156342440ecSPrasad Singamsetty }
1577c478bd9Sstevel@tonic-gate
1587c478bd9Sstevel@tonic-gate scandisk(device, devfd, do_scan);
159052b6e8aSbg159949 return (0);
1607c478bd9Sstevel@tonic-gate }
1617c478bd9Sstevel@tonic-gate
1627c478bd9Sstevel@tonic-gate /*
1637c478bd9Sstevel@tonic-gate * scandisk:
1647c478bd9Sstevel@tonic-gate * attempt to read every sector of the drive;
1657c478bd9Sstevel@tonic-gate * display bad sectors found on stderr
1667c478bd9Sstevel@tonic-gate */
1677c478bd9Sstevel@tonic-gate
1687c478bd9Sstevel@tonic-gate static void
scandisk(char * device,int devfd,int writeflag)1697c478bd9Sstevel@tonic-gate scandisk(char *device, int devfd, int writeflag)
1707c478bd9Sstevel@tonic-gate {
171*65908c77Syu, larry liu - Sun Microsystems - Beijing China int trksiz = 0;
1727c478bd9Sstevel@tonic-gate char *verbuf;
173342440ecSPrasad Singamsetty diskaddr_t cursec;
1747c478bd9Sstevel@tonic-gate int cylsiz = dkg.dkg_nsect * dkg.dkg_nhead;
1757c478bd9Sstevel@tonic-gate int i;
1767c478bd9Sstevel@tonic-gate char *rptr;
177342440ecSPrasad Singamsetty diskaddr_t tmpend = 0;
178342440ecSPrasad Singamsetty diskaddr_t tmpsec = 0;
179*65908c77Syu, larry liu - Sun Microsystems - Beijing China struct dk_minfo mediainfo;
180*65908c77Syu, larry liu - Sun Microsystems - Beijing China uint_t sector_size;
181*65908c77Syu, larry liu - Sun Microsystems - Beijing China
182*65908c77Syu, larry liu - Sun Microsystems - Beijing China if ((ioctl(devfd, DKIOCGMEDIAINFO, &mediainfo)) == 0) {
183*65908c77Syu, larry liu - Sun Microsystems - Beijing China sector_size = mediainfo.dki_lbsize;
184*65908c77Syu, larry liu - Sun Microsystems - Beijing China } else {
185*65908c77Syu, larry liu - Sun Microsystems - Beijing China sector_size = NBPSCTR;
186*65908c77Syu, larry liu - Sun Microsystems - Beijing China }
187*65908c77Syu, larry liu - Sun Microsystems - Beijing China trksiz = sector_size * dkg.dkg_nsect;
1887c478bd9Sstevel@tonic-gate
1897c478bd9Sstevel@tonic-gate /* #define LIBMALLOC */
1907c478bd9Sstevel@tonic-gate
1917c478bd9Sstevel@tonic-gate #ifdef LIBMALLOC
1927c478bd9Sstevel@tonic-gate
1937c478bd9Sstevel@tonic-gate extern int mallopt();
1947c478bd9Sstevel@tonic-gate
1957c478bd9Sstevel@tonic-gate /* This adds 5k to the binary, but it's a lot prettier */
1967c478bd9Sstevel@tonic-gate
1977c478bd9Sstevel@tonic-gate
1987c478bd9Sstevel@tonic-gate /* make track buffer sector aligned */
199*65908c77Syu, larry liu - Sun Microsystems - Beijing China if (mallopt(M_GRAIN, sector_size)) {
2007c478bd9Sstevel@tonic-gate perror("mallopt");
2017c478bd9Sstevel@tonic-gate exit(1);
2027c478bd9Sstevel@tonic-gate }
203*65908c77Syu, larry liu - Sun Microsystems - Beijing China if ((verbuf = malloc(sector_size * dkg.dkg_nsect)) ==
204*65908c77Syu, larry liu - Sun Microsystems - Beijing China (char *)NULL) {
2057c478bd9Sstevel@tonic-gate perror("malloc");
2067c478bd9Sstevel@tonic-gate exit(1);
2077c478bd9Sstevel@tonic-gate }
2087c478bd9Sstevel@tonic-gate
2097c478bd9Sstevel@tonic-gate #else
2107c478bd9Sstevel@tonic-gate
211*65908c77Syu, larry liu - Sun Microsystems - Beijing China if ((verbuf = malloc(sector_size + sector_size * dkg.dkg_nsect))
2127c478bd9Sstevel@tonic-gate == (char *)NULL) {
2137c478bd9Sstevel@tonic-gate perror("malloc");
2147c478bd9Sstevel@tonic-gate exit(1);
2157c478bd9Sstevel@tonic-gate }
216*65908c77Syu, larry liu - Sun Microsystems - Beijing China verbuf = (char *)((((unsigned long)verbuf + sector_size)) &
217*65908c77Syu, larry liu - Sun Microsystems - Beijing China (-sector_size));
2187c478bd9Sstevel@tonic-gate
2197c478bd9Sstevel@tonic-gate #endif
2207c478bd9Sstevel@tonic-gate
2217c478bd9Sstevel@tonic-gate /* write pattern in track buffer */
2227c478bd9Sstevel@tonic-gate
2237c478bd9Sstevel@tonic-gate for (i = 0; i < trksiz; i++)
2247c478bd9Sstevel@tonic-gate verbuf[i] = (char)0xe5;
2257c478bd9Sstevel@tonic-gate
2267c478bd9Sstevel@tonic-gate /* Turn off retry, and set trap to turn them on again */
2277c478bd9Sstevel@tonic-gate
2287c478bd9Sstevel@tonic-gate (void) signal(SIGINT, verexit);
2297c478bd9Sstevel@tonic-gate (void) signal(SIGQUIT, verexit);
2307c478bd9Sstevel@tonic-gate
2317c478bd9Sstevel@tonic-gate if (writeflag == VER_READ)
2327c478bd9Sstevel@tonic-gate goto do_readonly;
2337c478bd9Sstevel@tonic-gate
2347c478bd9Sstevel@tonic-gate /*
2357c478bd9Sstevel@tonic-gate * display warning only if -n arg not passed
2367c478bd9Sstevel@tonic-gate * (otherwise the UI system will take care of it)
2377c478bd9Sstevel@tonic-gate */
2387c478bd9Sstevel@tonic-gate
2397c478bd9Sstevel@tonic-gate if (print_warn == 1) {
2407c478bd9Sstevel@tonic-gate (void) printf(
2417c478bd9Sstevel@tonic-gate "\nCAUTION: ABOUT TO DO DESTRUCTIVE WRITE ON %s\n", device);
2427c478bd9Sstevel@tonic-gate (void) printf(" THIS WILL DESTROY ANY DATA YOU HAVE ON\n");
2437c478bd9Sstevel@tonic-gate (void) printf(" THAT PARTITION OR SLICE.\n");
2447c478bd9Sstevel@tonic-gate (void) printf("Do you want to continue (y/n)? ");
2457c478bd9Sstevel@tonic-gate
2467c478bd9Sstevel@tonic-gate rptr = fgets(replybuf, 64*sizeof (char), stdin);
2477c478bd9Sstevel@tonic-gate if (!rptr || !((replybuf[0] == 'Y') || (replybuf[0] == 'y')))
2487c478bd9Sstevel@tonic-gate exit(10);
2497c478bd9Sstevel@tonic-gate }
2507c478bd9Sstevel@tonic-gate
2517c478bd9Sstevel@tonic-gate for (cursec = 0; cursec < unix_size; cursec += dkg.dkg_nsect) {
252*65908c77Syu, larry liu - Sun Microsystems - Beijing China if (llseek(devfd, cursec * sector_size, 0) == -1) {
2537c478bd9Sstevel@tonic-gate (void) fprintf(stderr,
254342440ecSPrasad Singamsetty "Error seeking sector %llu Cylinder %llu\n",
2557c478bd9Sstevel@tonic-gate cursec, cursec / cylsiz);
2567c478bd9Sstevel@tonic-gate verexit(1);
2577c478bd9Sstevel@tonic-gate }
2587c478bd9Sstevel@tonic-gate
2597c478bd9Sstevel@tonic-gate /*
2607c478bd9Sstevel@tonic-gate * verify sector at a time only when
2617c478bd9Sstevel@tonic-gate * the whole track write fails;
2627c478bd9Sstevel@tonic-gate * (if we write a sector at a time, it takes forever)
2637c478bd9Sstevel@tonic-gate */
2647c478bd9Sstevel@tonic-gate
2657c478bd9Sstevel@tonic-gate report("Writing", cursec);
2667c478bd9Sstevel@tonic-gate
2677c478bd9Sstevel@tonic-gate if (write(devfd, verbuf, trksiz) != trksiz) {
2687c478bd9Sstevel@tonic-gate tmpend = cursec + dkg.dkg_nsect;
2697c478bd9Sstevel@tonic-gate for (tmpsec = cursec; tmpsec < tmpend; tmpsec++) {
2707c478bd9Sstevel@tonic-gate /*
2717c478bd9Sstevel@tonic-gate * try writing to it once; if this fails,
2727c478bd9Sstevel@tonic-gate * then announce the sector bad on stderr
2737c478bd9Sstevel@tonic-gate */
2747c478bd9Sstevel@tonic-gate
275*65908c77Syu, larry liu - Sun Microsystems - Beijing China if (llseek(devfd, tmpsec * sector_size,
276*65908c77Syu, larry liu - Sun Microsystems - Beijing China 0) == -1) {
2777c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "Error seeking "
278342440ecSPrasad Singamsetty "sector %llu Cylinder %llu\n",
2797c478bd9Sstevel@tonic-gate tmpsec, cursec / cylsiz);
2807c478bd9Sstevel@tonic-gate verexit(1);
2817c478bd9Sstevel@tonic-gate }
2827c478bd9Sstevel@tonic-gate
2837c478bd9Sstevel@tonic-gate report("Writing", tmpsec);
2847c478bd9Sstevel@tonic-gate
285*65908c77Syu, larry liu - Sun Microsystems - Beijing China if (write(devfd, verbuf, sector_size)
286*65908c77Syu, larry liu - Sun Microsystems - Beijing China != sector_size) {
2877c478bd9Sstevel@tonic-gate (void) fprintf(stderr,
288342440ecSPrasad Singamsetty "%llu\n", tmpsec + unix_base);
2897c478bd9Sstevel@tonic-gate numbadwr++;
2907c478bd9Sstevel@tonic-gate }
2917c478bd9Sstevel@tonic-gate }
2927c478bd9Sstevel@tonic-gate }
2937c478bd9Sstevel@tonic-gate }
2947c478bd9Sstevel@tonic-gate
2957c478bd9Sstevel@tonic-gate (void) putchar(eol);
2967c478bd9Sstevel@tonic-gate do_readonly:
2977c478bd9Sstevel@tonic-gate
2987c478bd9Sstevel@tonic-gate for (cursec = 0; cursec < unix_size; cursec += dkg.dkg_nsect) {
299*65908c77Syu, larry liu - Sun Microsystems - Beijing China if (llseek(devfd, cursec * sector_size, 0) == -1) {
3007c478bd9Sstevel@tonic-gate (void) fprintf(stderr,
301342440ecSPrasad Singamsetty "Error seeking sector %llu Cylinder %llu\n",
3027c478bd9Sstevel@tonic-gate cursec, cursec / cylsiz);
3037c478bd9Sstevel@tonic-gate verexit(1);
3047c478bd9Sstevel@tonic-gate }
3057c478bd9Sstevel@tonic-gate
3067c478bd9Sstevel@tonic-gate /*
3077c478bd9Sstevel@tonic-gate * read a sector at a time only when
3087c478bd9Sstevel@tonic-gate * the whole track write fails;
3097c478bd9Sstevel@tonic-gate * (if we do a sector at a time read, it takes forever)
3107c478bd9Sstevel@tonic-gate */
3117c478bd9Sstevel@tonic-gate
3127c478bd9Sstevel@tonic-gate report("Reading", cursec);
3137c478bd9Sstevel@tonic-gate if (read(devfd, verbuf, trksiz) != trksiz) {
3147c478bd9Sstevel@tonic-gate tmpend = cursec + dkg.dkg_nsect;
3157c478bd9Sstevel@tonic-gate for (tmpsec = cursec; tmpsec < tmpend; tmpsec++) {
316*65908c77Syu, larry liu - Sun Microsystems - Beijing China if (llseek(devfd, tmpsec * sector_size,
317*65908c77Syu, larry liu - Sun Microsystems - Beijing China 0) == -1) {
3187c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "Error seeking"
319342440ecSPrasad Singamsetty " sector %llu Cylinder %llu\n",
3207c478bd9Sstevel@tonic-gate tmpsec, cursec / cylsiz);
3217c478bd9Sstevel@tonic-gate verexit(1);
3227c478bd9Sstevel@tonic-gate }
3237c478bd9Sstevel@tonic-gate report("Reading", tmpsec);
324*65908c77Syu, larry liu - Sun Microsystems - Beijing China if (read(devfd, verbuf, sector_size) !=
325*65908c77Syu, larry liu - Sun Microsystems - Beijing China sector_size) {
326342440ecSPrasad Singamsetty (void) fprintf(stderr, "%llu\n",
3277c478bd9Sstevel@tonic-gate tmpsec + unix_base);
3287c478bd9Sstevel@tonic-gate numbadrd++;
3297c478bd9Sstevel@tonic-gate }
3307c478bd9Sstevel@tonic-gate }
3317c478bd9Sstevel@tonic-gate }
3327c478bd9Sstevel@tonic-gate }
3337c478bd9Sstevel@tonic-gate (void) printf("%c%c======== Diskscan complete ========%c", eol,
3347c478bd9Sstevel@tonic-gate eol, eol);
3357c478bd9Sstevel@tonic-gate
3367c478bd9Sstevel@tonic-gate if ((numbadrd > 0) || (numbadwr > 0)) {
3377c478bd9Sstevel@tonic-gate (void) printf("%cFound %ld bad sector(s) on read,"
3387c478bd9Sstevel@tonic-gate " %ld bad sector(s) on write%c",
3397c478bd9Sstevel@tonic-gate eol, numbadrd, numbadwr, eol);
3407c478bd9Sstevel@tonic-gate }
3417c478bd9Sstevel@tonic-gate }
3427c478bd9Sstevel@tonic-gate
3437c478bd9Sstevel@tonic-gate static void
verexit(int code)3447c478bd9Sstevel@tonic-gate verexit(int code)
3457c478bd9Sstevel@tonic-gate {
3467c478bd9Sstevel@tonic-gate (void) printf("\n");
3477c478bd9Sstevel@tonic-gate exit(code);
3487c478bd9Sstevel@tonic-gate }
3497c478bd9Sstevel@tonic-gate
3507c478bd9Sstevel@tonic-gate
3517c478bd9Sstevel@tonic-gate /*
3527c478bd9Sstevel@tonic-gate * report where we are...
3537c478bd9Sstevel@tonic-gate */
3547c478bd9Sstevel@tonic-gate
3557c478bd9Sstevel@tonic-gate static void
report(char * what,diskaddr_t sector)356342440ecSPrasad Singamsetty report(char *what, diskaddr_t sector)
3577c478bd9Sstevel@tonic-gate {
358342440ecSPrasad Singamsetty (void) printf("%s sector %-19llu of %-19llu%c", what, sector,
3597c478bd9Sstevel@tonic-gate unix_size, eol);
3607c478bd9Sstevel@tonic-gate }
361