summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-04-24 18:59:19 +0000
committerpeter <peter@FreeBSD.org>1999-04-24 18:59:19 +0000
commit6994e5b80181dda0367cc24342a59efbbfd24a10 (patch)
treefb0aa7dbe0a0bfc6150eaeb6ca9b74bbd2cb7c3e /usr.sbin
parent3843abdc03deacf817f6459a1690b2911648a571 (diff)
downloadFreeBSD-src-6994e5b80181dda0367cc24342a59efbbfd24a10.zip
FreeBSD-src-6994e5b80181dda0367cc24342a59efbbfd24a10.tar.gz
More cleanups, tweaks and features.
- make this work: options FOO123=456 *without quotes* - grumble (but accept) vector xxxintr, and tty/net/bio/cam flags. - complain if a device is specified twice (eg: 2 x psm0) - don't require quotes around: port IO_COM2 - recognize negative numbers. (ie: options CAM_DEBUG_UNIT=-1) - GC some more unused stuff (we don't have composite disks from config(8)). - various other nits (snprintf paranoia etc)
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/config/config.h14
-rw-r--r--usr.sbin/config/config.y241
-rw-r--r--usr.sbin/config/lang.l14
-rw-r--r--usr.sbin/config/main.c4
-rw-r--r--usr.sbin/config/mkioconf.c8
-rw-r--r--usr.sbin/config/mkmakefile.c8
-rw-r--r--usr.sbin/config/mkoptions.c4
-rw-r--r--usr.sbin/config/mkswapconf.c12
8 files changed, 86 insertions, 219 deletions
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h
index 8d462e4..d7f009b 100644
--- a/usr.sbin/config/config.h
+++ b/usr.sbin/config/config.h
@@ -90,9 +90,8 @@ struct file_list {
#define SYSTEMSPEC 5
#define SWAPSPEC 6
#define COMPDEVICE 7
-#define COMPSPEC 8
-#define NODEPEND 9
-#define LOCAL 10
+#define NODEPEND 8
+#define LOCAL 9
#define DEVDONE 0x80000000
#define TYPEMASK 0x7fffffff
@@ -104,18 +103,10 @@ struct file_list {
#define NO_OBJ 4
#define BEFORE_DEPEND 8
-struct idlst {
- char *id;
- struct idlst *id_next;
-};
-
struct device {
int d_type; /* CONTROLLER, DEVICE, bus adaptor */
struct device *d_conn; /* what it is connected to */
char *d_name; /* name of device (e.g. rk11) */
- struct idlst *d_vec; /* interrupt vectors */
- int d_pri; /* interrupt priority */
- int d_addr; /* address of csr */
int d_unit; /* unit number */
int d_drive; /* drive number */
int d_target; /* target number */
@@ -129,7 +120,6 @@ struct device {
int d_disabled; /* nonzero to skip probe/attach */
char *d_port; /* io port base manifest constant */
int d_portn; /* io port base (if number not manifest) */
- char *d_mask; /* interrupt mask */
int d_maddr; /* io memory base */
int d_msize; /* io memory size */
int d_drq; /* DMA request */
diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y
index 03fdb91..4db2c80 100644
--- a/usr.sbin/config/config.y
+++ b/usr.sbin/config/config.y
@@ -2,7 +2,6 @@
char *str;
int val;
struct file_list *file;
- struct idlst *lst;
}
%token AND
@@ -17,7 +16,6 @@
%token CONFLICTS
%token CONTROLLER
%token CPU
-%token CSR
%token DEVICE
%token DISABLE
%token DISK
@@ -27,7 +25,6 @@
%token EQUALS
%token FLAGS
%token IDENT
-%token INTERLEAVE
%token IOMEM
%token IOSIZ
%token IRQ
@@ -62,18 +59,14 @@
%token <val> FPNUMBER
%type <str> Save_id
-%type <str> Opt_value
+%type <str> Opt_name
+%type <str> Opt_string
%type <str> Dev
-%type <lst> Id_list
-%type <val> optional_size
-%type <val> optional_sflag
%type <str> device_name
%type <val> major_minor
-%type <val> arg_device_spec
%type <val> root_device_spec root_device_specs
%type <val> dump_device_spec
%type <file> swap_device_spec
-%type <file> comp_device_spec
%{
@@ -140,7 +133,6 @@ int seen_scbus;
static int alreadychecked __P((dev_t, dev_t[], dev_t *));
static void deverror __P((char *, char *));
static int finddev __P((dev_t));
-static void verifycomp __P((struct file_list *));
static struct device *connect __P((char *, int));
static struct device *huhcon __P((char *));
static dev_t *verifyswap __P((struct file_list *, dev_t *, dev_t *));
@@ -173,7 +165,7 @@ Spec:
;
Config_spec:
- MACHINE Save_id
+ MACHINE Opt_string
= {
if (!strcmp($2, "i386")) {
machine = MACHINE_I386;
@@ -187,7 +179,7 @@ Config_spec:
} else
yyerror("Unknown machine type");
} |
- CPU Save_id
+ CPU Opt_string
= {
struct cputype *cp =
(struct cputype *)malloc(sizeof (struct cputype));
@@ -326,7 +318,6 @@ arg_spec:
arg_device_spec:
device_name
- = { $$ = nametodev($1, 0, COMPATIBILITY_SLICE, 'b'); }
| major_minor
;
@@ -342,16 +333,14 @@ optional_on:
optional_size:
SIZE NUMBER
- = { $$ = $2; }
+ = { yyerror("`size nnn' swap spec obsolete"); }
| /* empty */
- = { $$ = 0; }
;
optional_sflag:
SEQUENTIAL
- = { $$ = 2; }
+ = { yyerror("`sequential' swap spec obsolete"); }
| /* empty */
- = { $$ = 0; }
;
device_name:
@@ -361,28 +350,29 @@ device_name:
= {
char buf[80];
- (void) snprintf(buf, 80, "%s%d", $1, $2);
+ (void) snprintf(buf, sizeof(buf), "%s%d", $1, $2);
$$ = ns(buf); free($1);
}
| Save_id NUMBER ID
= {
char buf[80];
- (void) snprintf(buf, 80, "%s%d%s", $1, $2, $3);
+ (void) snprintf(buf, sizeof(buf), "%s%d%s", $1, $2, $3);
$$ = ns(buf); free($1);
}
| Save_id NUMBER ID NUMBER
= {
char buf[80];
- (void) snprintf(buf, 80, "%s%d%s%d", $1, $2, $3, $4);
+ (void) snprintf(buf, sizeof(buf), "%s%d%s%d",
+ $1, $2, $3, $4);
$$ = ns(buf); free($1);
}
| Save_id NUMBER ID NUMBER ID
= {
char buf[80];
- (void) snprintf(buf, 80, "%s%d%s%d%s",
+ (void) snprintf(buf, sizeof(buf), "%s%d%s%d%s",
$1, $2, $3, $4, $5);
$$ = ns(buf); free($1);
}
@@ -395,7 +385,7 @@ Opt_list:
;
Option:
- Save_id
+ Opt_string
= {
struct opt *op = (struct opt *)malloc(sizeof (struct opt));
char *s;
@@ -410,12 +400,12 @@ Option:
op->op_line = yyline;
opt = op;
if ((s = strchr(op->op_name, '='))) {
- /* AARGH!!!! Old-style bogon */
+ warnx("line %d: The `=' in options should not be quoted", yyline);
*s = '\0';
op->op_value = ns(s + 1);
}
} |
- Save_id EQUALS Opt_value
+ Opt_string EQUALS Opt_string
= {
struct opt *op = (struct opt *)malloc(sizeof (struct opt));
memset(op, 0, sizeof(*op));
@@ -426,16 +416,26 @@ Option:
opt = op;
} ;
-Opt_value:
+Opt_name:
ID
- = { $$ = $1; } |
+ = { $$ = $1; } |
NUMBER
- = {
- char nb[16];
- (void) sprintf(nb, "%d", $1);
- $$ = ns(nb);
- } ;
+ = {
+ char buf[80];
+ (void) snprintf(buf, sizeof(buf), "%d", $1);
+ $$ = ns(buf);
+ } ;
+Opt_string:
+ Opt_name
+ = { $$ = $1; } |
+ Opt_name Opt_string
+ = {
+ char buf[80];
+
+ (void) snprintf(buf, sizeof(buf), "%s%s", $1, $2);
+ $$ = ns(buf); free($1); free($2);
+ } ;
Save_id:
ID
@@ -449,7 +449,7 @@ Mkopt_list:
;
Mkoption:
- Save_id EQUALS Opt_value
+ Opt_string EQUALS Opt_string
= {
struct opt *op = (struct opt *)malloc(sizeof (struct opt));
memset(op, 0, sizeof(*op));
@@ -485,64 +485,7 @@ Device_spec:
cur.d_name = $3;
cur.d_type = PSEUDO_DEVICE;
cur.d_slave = $4;
- } |
- PSEUDO_DEVICE Dev_name Cdev_init Cdev_info
- = {
- if (!eq(cur.d_name, "cd"))
- yyerror("improper spec for pseudo-device");
- cur.d_type = DEVICE;
- verifycomp(*compp);
- };
-
-Cdev_init:
- /* lambda */
- = { mkcomp(&cur); };
-
-Cdev_info:
- optional_on comp_device_list comp_option_list
- ;
-
-comp_device_list:
- comp_device_list AND comp_device
- | comp_device
- ;
-
-comp_device:
- comp_device_spec
- = { addcomp(*compp, $1); }
- ;
-
-comp_device_spec:
- device_name
- = {
- struct file_list *fl = newflist(COMPSPEC);
-
- fl->f_compdev = nametodev($1, 0, COMPATIBILITY_SLICE,
- 'c');
- fl->f_fn = devtoname(fl->f_compdev);
- $$ = fl;
- }
- | major_minor
- = {
- struct file_list *fl = newflist(COMPSPEC);
-
- fl->f_compdev = $1;
- fl->f_fn = devtoname($1);
- $$ = fl;
- }
- ;
-
-comp_option_list:
- comp_option_list comp_option
- |
- /* lambda */
- ;
-
-comp_option:
- INTERLEAVE NUMBER
- = { cur.d_pri = $2; } |
- FLAGS NUMBER
- = { cur.d_flags = $2; };
+ } ;
Dev_name:
Init_dev Dev NUMBER
@@ -567,7 +510,7 @@ Con_info:
AT Dev NUMBER
= {
if (eq(cur.d_name, "mba") || eq(cur.d_name, "uba")) {
- (void) sprintf(errbuf,
+ (void) snprintf(errbuf, sizeof(errbuf),
"%s must be connected to a nexus", cur.d_name);
yyerror(errbuf);
}
@@ -583,8 +526,6 @@ Info_list:
;
Info:
- CSR NUMBER
- = { cur.d_addr = $2; } |
BUS NUMBER
= {
if (cur.d_conn != 0 && cur.d_conn->d_type == CONTROLLER)
@@ -620,13 +561,13 @@ Info:
PORT NUMBER
= { cur.d_portn = $2; } |
TTY
- = { cur.d_mask = "tty"; } |
+ = { yyerror("`tty' interrupt label obsolete"); } |
BIO
- = { cur.d_mask = "bio"; } |
+ = { yyerror("`bio' interrupt label obsolete"); } |
CAM
- = { cur.d_mask = "cam"; } |
+ = { yyerror("`cam' interrupt label obsolete"); } |
NET
- = { cur.d_mask = "net"; } |
+ = { yyerror("`net' interrupt label obsolete"); } |
FLAGS NUMBER
= { cur.d_flags = $2; } |
DISABLE
@@ -635,27 +576,13 @@ Info:
= { cur.d_conflicts = 1; };
Int_spec:
- VECTOR Id_list
- = { cur.d_vec = $2; } |
+ VECTOR ID
+ = { yyerror("`vector xxxintr' interrupt vector obsolete"); } |
PRIORITY NUMBER
- = { cur.d_pri = $2; } |
+ = { yyerror("`priority nnn' interrupt priority obsolete"); } |
/* lambda */
;
-Id_list:
- Save_id
- = {
- struct idlst *a = (struct idlst *)malloc(sizeof(struct idlst));
- memset(a, 0, sizeof(*a));
- a->id = $1; a->id_next = 0; $$ = a;
- } |
- Save_id Id_list =
- {
- struct idlst *a = (struct idlst *)malloc(sizeof(struct idlst));
- memset(a, 0, sizeof(*a));
- a->id = $1; a->id_next = $2; $$ = a;
- };
-
%%
static void
@@ -673,8 +600,17 @@ static void
newdev(dp)
register struct device *dp;
{
- register struct device *np;
-
+ register struct device *np, *xp;
+
+ if (dp->d_unit >= 0) {
+ for (xp = dtab; xp != 0; xp = xp->d_next) {
+ if ((xp->d_unit == dp->d_unit) &&
+ eq(xp->d_name, dp->d_name)) {
+ warnx("line %d: already seen device %s%d",
+ yyline, xp->d_name, xp->d_unit);
+ }
+ }
+ }
np = (struct device *) malloc(sizeof *np);
memset(np, 0, sizeof(*np));
*np = *dp;
@@ -766,47 +702,6 @@ mkswap(system, fl, size, flag)
system->f_fn = ns(system->f_needs);
}
-static void
-mkcomp(dp)
- register struct device *dp;
-{
- register struct file_list *fl, **flp;
- char buf[80];
-
- fl = (struct file_list *) malloc(sizeof *fl);
- memset(fl, 0, sizeof(*fl));
- fl->f_type = COMPDEVICE;
- fl->f_compinfo = dp->d_unit;
- fl->f_fn = ns(dp->d_name);
- (void) sprintf(buf, "%s%d", dp->d_name, dp->d_unit);
- fl->f_needs = ns(buf);
- fl->f_next = 0;
- for (flp = compp; *flp; flp = &(*flp)->f_next)
- ;
- *flp = fl;
- compp = flp;
-}
-
-static void
-addcomp(compdev, fl)
- struct file_list *compdev, *fl;
-{
- register struct file_list **flp;
-
- if (compdev == 0 || compdev->f_type != COMPDEVICE) {
- yyerror("component spec precedes device specification");
- return;
- }
- /*
- * Append description to the end of the list.
- */
- flp = &compdev->f_next;
- for (; *flp && (*flp)->f_type == COMPSPEC; flp = &(*flp)->f_next)
- ;
- fl->f_next = *flp;
- *flp = fl;
-}
-
/*
* find the pointer to connect to the given device and number.
* returns 0 if no such device and prints an error message
@@ -824,14 +719,14 @@ connect(dev, num)
if ((num != dp->d_unit) || !eq(dev, dp->d_name))
continue;
if (dp->d_type != CONTROLLER && dp->d_type != MASTER) {
- (void) sprintf(errbuf,
+ (void) snprintf(errbuf, sizeof(errbuf),
"%s connected to non-controller", dev);
yyerror(errbuf);
return (0);
}
return (dp);
}
- (void) sprintf(errbuf, "%s %d not defined", dev, num);
+ (void) snprintf(errbuf, sizeof(errbuf), "%s %d not defined", dev, num);
yyerror(errbuf);
return (0);
}
@@ -854,7 +749,8 @@ huhcon(dev)
if (eq(dp->d_name, dev))
break;
if (dp == 0) {
- (void) sprintf(errbuf, "no %s's to wildcard", dev);
+ (void) snprintf(errbuf, sizeof(errbuf), "no %s's to wildcard",
+ dev);
yyerror(errbuf);
return (0);
}
@@ -906,9 +802,7 @@ init_dev(dp)
dp->d_conn = 0;
dp->d_conflicts = 0;
dp->d_disabled = 0;
- dp->d_vec = 0;
- dp->d_addr = dp->d_flags = dp->d_dk = 0;
- dp->d_pri = -1;
+ dp->d_flags = dp->d_dk = 0;
dp->d_slave = dp->d_lun = dp->d_target = dp->d_drive = dp->d_unit = UNKNOWN;
dp->d_port = (char *)0;
dp->d_portn = -1;
@@ -916,7 +810,6 @@ init_dev(dp)
dp->d_drq = -1;
dp->d_maddr = 0;
dp->d_msize = 0;
- dp->d_mask = "null";
}
/*
@@ -974,7 +867,7 @@ checksystemspec(fl)
swap = newflist(SWAPSPEC);
dev = fl->f_rootdev;
if (dkpart(dev) != 0) {
- (void) sprintf(buf,
+ (void) snprintf(buf, sizeof(buf),
"Warning, swap defaulted to 'b' partition with root on '%c' partition",
dkpart(dev) + 'a');
yyerror(buf);
@@ -1003,7 +896,7 @@ checksystemspec(fl)
for (; p && p->f_type == SWAPSPEC; p = p->f_next)
if (fl->f_dumpdev == p->f_swapdev)
return;
- (void) sprintf(buf,
+ (void) snprintf(buf, sizeof(buf),
"Warning: dump device is not a swap partition");
yyerror(buf);
}
@@ -1058,22 +951,6 @@ verifyswap(fl, checked, pchecked)
}
/*
- * Verify that components of a compound device have themselves been config'ed
- */
-static void
-verifycomp(fl)
- register struct file_list *fl;
-{
- char *dname = fl->f_needs;
-
- for (fl = fl->f_next; fl; fl = fl->f_next) {
- if (fl->f_type != COMPSPEC || finddev(fl->f_compdev))
- continue;
- warnx("%s: component device %s not configured", dname, fl->f_needs);
- }
-}
-
-/*
* Has a device already been checked
* for its existence in the configuration?
*/
diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l
index c680446..30cf805 100644
--- a/usr.sbin/config/lang.l
+++ b/usr.sbin/config/lang.l
@@ -55,13 +55,12 @@ struct kt {
{ "args", ARGS },
{ "at", AT },
{ "bio", BIO }, /* XXX going away */
- { "bus", BUS }, /* XXX going away */
+ { "bus", BUS },
{ "cam", CAM }, /* XXX going away */
{ "conflicts", CONFLICTS },
{ "config", CONFIG },
{ "controller", CONTROLLER },
{ "cpu", CPU },
- { "csr", CSR },
{ "device", DEVICE },
{ "disable", DISABLE },
{ "disk", DISK },
@@ -70,7 +69,6 @@ struct kt {
{ "dumps", DUMPS },
{ "flags", FLAGS },
{ "ident", IDENT },
- { "interleave", INTERLEAVE },
{ "iomem", IOMEM },
{ "iosiz", IOSIZ },
{ "irq", IRQ },
@@ -107,7 +105,7 @@ int octal __P((char *));
int hex __P((char *));
%}
-WORD [A-Za-z_][-A-Za-z_]*
+WORD [-A-Za-z_][-A-Za-z_]*
%%
{WORD} {
int i;
@@ -142,6 +140,11 @@ WORD [A-Za-z_][-A-Za-z_]*
tprintf("#X:%x ", yylval.val);
return NUMBER;
}
+-[1-9][0-9]* {
+ yylval.val = atoi(yytext);
+ tprintf("#D:%d ", yylval.val);
+ return NUMBER;
+ }
[1-9][0-9]* {
yylval.val = atoi(yytext);
tprintf("#D:%d ", yylval.val);
@@ -151,9 +154,6 @@ WORD [A-Za-z_][-A-Za-z_]*
yylval.val = (int) (60 * atof(yytext) + 0.5);
return FPNUMBER;
}
-"-" {
- return MINUS;
- }
"?" {
yylval.val = -1;
tprintf("? ");
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c
index cff924a..3f7e106 100644
--- a/usr.sbin/config/main.c
+++ b/usr.sbin/config/main.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id: main.c,v 1.30 1999/04/17 14:41:40 peter Exp $";
+ "$Id: main.c,v 1.31 1999/04/18 13:36:29 peter Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -131,7 +131,7 @@ main(argc, argv)
fprintf(stderr, "Removing old directory %s: ", p);
fflush(stderr);
- sprintf(tmp, "rm -rf %s", p);
+ snprintf(tmp, sizeof(tmp), "rm -rf %s", p);
if (system(tmp)) {
fprintf(stderr, "Failed!\n");
err(2, "%s", tmp);
diff --git a/usr.sbin/config/mkioconf.c b/usr.sbin/config/mkioconf.c
index f4927c7..96b1619 100644
--- a/usr.sbin/config/mkioconf.c
+++ b/usr.sbin/config/mkioconf.c
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)mkioconf.c 8.2 (Berkeley) 1/21/94";
#endif
static const char rcsid[] =
- "$Id: mkioconf.c,v 1.52 1999/04/18 14:27:33 kato Exp $";
+ "$Id: mkioconf.c,v 1.53 1999/04/19 14:40:55 peter Exp $";
#endif /* not lint */
#include <err.h>
@@ -60,7 +60,7 @@ devstr(struct device *dp)
return "nexus0";
if (dp->d_unit >= 0) {
- sprintf(buf, "%s%d", dp->d_name, dp->d_unit);
+ snprintf(buf, sizeof(buf), "%s%d", dp->d_name, dp->d_unit);
return buf;
} else
return dp->d_name;
@@ -319,7 +319,7 @@ qu(num)
return ("'?'");
if (num == UNKNOWN)
return (" -1");
- (void) sprintf(errbuf, "%3d", num);
+ (void) snprintf(errbuf, sizeof(errbuf), "%3d", num);
return (errbuf);
}
@@ -330,6 +330,6 @@ wnum(num)
if (num == QUES || num == UNKNOWN)
return ("?");
- (void) sprintf(errbuf, "%d", num);
+ (void) snprintf(errbuf, sizeof(errbuf), "%d", num);
return (errbuf);
}
diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c
index f5289c8..e1dfa2b 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.c
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)mkmakefile.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id: mkmakefile.c,v 1.39 1999/04/18 13:36:29 peter Exp $";
+ "$Id: mkmakefile.c,v 1.40 1999/04/19 13:53:07 peter Exp $";
#endif /* not lint */
/*
@@ -569,7 +569,7 @@ do_objs(fp)
for (fl = conf_list; fl; fl = fl->f_next) {
if (fl->f_type != SWAPSPEC)
continue;
- (void) sprintf(swapname, "swap%s.c", fl->f_fn);
+ (void) snprintf(swapname, sizeof(swapname), "swap%s.c", fl->f_fn);
if (eq(sp, swapname))
goto cont;
}
@@ -618,7 +618,7 @@ do_cfiles(fp)
}
for (fl = conf_list; fl; fl = fl->f_next)
if (fl->f_type == SYSTEMSPEC) {
- (void) sprintf(swapname, "swap%s.c", fl->f_fn);
+ (void) snprintf(swapname, sizeof(swapname), "swap%s.c", fl->f_fn);
if ((len = 3 + strlen(swapname)) + lpos > 72) {
lpos = 8;
fputs("\\\n\t", fp);
@@ -763,7 +763,7 @@ do_rules(f)
printf("config: don't know rules for %s\n", np);
break;
}
- (void)sprintf(cmd, "${%s_%c%s}", ftype, toupper(och),
+ (void)snprintf(cmd, sizeof(cmd), "${%s_%c%s}", ftype, toupper(och),
ftp->f_flags & CONFIGDEP? "_C" : "");
special = cmd;
}
diff --git a/usr.sbin/config/mkoptions.c b/usr.sbin/config/mkoptions.c
index a32f190..cd07a12 100644
--- a/usr.sbin/config/mkoptions.c
+++ b/usr.sbin/config/mkoptions.c
@@ -37,7 +37,7 @@
static char sccsid[] = "@(#)mkheaders.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id: mkoptions.c,v 1.9 1999/04/17 14:41:40 peter Exp $";
+ "$Id: mkoptions.c,v 1.10 1999/04/18 13:36:29 peter Exp $";
#endif /* not lint */
/*
@@ -106,7 +106,7 @@ options()
op = (struct opt *)malloc(sizeof(*op));
memset(op, 0, sizeof(*op));
op->op_name = "MAXUSERS";
- sprintf(buf, "%d", maxusers);
+ snprintf(buf, sizeof(buf), "%d", maxusers);
op->op_value = ns(buf);
op->op_next = opt;
opt = op;
diff --git a/usr.sbin/config/mkswapconf.c b/usr.sbin/config/mkswapconf.c
index b2c1c82..255cbf6 100644
--- a/usr.sbin/config/mkswapconf.c
+++ b/usr.sbin/config/mkswapconf.c
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)mkswapconf.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id: mkswapconf.c,v 1.17 1999/04/17 14:41:40 peter Exp $";
+ "$Id: mkswapconf.c,v 1.18 1999/04/18 13:36:29 peter Exp $";
#endif /* not lint */
/*
@@ -87,8 +87,8 @@ do_swap(fl)
fl = fl->f_next;
return (fl->f_next);
}
- (void) sprintf(swapname, "swap%s.c", fl->f_fn);
- (void) sprintf(newswapname, "swap%s.c.new", fl->f_fn);
+ (void) snprintf(swapname, sizeof(swapname), "swap%s.c", fl->f_fn);
+ (void) snprintf(newswapname, sizeof(newswapname), "swap%s.c.new", fl->f_fn);
fp = fopen(path(newswapname), "w");
if (fp == 0)
err(1, "%s", path(newswapname));
@@ -225,9 +225,9 @@ devtoname(dev)
partname[0] = 'a' + part;
partname[1] = '\0';
if (slice != COMPATIBILITY_SLICE)
- sprintf(slicename, "s%d", slice - 1);
+ snprintf(slicename, sizeof(slicename), "s%d", slice - 1);
}
- (void) sprintf(buf, "%s%d%s%s", dp->dev_name,
+ (void) snprintf(buf, sizeof(buf), "%s%d%s%s", dp->dev_name,
dkunit(dev), slicename, partname);
return (ns(buf));
}
@@ -241,7 +241,7 @@ initdevtable()
register struct devdescription **dp = &devtable;
FILE *fp;
- (void) sprintf(buf, "../conf/devices.%s", machinename);
+ (void) snprintf(buf, sizeof(buf), "../conf/devices.%s", machinename);
fp = fopen(buf, "r");
if (fp == NULL)
errx(1, "can't open %s", buf);
OpenPOWER on IntegriCloud