From 982210ebf32f9c040aca497ce86c958098caf8a8 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Wed, 1 Nov 1995 17:20:37 +0000 Subject: Add the function isbad(), needed by xd/xy drivers --- sys/arch/sun3/sun3/disksubr.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'sys/arch') diff --git a/sys/arch/sun3/sun3/disksubr.c b/sys/arch/sun3/sun3/disksubr.c index 8167194c3f9..779d1569831 100644 --- a/sys/arch/sun3/sun3/disksubr.c +++ b/sys/arch/sun3/sun3/disksubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: disksubr.c,v 1.9 1995/05/30 15:38:14 gwr Exp $ */ +/* $NetBSD: disksubr.c,v 1.9.2.1 1995/10/30 23:36:34 gwr Exp $ */ /* * Copyright (c) 1994, 1995 Gordon W. Ross @@ -46,10 +46,10 @@ #include #include #include -#include - #include +#include #include +#include #include @@ -424,3 +424,27 @@ disklabel_bsd_to_sun(lp, cp) return(0); } + +/* + * Search the bad sector table looking for the specified sector. + * Return index if found. + * Return -1 if not found. + */ +int +isbad(bt, cyl, trk, sec) + register struct dkbad *bt; +{ + register int i; + register long blk, bblk; + + blk = ((long)cyl << 16) + (trk << 8) + sec; + for (i = 0; i < 126; i++) { + bblk = ((long)bt->bt_bad[i].bt_cyl << 16) + + bt->bt_bad[i].bt_trksec; + if (blk == bblk) + return (i); + if (blk < bblk || bblk < 0) + break; + } + return (-1); +} -- cgit v1.2.3