addbadsec.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2003 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <fcntl.h>
#include <memory.h>
#include <errno.h>
#include "badsec.h"
char *devname; /* name of device */
int devfd; /* device file descriptor */
char *progname;
extern struct badsec_lst *badsl_chain;
extern int badsl_chain_cnt;
extern struct badsec_lst *gbadsl_chain;
extern int gbadsl_chain_cnt;
int alts_fd;
void
int argc;
char *argv[];
{
extern int optind;
extern char *optarg;
static char options[] = "Ipa:f:";
char numbuf[100];
char *nxtarg;
char *alts_name;
int alts_slice = -1;
int l;
int p;
int init_flag = 0;
int print_flag = 0;
int c;
int i;
struct badsec_lst *blc_p;
switch (c) {
case 'I':
init_flag = 1;
break;
case 'p':
print_flag = 1;
break;
case 'a':
for (;*nxtarg != '\0';)
break;
case 'f':
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);
}
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)
{
print_altsec (part);
exit (0);
}
wr_altsctr();
exit(17);
}
sync();
exit(0);
}
/*
* Giveusage ()
* Give a (not so) concise message on how to use this program.
*/
{
if (devfd)
}
/*
* read in the additional growing bad sectors
*/
{
int badsec_entry;
int status;
}
}
int badsec_entry;
{
struct badsec_lst *blc_p;
if (!gbadsl_chain) {
if (!blc_p) {
exit(18);
}
}
exit(19);
}
}
}
/*
* Map a block using hardware (SCSI) techniques.
*/
/*ARGSUSED*/
int
int bn;
{
struct scsi_reassign_blk defect_list;
/*
* Build and execute the uscsi ioctl
*/
(void) memset((char *)&defect_list, 0,
sizeof (struct scsi_reassign_blk));
/*
printf ("length - %x %x\n", sizeof (defect_list.defect), defect_list.length);
printf ("defect - %x %x\n", bn, defect_list.defect);
*/
/*
* 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);
}
try_hw_remap ()
{
struct badsec_lst *blc_p;
int i;
{
return (FAILURE);
}
return (SUCCESS);
}