/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* 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
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/*
* Copyrighted as an unpublished work.
* (c) Copyright INTERACTIVE Systems Corporation 1986, 1988, 1990
* All rights reserved.
*/
#include <stdio.h>
#include <fcntl.h>
#include <memory.h>
#include <errno.h>
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
#include <stropts.h>
#include "badsec.h"
char *progname;
extern struct badsec_lst *badsl_chain;
extern int badsl_chain_cnt;
extern struct badsec_lst *gbadsl_chain;
extern int gbadsl_chain_cnt;
extern int print_altsec(struct extpartition *);
extern int updatebadsec(struct extpartition *, int);
extern void wr_altsctr(void);
int alts_fd;
static void giveusage(void);
static void add_gbad(int badsec_entry);
static int try_hw_remap(void);
static int hardware_remap(blkaddr_t);
int
{
extern int optind;
extern char *optarg;
char *nxtarg;
char *alts_name;
int l;
int p;
int init_flag = 0;
int print_flag = 0;
int c;
int i;
switch (c) {
case 'I':
init_flag = 1;
break;
case 'p':
print_flag = 1;
break;
case 'a':
for (; *nxtarg != '\0'; )
break;
case 'f':
"%s: unable to open %s file\n",
exit(1);
}
break;
default:
giveusage();
exit(2);
}
}
/* get the last argument -- device stanza */
giveusage();
exit(3);
}
giveusage();
exit(4);
}
giveusage();
exit(5);
}
/*
* NEED A DEFINE FOR THE PHYSICAL BIT (0x10)
*/
if ((minor_val & 0x10) == 0) {
giveusage();
exit(6);
}
giveusage();
exit(7);
}
perror("");
exit(8);
}
progname);
perror("");
exit(9);
}
giveusage();
exit(14);
}
giveusage();
exit(15);
}
if (badsecfd)
#ifdef ADDBAD_DEBUG
{
}
printf("\n");
}
#endif
#ifdef PPP
/*
* If init_flag is set, run to completion.
*/
if (gbadsl_chain_cnt == 0 && init_flag == 0)
/*
* No defects and not initializing
*/
exit(0);
#endif
if (gbadsl_chain_cnt != 0)
{
if (try_hw_remap() == SUCCESS)
exit(0);
}
/*
* get ALTS slice
*/
{
{
alts_slice = i;
}
}
if (alts_slice == -1)
{
exit(16);
}
perror("");
exit(9);
}
if (print_flag)
{
(void) print_altsec(part);
exit(0);
}
wr_altsctr();
" failed. System must be re-booted\n");
exit(17);
}
sync();
return (0);
}
/*
* Giveusage ()
* Give a (not so) concise message on how to use this program.
*/
static void
giveusage(void)
{
" raw-device\n", progname);
" bad block list\n");
" to the bad block list\n");
if (devfd)
}
/*
* read in the additional growing bad sectors
*/
static void
{
int badsec_entry;
int status;
}
}
static void
{
if (!gbadsl_chain) {
if (!blc_p) {
" for additional bad sectors\n");
exit(18);
}
}
" for additional bad sectors\n");
exit(19);
}
}
}
/*
* Map a block using hardware (SCSI) techniques.
*/
/*ARGSUSED*/
static int
{
/*
* Build and execute the uscsi ioctl
*/
(void) memset((char *)&defect_list, 0,
sizeof (struct scsi_reassign_blk));
/*
* Set function flags for driver.
*/
/*
* Execute the ioctl
*/
{
{
perror("SCSI hardware re-assign failed");
/*
* It looks like a failure but by returning success
* the upper layer will not try to do
* software remapping.
*/
return (SUCCESS);
}
return (FAILURE);
}
return (SUCCESS);
}
{
return (rc);
}
{
return (rc);
}
static int
{
int i;
return (FAILURE);
}
return (SUCCESS);
}