xref: /titanic_44/usr/src/cmd/addbadsec/badsec.h (revision cfcc56e0075241b5a13f04c502e961ef843de0d3)
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
5*cfcc56e0SMark Logan  * Common Development and Distribution License (the "License").
6*cfcc56e0SMark Logan  * 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 /*	Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.	*/
227c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T	*/
237c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
247c478bd9Sstevel@tonic-gate 
25*cfcc56e0SMark Logan /*
26*cfcc56e0SMark Logan  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
27*cfcc56e0SMark Logan  * Use is subject to license terms.
28*cfcc56e0SMark Logan  */
29*cfcc56e0SMark Logan 
30*cfcc56e0SMark Logan #ifndef _BADSEC_H
31*cfcc56e0SMark Logan #define	_BADSEC_H
32*cfcc56e0SMark Logan 
33*cfcc56e0SMark Logan #ifdef	__cplusplus
34*cfcc56e0SMark Logan extern "C" {
35*cfcc56e0SMark Logan #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #define	BADSECFILE	"/etc/scsi/badsec"
387c478bd9Sstevel@tonic-gate #define	FAILURE	0
397c478bd9Sstevel@tonic-gate #define	SUCCESS	1
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #define	MAXBLENT	4
427c478bd9Sstevel@tonic-gate struct	badsec_lst {
437c478bd9Sstevel@tonic-gate 	int		bl_cnt;
447c478bd9Sstevel@tonic-gate 	struct	badsec_lst *bl_nxt;
45*cfcc56e0SMark Logan 	blkaddr_t	bl_sec[MAXBLENT];
467c478bd9Sstevel@tonic-gate };
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #define	BADSLSZ		sizeof (struct badsec_lst)
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate #define	ALTS_ADDPART	0x1	/* add alternate partition		*/
517c478bd9Sstevel@tonic-gate struct	alts_mempart {			/* incore alts partition info	*/
527c478bd9Sstevel@tonic-gate 	int	ap_flag;		/* flag for alternate partition	*/
537c478bd9Sstevel@tonic-gate 	struct	alts_parttbl *ap_tblp;	/* alts partition table		*/
547c478bd9Sstevel@tonic-gate 	int	ap_tbl_secsiz;		/* alts parttbl sector size	*/
55*cfcc56e0SMark Logan 	uchar_t	*ap_memmapp;		/* incore alternate sector map	*/
56*cfcc56e0SMark Logan 	uchar_t	*ap_mapp;		/* alternate sector map		*/
577c478bd9Sstevel@tonic-gate 	int	ap_map_secsiz;		/* alts partmap sector size	*/
587c478bd9Sstevel@tonic-gate 	int	ap_map_sectot;		/* alts partmap # sector 	*/
597c478bd9Sstevel@tonic-gate 	struct  alts_ent *ap_entp;	/* alternate sector entry table */
607c478bd9Sstevel@tonic-gate 	int	ap_ent_secsiz;		/* alts entry sector size	*/
617c478bd9Sstevel@tonic-gate 	struct	alts_ent *ap_gbadp;	/* growing badsec entry table	*/
627c478bd9Sstevel@tonic-gate 	int	ap_gbadcnt;		/* growing bad sector count	*/
63*cfcc56e0SMark Logan 	struct	extpartition part;	/* alts partition configuration */
647c478bd9Sstevel@tonic-gate };
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate /*	size of incore alternate partition memory structure		*/
677c478bd9Sstevel@tonic-gate #define	ALTS_MEMPART_SIZE	sizeof (struct alts_mempart)
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate struct	altsectbl {			/* working alts info		*/
707c478bd9Sstevel@tonic-gate 	struct  alts_ent *ast_entp;	/* alternate sector entry table */
717c478bd9Sstevel@tonic-gate 	int	ast_entused;		/* entry used			*/
727c478bd9Sstevel@tonic-gate 	struct	alt_info *ast_alttblp;	/* alts info			*/
737c478bd9Sstevel@tonic-gate 	int	ast_altsiz;		/* size of alts info		*/
747c478bd9Sstevel@tonic-gate 	struct  alts_ent *ast_gbadp;	/* growing bad sector entry ptr */
757c478bd9Sstevel@tonic-gate 	int	ast_gbadcnt;		/* growing bad sector entry cnt */
767c478bd9Sstevel@tonic-gate };
777c478bd9Sstevel@tonic-gate /*	size of incore alternate partition memory structure		*/
787c478bd9Sstevel@tonic-gate #define	ALTSECTBL_SIZE	sizeof (struct altsectbl)
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate /*	macro definitions						*/
817c478bd9Sstevel@tonic-gate #define	byte_to_secsiz(APSIZE, BPS)	(daddr_t) \
82*cfcc56e0SMark Logan 	((((APSIZE) + (BPS) - 1)/(uint_t)(BPS)) * (BPS))
83*cfcc56e0SMark Logan 
84*cfcc56e0SMark Logan #ifdef	__cplusplus
85*cfcc56e0SMark Logan }
86*cfcc56e0SMark Logan #endif
87*cfcc56e0SMark Logan 
88*cfcc56e0SMark Logan #endif	/* _BADSEC_H */
89