Date: Tue, 28 Mar 2000 02:12:20 +0900 From: Mitsuru IWASAKI <iwasaki@jp.FreeBSD.org> To: freebsd-mobile@freebsd.org Cc: freebsd-hackers@freebsd.org Subject: Call for review: new pccard.conf scheme Message-ID: <200003271712.CAA08158@tasogare.imasy.or.jp>
next in thread | raw e-mail | index | archive | help
Hi,
I'm working on new pccard.conf scheme, /etc/defaults/pccard.conf and
/etc/pccard.conf in the same manner as rc.conf.
Attached patch for pccardd(8) contains:
1. improved `include' keyword function for error handling.
2. changed available io, irq, mem pool so that they can be overridden.
3. default config file as /etc/defaults/pccard.conf instead of
/etc/pccard.conf.
Currently, /etc/pccard.conf.sample is provied as sample configuration
file for pccard, most of users modify this file based on his/her
laptop environment. However, on every upgrading, they have to merge
new sample config into own config file.
The pccard configuration can be separated into two parts; Default
pccard configuration database for general purpose, and user specific
configuration (further, available resource infomation and additional
pccard entries). By separating the file into two
(/etc/defaults/pccard.conf as default, /etc/pccard.conf as user
config), upgrading pccard.conf would be much easier.
Yes, just update /etc/defaults/pccard.conf!
To test this stuff, apply the patch and compile & install
src/usr.sbin/pccard/pccardd, and;
# cp src/etc/pccard.conf.sample /etc/defaults/pccard.conf
# echo include /etc/pccard.conf >> /etc/defaults/pccard.conf
to make sample config to default config file.
Then, create your own pccard config, you can change config entries
here from default;
# vi /etc/pccard.conf # change or add or delete contents
or you can also do
# rm /etc/pccard.conf
Comments?
Index: 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/27 07:29:01
@@ -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,54 @@
parsefile(void)
{
int i;
- int irq_init = 0;
- int io_init = 0;
- struct allocblk *bp;
+ 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);
@@ -732,7 +744,9 @@
if (includes) {
fclose(in);
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 +787,29 @@
* Include configuration file
*/
static void
-file_include(char *filename)
+file_include(char *incl)
{
FILE *fp;
- includes++;
if (includes >= MAXINCLUDES) {
error("include nesting overflow");
+ pusht = 0;
+ goto out;
}
- if (!(fp = fopen(filename, "r"))) {
+ if (strcmp(incl, filename) == 0) {
+ error("can't include from the same file");
+ pusht = 0;
+ goto out;
+ }
+ if (!(fp = fopen(incl, "r"))) {
error("can't open include file");
- includes--;
+ pusht = 0;
+ goto out;
}
- in = files[includes] = fp;
+ configfiles[includes].lineno = lineno;
+ includes++;
+ in = configfiles[includes].filep = fp;
+ filename = configfiles[includes].filename = incl;
+out:
+ return;
}
Index: 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
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-mobile" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200003271712.CAA08158>
