xref: /original-bsd/sys/hp300/hp300/dkbad.c (revision e64bc6e4)
1 /*
2  * Copyright (c) 1982, 1986, 1990, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)dkbad.c	8.2 (Berkeley) 01/12/94
8  */
9 
10 #ifndef NOBADSECT
11 #include <sys/param.h>
12 #include <sys/buf.h>
13 #include <sys/dkbad.h>
14 
15 /*
16  * Search the bad sector table looking for
17  * the specified sector.  Return index if found.
18  * Return -1 if not found.
19  */
20 
isbad(bt,cyl,trk,sec)21 isbad(bt, cyl, trk, sec)
22 	register struct dkbad *bt;
23 	int cyl, trk, sec;
24 {
25 	register int i;
26 	register long blk, bblk;
27 
28 	blk = ((long)cyl << 16) + (trk << 8) + sec;
29 	for (i = 0; i < 126; i++) {
30 		bblk = ((long)bt->bt_bad[i].bt_cyl << 16) + bt->bt_bad[i].bt_trksec;
31 		if (blk == bblk)
32 			return (i);
33 		if (blk < bblk || bblk < 0)
34 			break;
35 	}
36 	return (-1);
37 }
38 #endif
39