diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-05-04 19:30:56 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-05-04 19:30:56 +0000 |
commit | e3d438608f212120e42a6447bf89f354816ac4ff (patch) | |
tree | 0ef9e295d96f14d2180ea27daa273afdb5b093d1 | |
parent | a258f20b10975f2a073d3fbeb33358967ff5298c (diff) |
make findblkmajor() and findblkname() MI; ok miod
24 files changed, 109 insertions, 629 deletions
diff --git a/sys/arch/alpha/alpha/autoconf.c b/sys/arch/alpha/alpha/autoconf.c index 0642034ee20..ab9cd83d056 100644 --- a/sys/arch/alpha/alpha/autoconf.c +++ b/sys/arch/alpha/alpha/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.29 2007/05/04 03:44:41 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.30 2007/05/04 19:30:53 deraadt Exp $ */ /* $NetBSD: autoconf.c,v 1.16 1996/11/13 21:13:04 cgd Exp $ */ /* @@ -206,38 +206,13 @@ device_register(dev, aux) (*platform.device_register)(dev, aux); } -static struct { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "st", 2 }, { "cd", 3 }, { "fd", 4 }, { "rd", 6 }, { "sd", 8 }, { "wd", 0 }, - { "raid", 16 } + { "raid", 16 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/amd64/amd64/autoconf.c b/sys/arch/amd64/amd64/autoconf.c index 4ac99b91f70..a229aa8f20d 100644 --- a/sys/arch/amd64/amd64/autoconf.c +++ b/sys/arch/amd64/amd64/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.19 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.20 2007/05/04 19:30:54 deraadt Exp $ */ /* $NetBSD: autoconf.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */ /*- @@ -187,35 +187,10 @@ diskconf(void) dumpconf(); } -static struct { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "wd", 0 }, { "sd", 4 }, { "rd", 17 }, { "raid", 19 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/armish/armish/autoconf.c b/sys/arch/armish/armish/autoconf.c index 7cf951d39b1..be52bcb6862 100644 --- a/sys/arch/armish/armish/autoconf.c +++ b/sys/arch/armish/armish/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.5 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.6 2007/05/04 19:30:54 deraadt Exp $ */ /* $NetBSD: autoconf.c,v 1.2 2001/09/05 16:17:36 matt Exp $ */ /* @@ -140,36 +140,11 @@ cpu_configure(void) } -static struct { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "wd", 16 }, { "sd", 24 }, { "cd", 26 }, { "rd", 18 }, - { "raid", 71 } + { "raid", 71 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/aviion/aviion/autoconf.c b/sys/arch/aviion/aviion/autoconf.c index 0c2a9d20701..a68085097ca 100644 --- a/sys/arch/aviion/aviion/autoconf.c +++ b/sys/arch/aviion/aviion/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.2 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.3 2007/05/04 19:30:54 deraadt Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -183,34 +183,9 @@ device_register(struct device *dev, void *aux) } } -static struct { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "sd", 4 }, { "cd", 6 }, { "rd", 7 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/cats/cats/autoconf.c b/sys/arch/cats/cats/autoconf.c index 908ef9b6ab8..4637cc0d294 100644 --- a/sys/arch/cats/cats/autoconf.c +++ b/sys/arch/cats/cats/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.9 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.10 2007/05/04 19:30:54 deraadt Exp $ */ /* $NetBSD: autoconf.c,v 1.2 2001/09/05 16:17:36 matt Exp $ */ /* @@ -125,36 +125,11 @@ cpu_configure(void) } -static struct { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "wd", 16 }, { "sd", 24 }, { "cd", 26 }, { "rd", 18 }, { "raid", 71 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/hp300/hp300/autoconf.c b/sys/arch/hp300/hp300/autoconf.c index df4ec06cd4f..10c4a999cfe 100644 --- a/sys/arch/hp300/hp300/autoconf.c +++ b/sys/arch/hp300/hp300/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.41 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.42 2007/05/04 19:30:54 deraadt Exp $ */ /* $NetBSD: autoconf.c,v 1.45 1999/04/10 17:31:02 kleink Exp $ */ /* @@ -868,37 +868,12 @@ iounmap(va, size) #endif } -struct nam2blk { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "ct", 0 }, { "hd", 2 }, { "sd", 4 }, { "st", 7 }, { "rd", 8 }, { "cd", 9 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - register int i; - - for (i = 0; i < sizeof(nam2blk) / sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[0].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk) / sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/hppa/hppa/autoconf.c b/sys/arch/hppa/hppa/autoconf.c index 3b61ecf330c..09e7fbb5864 100644 --- a/sys/arch/hppa/hppa/autoconf.c +++ b/sys/arch/hppa/hppa/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.46 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.47 2007/05/04 19:30:55 deraadt Exp $ */ /* * Copyright (c) 1998-2003 Michael Shalayeff @@ -479,39 +479,14 @@ cpu_configure(void) cold = 0; } -static struct { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "rd", 3 }, { "sd", 4 }, { "st", 5 }, - { "cd", 6 } + { "cd", 6 }, #if 0 { "wd", ? }, { "fd", 7 }, #endif + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/hppa64/hppa64/autoconf.c b/sys/arch/hppa64/hppa64/autoconf.c index 8b13e37fa89..867c32f3876 100644 --- a/sys/arch/hppa64/hppa64/autoconf.c +++ b/sys/arch/hppa64/hppa64/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.6 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.7 2007/05/04 19:30:55 deraadt Exp $ */ /* * Copyright (c) 1998-2005 Michael Shalayeff @@ -536,10 +536,7 @@ device_register(struct device *dev, void *aux) #endif } -static struct { - char name[4]; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "rd", 3 }, { "sd", 4 }, { "st", 5 }, @@ -548,27 +545,5 @@ static struct { { "wd", ? }, { "fd", 7 }, #endif + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -const char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk) / sizeof(nam2blk[0]); ++i) - if (maj == nam2blk[i].maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/i386/i386/autoconf.c b/sys/arch/i386/i386/autoconf.c index f74e9ee9bd7..deb2402b5fd 100644 --- a/sys/arch/i386/i386/autoconf.c +++ b/sys/arch/i386/i386/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.72 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.73 2007/05/04 19:30:55 deraadt Exp $ */ /* $NetBSD: autoconf.c,v 1.20 1996/05/03 19:41:56 christos Exp $ */ /*- @@ -225,38 +225,13 @@ diskconf(void) dumpconf(); } -static struct { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "wd", 0 }, { "fd", 2 }, { "sd", 4 }, { "cd", 6 }, { "mcd", 7 }, { "rd", 17 }, - { "raid", 19 } + { "raid", 19 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/landisk/landisk/autoconf.c b/sys/arch/landisk/landisk/autoconf.c index 1cd0c493478..b0fececfa83 100644 --- a/sys/arch/landisk/landisk/autoconf.c +++ b/sys/arch/landisk/landisk/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.6 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.7 2007/05/04 19:30:55 deraadt Exp $ */ /* $NetBSD: autoconf.c,v 1.1 2006/09/01 21:26:18 uwe Exp $ */ /*- @@ -80,34 +80,9 @@ diskconf(void) dumpconf(); } -static struct { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "wd", 16 }, { "rd", 18 }, - { "sd", 24 } + { "sd", 24 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/luna88k/luna88k/autoconf.c b/sys/arch/luna88k/luna88k/autoconf.c index 895a04bf6d1..5250c359251 100644 --- a/sys/arch/luna88k/luna88k/autoconf.c +++ b/sys/arch/luna88k/luna88k/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.9 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.10 2007/05/04 19:30:55 deraadt Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -169,34 +169,9 @@ device_register(struct device *dev, void *aux) } } -static struct { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "sd", 4 }, { "st", 5 }, { "rd", 7 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/mac68k/mac68k/autoconf.c b/sys/arch/mac68k/mac68k/autoconf.c index f6a7f034382..3aa8c82a984 100644 --- a/sys/arch/mac68k/mac68k/autoconf.c +++ b/sys/arch/mac68k/mac68k/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.27 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.28 2007/05/04 19:30:55 deraadt Exp $ */ /* $NetBSD: autoconf.c,v 1.38 1996/12/18 05:46:09 scottr Exp $ */ /* @@ -179,34 +179,9 @@ target_to_unit(bus, target, lun) return -1; } -static struct { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "sd", 4 }, { "cd", 6 }, { "rd", 13 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/macppc/macppc/autoconf.c b/sys/arch/macppc/macppc/autoconf.c index c9e66479e8d..8d08350b7ad 100644 --- a/sys/arch/macppc/macppc/autoconf.c +++ b/sys/arch/macppc/macppc/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.26 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.27 2007/05/04 19:30:55 deraadt Exp $ */ /* * Copyright (c) 1996, 1997 Per Fogelstrom * Copyright (c) 1995 Theo de Raadt @@ -37,7 +37,7 @@ * from: Utah Hdr: autoconf.c 1.31 91/01/21 * * from: @(#)autoconf.c 8.1 (Berkeley) 6/10/93 - * $Id: autoconf.c,v 1.26 2007/05/04 03:44:44 deraadt Exp $ + * $Id: autoconf.c,v 1.27 2007/05/04 19:30:55 deraadt Exp $ */ /* @@ -293,35 +293,10 @@ diskconf(void) dumpconf(); } -static struct { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "wd", 0 }, { "sd", 2 }, { "ofdisk", 4 }, { "raid", 19 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/mvme68k/mvme68k/autoconf.c b/sys/arch/mvme68k/mvme68k/autoconf.c index 2f3a77fee74..a93c6bac3e8 100644 --- a/sys/arch/mvme68k/mvme68k/autoconf.c +++ b/sys/arch/mvme68k/mvme68k/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.37 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.38 2007/05/04 19:30:55 deraadt Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -314,34 +314,9 @@ device_register(struct device *dev, void *aux) } } -static struct { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "sd", 4 }, { "st", 7 }, { "rd", 9 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/mvme88k/mvme88k/autoconf.c b/sys/arch/mvme88k/mvme88k/autoconf.c index 5f41f436a6b..62c606e7aa6 100644 --- a/sys/arch/mvme88k/mvme88k/autoconf.c +++ b/sys/arch/mvme88k/mvme88k/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.36 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.37 2007/05/04 19:30:55 deraadt Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -179,34 +179,9 @@ get_target(int *target, int *bus, int *lun) } } -static struct { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "sd", 4 }, { "cd", 6 }, { "rd", 7 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/mvmeppc/mvmeppc/autoconf.c b/sys/arch/mvmeppc/mvmeppc/autoconf.c index 67d655b3c48..f894373b15c 100644 --- a/sys/arch/mvmeppc/mvmeppc/autoconf.c +++ b/sys/arch/mvmeppc/mvmeppc/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.15 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.16 2007/05/04 19:30:55 deraadt Exp $ */ /* * Copyright (c) 1996, 1997 Per Fogelstrom * Copyright (c) 1995 Theo de Raadt @@ -37,7 +37,7 @@ * from: Utah Hdr: autoconf.c 1.31 91/01/21 * * from: @(#)autoconf.c 8.1 (Berkeley) 6/10/93 - * $Id: autoconf.c,v 1.15 2007/05/04 03:44:44 deraadt Exp $ + * $Id: autoconf.c,v 1.16 2007/05/04 19:30:55 deraadt Exp $ */ /* @@ -184,35 +184,10 @@ getdevunit(name, unit) return dev; } -const struct { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "wd", 0 }, { "sd", 2 }, { "ofdisk", 4 }, { "raid", 19 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/sgi/sgi/autoconf.c b/sys/arch/sgi/sgi/autoconf.c index 91c855fac46..d77134b2a60 100644 --- a/sys/arch/sgi/sgi/autoconf.c +++ b/sys/arch/sgi/sgi/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.12 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.13 2007/05/04 19:30:55 deraadt Exp $ */ /* * Copyright (c) 1996 Per Fogelstrom * Copyright (c) 1995 Theo de Raadt @@ -268,33 +268,8 @@ boot_getnr(const char *p, int *no) return p; } -static struct { - char *name; - int maj; -} nam2blk[] = { - { "sd", 0 }, /* 0 = sd */ - { "wd", 4 }, /* 4 = wd */ +struct nam2blk nam2blk[] = { + { "sd", 0 }, + { "wd", 4 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/solbourne/solbourne/autoconf.c b/sys/arch/solbourne/solbourne/autoconf.c index aa18aba42ba..48a6a185a04 100644 --- a/sys/arch/solbourne/solbourne/autoconf.c +++ b/sys/arch/solbourne/solbourne/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.6 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.7 2007/05/04 19:30:55 deraadt Exp $ */ /* OpenBSD: autoconf.c,v 1.64 2005/03/23 17:10:24 miod Exp */ /* @@ -591,36 +591,11 @@ device_register(struct device *dev, void *aux) { } -struct nam2blk { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "sd", 7 }, { "st", 11 }, { "fd", 16 }, { "rd", 17 }, { "cd", 18 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name)) == 0) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); ++i) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/sparc/sparc/autoconf.c b/sys/arch/sparc/sparc/autoconf.c index f21afa87351..2495f0fd0d6 100644 --- a/sys/arch/sparc/sparc/autoconf.c +++ b/sys/arch/sparc/sparc/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.77 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.78 2007/05/04 19:30:55 deraadt Exp $ */ /* $NetBSD: autoconf.c,v 1.73 1997/07/29 09:41:53 fair Exp $ */ /* @@ -1830,10 +1830,7 @@ getdevunit(name, unit) return dev; } -static struct { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "xy", 3 }, { "sd", 7 }, { "xd", 10 }, @@ -1841,28 +1838,6 @@ static struct { { "fd", 16 }, { "rd", 17 }, { "cd", 18 }, - { "raid", 25 } + { "raid", 25 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/sparc64/sparc64/autoconf.c b/sys/arch/sparc64/sparc64/autoconf.c index 56b3b02322a..74c1b8a55f2 100644 --- a/sys/arch/sparc64/sparc64/autoconf.c +++ b/sys/arch/sparc64/sparc64/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.64 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.65 2007/05/04 19:30:55 deraadt Exp $ */ /* $NetBSD: autoconf.c,v 1.51 2001/07/24 19:32:11 eeh Exp $ */ /* @@ -1155,36 +1155,11 @@ nail_bootdev(dev, bp) bootpath_store(1, NULL); } -struct nam2blk { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "sd", 7 }, { "rd", 5 }, { "wd", 12 }, { "cd", 18 }, { "raid", 25 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/vax/vax/autoconf.c b/sys/arch/vax/vax/autoconf.c index 86b2915c717..def4cb270e3 100644 --- a/sys/arch/vax/vax/autoconf.c +++ b/sys/arch/vax/vax/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.25 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.26 2007/05/04 19:30:55 deraadt Exp $ */ /* $NetBSD: autoconf.c,v 1.45 1999/10/23 14:56:05 ragge Exp $ */ /* @@ -454,10 +454,7 @@ struct ngcconf { dev_t ng_root; }; -struct nam2blk { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "ra", 9 }, { "rx", 12 }, { "rl", 14 }, @@ -466,27 +463,5 @@ struct nam2blk { { "rd", 23 }, { "raid", 25 }, { "cd", 61 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/arch/zaurus/zaurus/autoconf.c b/sys/arch/zaurus/zaurus/autoconf.c index d41e95edcf8..a807f8543c6 100644 --- a/sys/arch/zaurus/zaurus/autoconf.c +++ b/sys/arch/zaurus/zaurus/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.8 2007/05/04 03:44:44 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.9 2007/05/04 19:30:55 deraadt Exp $ */ /* $NetBSD: autoconf.c,v 1.2 2001/09/05 16:17:36 matt Exp $ */ /* @@ -138,36 +138,11 @@ cpu_configure(void) } -static struct { - char *name; - int maj; -} nam2blk[] = { +struct nam2blk nam2blk[] = { { "wd", 16 }, { "sd", 24 }, { "cd", 26 }, { "rd", 18 }, - { "raid", 71 } + { "raid", 71 }, + { NULL, -1 } }; - -int -findblkmajor(struct device *dv) -{ - char *name = dv->dv_xname; - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) - return (nam2blk[i].maj); - return (-1); -} - -char * -findblkname(int maj) -{ - int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++) - if (nam2blk[i].maj == maj) - return (nam2blk[i].name); - return (NULL); -} diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index 9f0836e9ea3..3e7d7a001cd 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_disk.c,v 1.35 2007/05/04 03:44:45 deraadt Exp $ */ +/* $OpenBSD: subr_disk.c,v 1.36 2007/05/04 19:30:55 deraadt Exp $ */ /* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */ /* @@ -813,3 +813,28 @@ gotswap: dumpdev = swdevt[0].sw_dev; } } + +extern struct nam2blk nam2blk[]; + +int +findblkmajor(struct device *dv) +{ + char *name = dv->dv_xname; + int i; + + for (i = 0; nam2blk[i].name; i++) + if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name))) + return (nam2blk[i].maj); + return (-1); +} + +char * +findblkname(int maj) +{ + int i; + + for (i = 0; nam2blk[i].name; i++) + if (nam2blk[i].maj == maj) + return (nam2blk[i].name); + return (NULL); +} diff --git a/sys/sys/device.h b/sys/sys/device.h index 924f5df3f63..d59f3d2e23b 100644 --- a/sys/sys/device.h +++ b/sys/sys/device.h @@ -1,4 +1,4 @@ -/* $OpenBSD: device.h,v 1.33 2007/05/04 03:44:45 deraadt Exp $ */ +/* $OpenBSD: device.h,v 1.34 2007/05/04 19:30:55 deraadt Exp $ */ /* $NetBSD: device.h,v 1.15 1996/04/09 20:55:24 cgd Exp $ */ /* @@ -210,6 +210,11 @@ struct device *device_lookup(struct cfdriver *, int unit); void device_ref(struct device *); void device_unref(struct device *); +struct nam2blk { + char *name; + int maj; +}; + int findblkmajor(struct device *dv); char *findblkname(int); void setroot(struct device *, int, int); |