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