kern_conf.c (12675) | kern_conf.c (12813) |
---|---|
1/*- 2 * Parts Copyright (c) 1995 Terrence R. Lambert 3 * Copyright (c) 1995 Julian R. Elischer 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 16 unchanged lines hidden (view full) --- 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * | 1/*- 2 * Parts Copyright (c) 1995 Terrence R. Lambert 3 * Copyright (c) 1995 Julian R. Elischer 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 16 unchanged lines hidden (view full) --- 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * |
33 * $Id: kern_conf.c,v 1.5 1995/11/30 05:59:09 julian Exp $ | 33 * $Id: kern_conf.c,v 1.6 1995/12/08 11:16:55 julian Exp $ |
34 */ 35 36#include <sys/param.h> 37#include <sys/types.h> 38#include <sys/systm.h> 39#include <sys/conf.h> 40 41/* 42 * (re)place an entry in the bdevsw or cdevsw table 43 * return the slot used in major(*descrip) 44 */ 45#define ADDENTRY(TTYPE,NXXXDEV) \ 46int TTYPE##_add(dev_t *descrip, \ 47 struct TTYPE *newentry, \ | 34 */ 35 36#include <sys/param.h> 37#include <sys/types.h> 38#include <sys/systm.h> 39#include <sys/conf.h> 40 41/* 42 * (re)place an entry in the bdevsw or cdevsw table 43 * return the slot used in major(*descrip) 44 */ 45#define ADDENTRY(TTYPE,NXXXDEV) \ 46int TTYPE##_add(dev_t *descrip, \ 47 struct TTYPE *newentry, \ |
48 struct TTYPE *oldentry) \ | 48 struct TTYPE **oldentry) \ |
49{ \ 50 int i ; \ 51 if ( (int)*descrip == -1) { /* auto (0 is valid) */ \ 52 /* \ 53 * Search the table looking for a slot... \ 54 */ \ 55 for (i = 0; i < NXXXDEV; i++) \ | 49{ \ 50 int i ; \ 51 if ( (int)*descrip == -1) { /* auto (0 is valid) */ \ 52 /* \ 53 * Search the table looking for a slot... \ 54 */ \ 55 for (i = 0; i < NXXXDEV; i++) \ |
56 if (TTYPE[i].d_open == NULL) \ | 56 if (TTYPE[i] == NULL) \ |
57 break; /* found one! */ \ 58 /* out of allocable slots? */ \ 59 if (i == NXXXDEV) { \ 60 return ENFILE; \ 61 } \ 62 } else { /* assign */ \ 63 i = major(*descrip); \ 64 if (i < 0 || i >= NXXXDEV) { \ 65 return EINVAL; \ 66 } \ 67 } \ 68 \ 69 /* maybe save old */ \ 70 if (oldentry) { \ | 57 break; /* found one! */ \ 58 /* out of allocable slots? */ \ 59 if (i == NXXXDEV) { \ 60 return ENFILE; \ 61 } \ 62 } else { /* assign */ \ 63 i = major(*descrip); \ 64 if (i < 0 || i >= NXXXDEV) { \ 65 return EINVAL; \ 66 } \ 67 } \ 68 \ 69 /* maybe save old */ \ 70 if (oldentry) { \ |
71 bcopy(&TTYPE[i], oldentry, sizeof(struct TTYPE)); \ | 71 *oldentry = TTYPE[i]; \ |
72 } \ 73 newentry->d_maj = i; \ 74 /* replace with new */ \ | 72 } \ 73 newentry->d_maj = i; \ 74 /* replace with new */ \ |
75 bcopy(newentry, &TTYPE[i], sizeof(struct TTYPE)); \ | 75 TTYPE[i] = newentry; \ |
76 \ | 76 \ |
77 /* done! */ \ | 77 /* done! let them know where we put it */ \ |
78 *descrip = makedev(i,0); \ 79 return 0; \ 80} \ 81 82ADDENTRY(bdevsw, nblkdev) 83ADDENTRY(cdevsw, nchrdev) | 78 *descrip = makedev(i,0); \ 79 return 0; \ 80} \ 81 82ADDENTRY(bdevsw, nblkdev) 83ADDENTRY(cdevsw, nchrdev) |