Index: usr.sbin/pccard/pccardd/file.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/pccard/pccardd/file.c,v retrieving revision 1.24 diff -u -r1.24 file.c --- file.c 2000/01/26 17:54:00 1.24 +++ file.c 2000/03/28 12:33:36 @@ -37,7 +37,12 @@ static FILE *in; static int includes = 0; -static FILE *files[MAXINCLUDES] = {NULL, }; +static struct { + FILE *filep; + char *filename; + int lineno; +} configfiles[MAXINCLUDES] = {{NULL, NULL, 0}, }; + static int pushc, pusht; static int lineno; static char *filename; @@ -114,12 +119,15 @@ die("readfile"); } for (i = 0; i < MAXINCLUDES; i++) { - if (files[i]) { - fclose(files[i]); - files[i] = NULL; + if (configfiles[i].filep) { + fclose(configfiles[i].filep); + configfiles[i].filep = NULL; } } - files[includes = 0] = in; + includes = 0; + configfiles[includes].filep = in; + filename = configfiles[includes].filename = name; + parsefile(); for (cp = cards; cp; cp = cp->next) { if (cp->config == 0) @@ -132,50 +140,55 @@ parsefile(void) { int i; - int irq_init = 0; - int io_init = 0; - struct allocblk *bp; + int errors = 0; + struct allocblk *bp, *next; char *incl; pushc = 0; lineno = 1; - for (i = 0; i < 16 ; i++) - if (pool_irq[i]) { - irq_init = 1; - break; - } for (;;) switch (keyword(next_tok())) { case KWD_EOF: /* EOF */ return; case KWD_IO: - /* reserved I/O blocks */ + /* override reserved I/O blocks */ + bzero(io_avail, sizeof(io_avail)); + for (bp = pool_ioblks; bp; bp = next) { + next = bp->next; + free(bp); + } + pool_ioblks = NULL; + while ((bp = ioblk_tok(0)) != 0) { - if (!io_init) { - if (bp->size == 0 || bp->addr == 0) { - free(bp); - continue; - } - bit_nset(io_avail, bp->addr, - bp->addr + bp->size - 1); - bp->next = pool_ioblks; - pool_ioblks = bp; + if (bp->size == 0 || bp->addr == 0) { + free(bp); + continue; } + bit_nset(io_avail, bp->addr, + bp->addr + bp->size - 1); + bp->next = pool_ioblks; + pool_ioblks = bp; } - io_init = 1; pusht = 1; break; case KWD_IRQ: - /* reserved irqs */ + /* override reserved irqs */ + bzero(pool_irq, sizeof(pool_irq)); + while ((i = irq_tok(0)) > 0) - if (!irq_init) - pool_irq[i] = 1; - irq_init = 1; + pool_irq[i] = 1; pusht = 1; break; case KWD_MEMORY: - /* reserved memory blocks. */ + /* override reserved memory blocks. */ + bzero(mem_avail, sizeof(mem_avail)); + for (bp = pool_mem; bp; bp = next) { + next = bp->next; + free(bp); + } + pool_mem = NULL; + while ((bp = memblk_tok(0)) != 0) { if (bp->size == 0 || bp->addr == 0) { free(bp); @@ -204,6 +217,10 @@ default: error("syntax error"); pusht = 0; + if (errors++ >= 10) { + error("too many errors, giving up"); + return; + } break; } } @@ -367,6 +384,11 @@ struct allocblk *io; int i, j; + /* ignore the keyword to allow separete blocks in multiple lines */ + if (keyword(next_tok()) != KWD_IO) { + pusht = 1; + } + if ((i = num_tok()) >= 0) { if (strcmp("-", next_tok()) || (j = num_tok()) < 0 || j < i) { error("I/O block format error"); @@ -399,6 +421,11 @@ struct allocblk *mem; int i, j; + /* ignore the keyword to allow separete blocks in multiple lines */ + if (keyword(next_tok()) != KWD_MEMORY) { + pusht = 1; + } + if ((i = num_tok()) >= 0) { if ((j = num_tok()) < 0) error("illegal memory block"); @@ -431,6 +458,11 @@ { int i; + /* ignore the keyword to allow separete blocks in multiple lines */ + if (keyword(next_tok()) != KWD_IRQ) { + pusht = 1; + } + if (strcmp("?", next_tok()) == 0 && force) return (0); pusht = 1; @@ -731,8 +763,11 @@ case EOF: if (includes) { fclose(in); + /* go back to previous config file */ includes--; - in = files[includes]; + in = configfiles[includes].filep; + filename = configfiles[includes].filename; + lineno = configfiles[includes].lineno; return _next_tok(); /* recursive */ } if (p != buf) { @@ -773,17 +808,53 @@ * Include configuration file */ static void -file_include(char *filename) +file_include(char *incl) { - FILE *fp; + int i, included; + FILE *fp; - includes++; + /* check nesting overflow */ if (includes >= MAXINCLUDES) { - error("include nesting overflow"); + if (debug_level >= 1) { + logmsg("%s: include nesting overflow " + "at line %d, near %s\n", filename, lineno, incl); + } + free(incl); + goto out; } - if (!(fp = fopen(filename, "r"))) { - error("can't open include file"); - includes--; + + /* check recursive inclusion */ + for (i = 0, included = 0; i <= includes; i++) { + if (strcmp(incl, configfiles[i].filename) == 0) { + included = 1; + break; + } } - in = files[includes] = fp; + if (included == 1) { + if (debug_level >= 1) { + logmsg("%s: can't include the same file twice " + "at line %d, near %s\n", filename, lineno, incl); + } + free(incl); + goto out; + } + + if (!(fp = fopen(incl, "r"))) { + if (debug_level >= 1) { + logmsg("%s: can't open include file " + "at line %d, near %s\n", filename, lineno, incl); + } + free(incl); + goto out; + } + + /* save line number of the current config file */ + configfiles[includes].lineno = lineno; + + /* now we start parsing new config file */ + includes++; + in = configfiles[includes].filep = fp; + filename = configfiles[includes].filename = incl; +out: + return; } Index: usr.sbin/pccard/pccardd/pccard.conf.5 =================================================================== RCS file: /home/ncvs/src/usr.sbin/pccard/pccardd/pccard.conf.5,v retrieving revision 1.12 diff -u -r1.12 pccard.conf.5 --- pccard.conf.5 2000/03/01 14:09:20 1.12 +++ pccard.conf.5 2000/03/28 04:51:02 @@ -54,6 +54,17 @@ The latter two may appear in any order, and may be interspersed as desired. .Pp +The +.Pa /etc/pccard.conf +file is included from the file +.Pa /etc/defaults/pccard.conf , +which contains the default resource pool settings and +pccard identifiers database. +The user specific configuration can be specified in +.Pa /etc/rc.conf +when the user wishes to override these defaults and/or +add additional entries. +.Pp Each PC-CARD card contains configuration tuples that provide the manufacturer and card version; these are used to identify the card specification in the configuration @@ -213,11 +224,14 @@ .Ed .Sh FILES -.Bl -tag -width /etc/pccard.conf -compact -.It Pa /etc/pccard.conf +.Bl -tag -width /etc/defaults/pccard.conf -compact +.It Pa /etc/defaults/pccard.conf The .Xr pccardd 8 -configuration file. +default configuration file. +.It Pa /etc/pccard.conf +The +user configuration file. .El .Sh SEE ALSO .Xr pccardd 8 Index: usr.sbin/pccard/pccardd/pccardd.8 =================================================================== RCS file: /home/ncvs/src/usr.sbin/pccard/pccardd/pccardd.8,v retrieving revision 1.17 diff -u -r1.17 pccardd.8 --- pccardd.8 2000/03/01 14:09:19 1.17 +++ pccardd.8 2000/03/28 04:08:21 @@ -46,7 +46,10 @@ When started, .Nm will read the configuration file (default name -.Pa /etc/pccard.conf ) +.Pa /etc/defaults/pccard.conf +which includes +.Pa /etc/pccard.conf +as the user configuration file) and scans the available PC-CARD slots for cards. .Nm Pccardd then waits for @@ -130,11 +133,13 @@ Delays running as a daemon until after the cards have been probed and attached. .It Fl i Ar IRQ Configures an available IRQ. It overrides the "irq" line in +.Pa /etc/defaults/pccard.conf +and .Pa /etc/pccard.conf . .It Fl f Ar configfile Specifies a different configuration file to be used in placed of the default file -.Pa /etc/pccard.conf . +.Pa /etc/defaults/pccard.conf . The file format is detailed in .Xr pccard.conf 5 , and lists the PC-CARD cards recognized by @@ -143,7 +148,8 @@ interface to the card. .Pp .Sh FILES -.Bl -tag -width /etc/pccard.conf -compact +.Bl -tag -width /etc/defaults/pccard.conf -compact +.It Pa /etc/defaults/pccard.conf .It Pa /etc/pccard.conf .El .Sh SEE ALSO Index: usr.sbin/pccard/pccardd/pccardd.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/pccard/pccardd/pccardd.c,v retrieving revision 1.6 diff -u -r1.6 pccardd.c --- pccardd.c 1999/08/28 01:17:37 1.6 +++ pccardd.c 2000/03/27 06:23:56 @@ -37,7 +37,7 @@ #define EXTERN #include "cardd.h" -char *config_file = "/etc/pccard.conf"; +char *config_file = "/etc/defaults/pccard.conf"; /* * mainline code for cardd Index: etc/Makefile =================================================================== RCS file: /home/ncvs/src/etc/Makefile,v retrieving revision 1.219 diff -u -r1.219 Makefile --- etc/Makefile 2000/03/13 04:59:43 1.219 +++ etc/Makefile 2000/03/28 04:58:04 @@ -58,6 +58,7 @@ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 755 ${BIN2} ${DESTDIR}/etc; \ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 defaults/rc.conf ${DESTDIR}/etc/defaults/; \ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 defaults/make.conf ${DESTDIR}/etc/defaults/; \ + ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 defaults/pccard.conf ${DESTDIR}/etc/defaults/; \ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \ ${DESTDIR}/var/log/cron; \ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 600 \ @@ -165,6 +166,8 @@ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 defaults/rc.conf \ ${DESTDIR}/usr/share/examples/etc/defaults; \ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 defaults/make.conf \ + ${DESTDIR}/usr/share/examples/etc/defaults) + ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 defaults/pccard.conf \ ${DESTDIR}/usr/share/examples/etc/defaults) .include Index: etc/defaults/rc.conf =================================================================== RCS file: /home/ncvs/src/etc/defaults/rc.conf,v retrieving revision 1.55 diff -u -r1.55 rc.conf --- etc/defaults/rc.conf 2000/03/27 21:38:33 1.55 +++ etc/defaults/rc.conf 2000/03/28 05:00:07 @@ -29,7 +29,7 @@ pccard_beep="1" # pccard beep type. pccard_ifconfig="NO" # Specialized pccard ethernet configuration (or NO). pccardd_flags="" # Additional flags for pccardd. -pccard_conf="/etc/pccard.conf.sample" # pccardd(8) config file +pccard_conf="/etc/defaults/pccard.conf" # pccardd(8) config file local_startup="/usr/local/etc/rc.d /usr/X11R6/etc/rc.d" # startup script dirs. local_periodic="/usr/local/etc/periodic /usr/X11R6/etc/periodic" # periodic script dirs rc_conf_files="/etc/rc.conf /etc/rc.conf.local" Index: share/examples/etc/README.examples =================================================================== RCS file: /home/ncvs/src/share/examples/etc/README.examples,v retrieving revision 1.5 diff -u -r1.5 README.examples --- share/examples/etc/README.examples 1999/08/28 00:19:16 1.5 +++ share/examples/etc/README.examples 2000/03/28 05:38:00 @@ -37,7 +37,6 @@ networks - see networks(5) newsyslog.conf - configuration for system log file rotator newsyslog(8) pam.conf - configuration file for pam(8) -pccard.conf - configuration file for pccardd(8) pccard_ether - confiuration script for ethernet pccards (see pccardd(8)) phones - phone number database for tip(1) printcap - configuration file for lpr(1) @@ -65,3 +64,4 @@ syslog.conf - configuration file for syslogd(8) ttys - defines port configuration for init(8) defaults/rc.conf - default system configuration info (see rc.conf(5)) +defaults/pccard.conf - default configuration file for pccardd(8)