Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/i386/i386 Split out the check for a valid disk devi...
details: https://anonhg.NetBSD.org/src/rev/58d7cedc5277
branches: trunk
changeset: 515262:58d7cedc5277
user: ad <ad%NetBSD.org@localhost>
date: Thu Sep 20 22:46:04 2001 +0000
description:
Split out the check for a valid disk device into a function.
diffstat:
sys/arch/i386/i386/autoconf.c | 33 +++++++++++++++++++--------------
1 files changed, 19 insertions(+), 14 deletions(-)
diffs (72 lines):
diff -r 953d28867a66 -r 58d7cedc5277 sys/arch/i386/i386/autoconf.c
--- a/sys/arch/i386/i386/autoconf.c Thu Sep 20 22:17:25 2001 +0000
+++ b/sys/arch/i386/i386/autoconf.c Thu Sep 20 22:46:04 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.57 2001/09/19 20:25:48 petrov Exp $ */
+/* $NetBSD: autoconf.c,v 1.58 2001/09/20 22:46:04 ad Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -71,6 +71,7 @@
static int match_harddisk __P((struct device *, struct btinfo_bootdisk *));
static void matchbiosdisks __P((void));
static void findroot __P((void));
+static int is_valid_disk __P((struct device *));
extern struct disklist *i386_alldisks;
extern int i386_ndisks;
@@ -159,11 +160,7 @@
* First, count all native disks
*/
for (dv = alldevs.tqh_first; dv != NULL; dv = dv->dv_list.tqe_next)
- if (dv->dv_class == DV_DISK &&
- (!strcmp(dv->dv_cfdata->cf_driver->cd_name, "sd") ||
- !strcmp(dv->dv_cfdata->cf_driver->cd_name, "wd") ||
- !strcmp(dv->dv_cfdata->cf_driver->cd_name, "ld") ||
- !strcmp(dv->dv_cfdata->cf_driver->cd_name, "ed")))
+ if (is_valid_disk(dv))
i386_ndisks++;
if (i386_ndisks == 0)
@@ -201,10 +198,7 @@
printf("matchbiosdisks: trying to match (%s) %s\n",
dv->dv_xname, dv->dv_cfdata->cf_driver->cd_name);
#endif
- if (!strcmp(dv->dv_cfdata->cf_driver->cd_name, "sd") ||
- !strcmp(dv->dv_cfdata->cf_driver->cd_name, "wd") ||
- !strcmp(dv->dv_cfdata->cf_driver->cd_name, "ld") ||
- !strcmp(dv->dv_cfdata->cf_driver->cd_name, "ed")) {
+ if (is_valid_disk(dv)) {
n++;
sprintf(i386_alldisks->dl_nativedisks[n].ni_devname,
"%s%d", dv->dv_cfdata->cf_driver->cd_name,
@@ -402,10 +396,7 @@
goto found;
}
- if (!strcmp(dv->dv_cfdata->cf_driver->cd_name, "sd") ||
- !strcmp(dv->dv_cfdata->cf_driver->cd_name, "wd") ||
- !strcmp(dv->dv_cfdata->cf_driver->cd_name, "ld") ||
- !strcmp(dv->dv_cfdata->cf_driver->cd_name, "ed")) {
+ if (is_valid_disk(dv)) {
/*
* Don't trust BIOS device numbers, try
* to match the information passed by the
@@ -536,3 +527,17 @@
}
booted_device = dev;
}
+
+static int
+is_valid_disk(struct device *dv)
+{
+ const char *name;
+
+ if (dv->dv_class != DV_DISK)
+ return (0);
+
+ name = dv->dv_cfdata->cf_driver->cd_name;
+
+ return (strcmp(name, "sd") == 0 || strcmp(name, "wd") == 0 ||
+ strcmp(name, "ld") == 0 || strcmp(name, "ed") == 0);
+}
Home |
Main Index |
Thread Index |
Old Index