diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-10-04 20:04:32 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-10-04 20:04:32 +0000 |
commit | d7d05bc1ee5c6a5ec0e18869dfd4726c35fd722f (patch) | |
tree | 5d1efa25c0d58331f4ae9d34ca275c6612349f61 /sys | |
parent | 2269932dd4c3a3c5ae5e59158c7d17a19fce7f5f (diff) |
save user configuration in some magic buffer, which config -e can read; maja
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/subr_userconf.c | 95 |
1 files changed, 87 insertions, 8 deletions
diff --git a/sys/kern/subr_userconf.c b/sys/kern/subr_userconf.c index 26b7f3dae1a..acfe9fba81d 100644 --- a/sys/kern/subr_userconf.c +++ b/sys/kern/subr_userconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_userconf.c,v 1.17 1999/08/17 11:02:40 art Exp $ */ +/* $OpenBSD: subr_userconf.c,v 1.18 1999/10/04 20:04:31 deraadt Exp $ */ /* * Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se> @@ -52,12 +52,20 @@ int userconf_totdev = -1; /* # of device slots */ int userconf_maxlocnames = -1; /* # of locnames */ int userconf_cnt = -1; /* Line counter for ... */ int userconf_lines = 12; /* ... # of lines per page */ +int userconf_histlen = 0; +int userconf_histcur = 0; +char userconf_history[1024]; +int userconf_histsz = sizeof(userconf_history); char userconf_argbuf[40]; /* Additional input */ char userconf_cmdbuf[40]; /* Command line */ +char userconf_histbuf[40]; void userconf_init __P((void)); int userconf_more __P((void)); void userconf_modify __P((char *, int*)); +void userconf_hist_cmd __P((char)); +void userconf_hist_int __P((int)); +void userconf_hist_eoc __P((void)); void userconf_pnum __P((int)); void userconf_pdevnam __P((short)); void userconf_pdev __P((short)); @@ -152,6 +160,40 @@ userconf_more() } void +userconf_hist_cmd(cmd) + char cmd; +{ + userconf_histcur = userconf_histlen; + if (userconf_histcur < userconf_histsz) { + userconf_history[userconf_histcur] = cmd; + userconf_histcur++; + } +} + +void +userconf_hist_int(val) + int val; +{ + sprintf(userconf_histbuf," %d",val); + if ((userconf_histcur + strlen(userconf_histbuf)) < userconf_histsz) { + bcopy(userconf_histbuf, + &userconf_history[userconf_histcur], + strlen(userconf_histbuf)); + userconf_histcur = userconf_histcur + strlen(userconf_histbuf); + } +} + +void +userconf_hist_eoc() +{ + if (userconf_histcur < userconf_histsz) { + userconf_history[userconf_histcur] = '\n'; + userconf_histcur++; + userconf_histlen = userconf_histcur; + } +} + +void userconf_pnum(val) int val; { @@ -419,7 +461,11 @@ userconf_change(devno) if (c == 'y' || c == 'Y') { int share = 0, i, *lk; - + + /* XXX add cmd 'c' <devno> */ + userconf_hist_cmd('c'); + userconf_hist_int(devno); + cd = &cfdata[devno]; l = cd->cf_loc; ln = cd->cf_locnames; @@ -443,6 +489,10 @@ userconf_change(devno) while (locnamp[ln] != -1) { userconf_modify(locnames[locnamp[ln]], l); + + /* XXX add *l */ + userconf_hist_int(*l); + ln++; l++; } @@ -458,6 +508,10 @@ userconf_change(devno) userconf_pdevnam(devno); printf(" changed\n"); userconf_pdev(devno); + + /* XXX add eoc */ + userconf_hist_eoc(); + } } else { printf("Unknown devno (max is %d)\n", userconf_maxdev); @@ -489,8 +543,14 @@ userconf_disable(devno) printf("%3d ", devno); userconf_pdevnam(devno); - if (done) + if (done) { printf(" already"); + } else { + /* XXX add cmd 'd' <devno> eoc */ + userconf_hist_cmd('d'); + userconf_hist_int(devno); + userconf_hist_eoc(); + } printf(" disabled\n"); } else { printf("Unknown devno (max is %d)\n", userconf_maxdev); @@ -522,8 +582,14 @@ userconf_enable(devno) printf("%3d ", devno); userconf_pdevnam(devno); - if (done) + if (done) { printf(" already"); + } else { + /* XXX add cmd 'e' <devno> eoc */ + userconf_hist_cmd('d'); + userconf_hist_int(devno); + userconf_hist_eoc(); + } printf(" enabled\n"); } else { printf("Unknown devno (max is %d)\n", userconf_maxdev); @@ -848,7 +914,8 @@ userconf_add_read(prompt, field, dev, len, val) printf("Unknown devno (max is %d)\n", userconf_maxdev); } else if (strncasecmp(dev, - cfdata[a].cf_driver->cd_name, len) != 0) { + cfdata[a].cf_driver->cd_name, len) != 0 && + field == 'a') { printf("Not same device type\n"); } else { *val = a; @@ -876,7 +943,7 @@ userconf_add(dev, len, unit, state) { int i = 0, found = 0; struct cfdata new; - int val, max_unit; + int val, max_unit, orig; bzero(&new, sizeof(struct cfdata)); @@ -886,7 +953,7 @@ userconf_add(dev, len, unit, state) } if (state == FSTATE_FOUND) { - printf("Device not complete number or * is missing/n"); + printf("Device not complete number or * is missing\n"); return; } @@ -904,6 +971,7 @@ userconf_add(dev, len, unit, state) 'a', dev, len, &val); if (val != -1) { + orig = val; new = cfdata[val]; new.cf_unit = unit; new.cf_fstate = state; @@ -912,7 +980,15 @@ userconf_add(dev, len, unit, state) } if (val != -1) { - + + /* XXX add cmd 'a' <orig> <val> eoc */ + userconf_hist_cmd('a'); + userconf_hist_int(orig); + userconf_hist_int(unit); + userconf_hist_int(state); + userconf_hist_int(val); + userconf_hist_eoc(); + /* Insert the new record */ for (i = userconf_maxdev; val <= i; i--) cfdata[i+1] = cfdata[i]; @@ -1097,6 +1173,9 @@ userconf_parse(cmd) printf("Unknown argument\n"); break; case 'q': + /* XXX add cmd 'q' eoc */ + userconf_hist_cmd('q'); + userconf_hist_eoc(); return(-1); break; case 's': |