| 1 | /* dkbad.c 4.3 81/05/10 */ |
| 2 | |
| 3 | #ifndef NOBADSECT |
| 4 | #include "../h/param.h" |
| 5 | #include "../h/buf.h" |
| 6 | #include "../h/dkbad.h" |
| 7 | |
| 8 | /* |
| 9 | * Search the bad sector table looking for |
| 10 | * the specified sector. Return index if found. |
| 11 | * Return -1 if not found. |
| 12 | */ |
| 13 | |
| 14 | isbad(bt, cyl, trk, sec) |
| 15 | register struct dkbad *bt; |
| 16 | { |
| 17 | register int i; |
| 18 | register long blk, bblk; |
| 19 | |
| 20 | blk = ((long)cyl << 16) + (trk << 8) + sec; |
| 21 | for (i = 0; i < 126; i++) { |
| 22 | bblk = ((long)bt->bt_bad[i].bt_cyl << 16) + bt->bt_bad[i].bt_trksec; |
| 23 | if (blk == bblk) |
| 24 | return (i); |
| 25 | if (blk < bblk || bblk < 0) |
| 26 | break; |
| 27 | } |
| 28 | return (-1); |
| 29 | } |
| 30 | #endif |