GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usr.sbin/config/main.c Lines: 0 306 0.0 %
Date: 2017-11-13 Branches: 0 248 0.0 %

Line Branch Exec Source
1
/*	$OpenBSD: main.c,v 1.59 2017/06/22 15:57:16 deraadt Exp $	*/
2
/*	$NetBSD: main.c,v 1.22 1997/02/02 21:12:33 thorpej Exp $	*/
3
4
/*
5
 * Copyright (c) 1992, 1993
6
 *	The Regents of the University of California.  All rights reserved.
7
 *
8
 * This software was developed by the Computer Systems Engineering group
9
 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
10
 * contributed to Berkeley.
11
 *
12
 * All advertising materials mentioning features or use of this software
13
 * must display the following acknowledgement:
14
 *	This product includes software developed by the University of
15
 *	California, Lawrence Berkeley Laboratories.
16
 *
17
 * Redistribution and use in source and binary forms, with or without
18
 * modification, are permitted provided that the following conditions
19
 * are met:
20
 * 1. Redistributions of source code must retain the above copyright
21
 *    notice, this list of conditions and the following disclaimer.
22
 * 2. Redistributions in binary form must reproduce the above copyright
23
 *    notice, this list of conditions and the following disclaimer in the
24
 *    documentation and/or other materials provided with the distribution.
25
 * 3. Neither the name of the University nor the names of its contributors
26
 *    may be used to endorse or promote products derived from this software
27
 *    without specific prior written permission.
28
 *
29
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39
 * SUCH DAMAGE.
40
 *
41
 *	from: @(#)main.c	8.1 (Berkeley) 6/6/93
42
 */
43
44
#include <sys/types.h>
45
#include <sys/stat.h>
46
47
#include <ctype.h>
48
#include <err.h>
49
#include <errno.h>
50
#include <stdio.h>
51
#include <stdlib.h>
52
#include <string.h>
53
#include <unistd.h>
54
#include <limits.h>
55
56
#include "config.h"
57
58
int	firstfile(const char *);
59
int	yyparse(void);
60
61
static struct hashtab *mkopttab;
62
static struct nvlist **nextopt;
63
static struct nvlist **nextdefopt;
64
static struct nvlist **nextmkopt;
65
66
static __dead void stop(void);
67
static int do_option(struct hashtab *, struct nvlist ***,
68
    const char *, const char *, const char *);
69
static int crosscheck(void);
70
static int badstar(void);
71
static int mksymlinks(void);
72
static int hasparent(struct devi *);
73
static int cfcrosscheck(struct config *, const char *, struct nvlist *);
74
static void optiondelta(void);
75
76
int	verbose;
77
78
__dead void
79
usage(void)
80
{
81
	extern char *__progname;
82
83
	fprintf(stderr,
84
		"usage: %s [-p] [-b builddir] [-s srcdir] [config-file]\n"
85
		"       %s [-u] [-f | -o outfile] -e infile\n",
86
		__progname, __progname);
87
88
	exit(1);
89
}
90
91
int pflag = 0;
92
char *sflag = NULL;
93
char *bflag = NULL;
94
char *startdir;
95
96
int
97
main(int argc, char *argv[])
98
{
99
	char *p;
100
	char *outfile = NULL;
101
	int ch, eflag, uflag, fflag;
102
	char dirbuffer[PATH_MAX];
103
104
	if (pledge("stdio rpath wpath cpath flock proc exec", NULL) == -1)
105
		err(1, "pledge");
106
107
	pflag = eflag = uflag = fflag = 0;
108
	while ((ch = getopt(argc, argv, "epfb:s:o:u")) != -1) {
109
		switch (ch) {
110
111
		case 'o':
112
			outfile = optarg;
113
			break;
114
		case 'u':
115
			uflag = 1;
116
			break;
117
		case 'f':
118
			fflag = 1;
119
			break;
120
121
		case 'e':
122
			eflag = 1;
123
			if (!isatty(STDIN_FILENO))
124
				verbose = 1;
125
			break;
126
127
		case 'p':
128
			/*
129
			 * Essentially the same as makeoptions PROF="-pg",
130
			 * but also changes the path from ../../compile/FOO
131
			 * to ../../compile/FOO.PROF; i.e., compile a
132
			 * profiling kernel based on a typical "regular"
133
			 * kernel.
134
			 *
135
			 * Note that if you always want profiling, you
136
			 * can (and should) use a "makeoptions" line.
137
			 */
138
			pflag = 1;
139
			break;
140
141
		case 'b':
142
			bflag = optarg;
143
			builddir = optarg;
144
			break;
145
146
		case 's':
147
			sflag = optarg;
148
			srcdir = optarg;
149
			break;
150
151
		default:
152
			usage();
153
		}
154
	}
155
156
	argc -= optind;
157
	argv += optind;
158
	if (argc > 1 || (eflag && argv[0] == NULL))
159
		usage();
160
	if (bflag) {
161
		startdir = getcwd(dirbuffer, sizeof dirbuffer);
162
		if (startdir == NULL)
163
			warn("Use of -b and can't getcwd, no make config");
164
	} else {
165
		startdir = "../../conf";
166
	}
167
168
	if (eflag) {
169
#ifdef MAKE_BOOTSTRAP
170
		errx(1, "UKC not available in this binary");
171
#else
172
		return (ukc(argv[0], outfile, uflag, fflag));
173
#endif
174
	}
175
176
	conffile = (argc == 1) ? argv[0] : "CONFIG";
177
	if (firstfile(conffile))
178
		err(2, "cannot read %s", conffile);
179
180
	/*
181
	 * Init variables.
182
	 */
183
	minmaxusers = 1;
184
	maxmaxusers = 10000;
185
	initintern();
186
	initfiles();
187
	initsem();
188
	devbasetab = ht_new();
189
	devatab = ht_new();
190
	selecttab = ht_new();
191
	needcnttab = ht_new();
192
	opttab = ht_new();
193
	mkopttab = ht_new();
194
	defopttab = ht_new();
195
	nextopt = &options;
196
	nextmkopt = &mkoptions;
197
	nextdefopt = &defoptions;
198
199
	/*
200
	 * Handle profiling (must do this before we try to create any
201
	 * files).
202
	 */
203
	last_component = strrchr(conffile, '/');
204
	last_component = (last_component) ? last_component + 1 : conffile;
205
	if (pflag) {
206
		if (asprintf(&p, "../compile/%s.PROF", last_component) == -1)
207
			err(1, NULL);
208
		(void)addmkoption(intern("PROF"), "-pg");
209
		(void)addoption(intern("GPROF"), NULL);
210
	} else {
211
		if (asprintf(&p, "../compile/%s", last_component) == -1)
212
			err(1, NULL);
213
	}
214
	defbuilddir = (argc == 0) ? "." : p;
215
216
	/*
217
	 * Parse config file (including machine definitions).
218
	 */
219
	if (yyparse())
220
		stop();
221
222
	/*
223
	 * Fix (as in `set firmly in place') files.
224
	 */
225
	if (fixfiles())
226
		stop();
227
228
	/*
229
	 * Fix objects and libraries.
230
	 */
231
	if (fixobjects())
232
		stop();
233
234
	/*
235
	 * Perform cross-checking.
236
	 */
237
	if (maxusers == 0) {
238
		if (defmaxusers) {
239
			(void)printf("maxusers not specified; %d assumed\n",
240
			    defmaxusers);
241
			maxusers = defmaxusers;
242
		} else {
243
			warnx("need \"maxusers\" line");
244
			errors++;
245
		}
246
	}
247
	if (crosscheck() || errors)
248
		stop();
249
250
	/*
251
	 * Squeeze things down and finish cross-checks (STAR checks must
252
	 * run after packing).
253
	 */
254
	pack();
255
	if (badstar())
256
		stop();
257
258
	/*
259
	 * Ready to go.  Build all the various files.
260
	 */
261
	if (mksymlinks() || mkmakefile() || mkheaders() || mkswap() ||
262
	    mkioconf())
263
		stop();
264
	optiondelta();
265
	return (0);
266
}
267
268
static int
269
mksymlink(const char *value, const char *path)
270
{
271
	int ret = 0;
272
273
	if (remove(path) && errno != ENOENT) {
274
		warn("remove(%s)", path);
275
		ret = 1;
276
	}
277
	if (symlink(value, path)) {
278
		warn("symlink(%s -> %s)", path, value);
279
		ret = 1;
280
	}
281
	return (ret);
282
}
283
284
285
/*
286
 * Make a symlink for "machine" so that "#include <machine/foo.h>" works,
287
 * and for the machine's CPU architecture, so that works as well.
288
 */
289
static int
290
mksymlinks(void)
291
{
292
	int ret;
293
	char *p, buf[PATH_MAX];
294
	const char *q;
295
296
	snprintf(buf, sizeof buf, "arch/%s/include", machine);
297
	p = sourcepath(buf);
298
	ret = mksymlink(p, "machine");
299
	if (machinearch != NULL) {
300
		snprintf(buf, sizeof buf, "arch/%s/include", machinearch);
301
		p = sourcepath(buf);
302
		q = machinearch;
303
	} else {
304
		p = strdup("machine");
305
		if (!p)
306
			errx(1, "out of memory");
307
		q = machine;
308
	}
309
	ret |= mksymlink(p, q);
310
	free(p);
311
312
	return (ret);
313
}
314
315
static __dead void
316
stop(void)
317
{
318
	(void)fprintf(stderr, "*** Stop.\n");
319
	exit(1);
320
}
321
322
/*
323
 * Define a standard option, for which a header file will be generated.
324
 */
325
void
326
defoption(const char *name)
327
{
328
	char *p, *low, c;
329
	const char *n;
330
331
	/*
332
	 * Convert to lower case.  The header file name will be
333
	 * in lower case, so we store the lower case version in
334
	 * the hash table to detect option name collisions.  The
335
	 * original string will be stored in the nvlist for use
336
	 * in the header file.
337
	 */
338
	low = emalloc(strlen(name) + 1);
339
	for (n = name, p = low; (c = *n) != '\0'; n++)
340
		*p++ = isupper((unsigned char)c) ?
341
		    tolower((unsigned char)c) : c;
342
	*p = 0;
343
344
	n = intern(low);
345
	free(low);
346
	(void)do_option(defopttab, &nextdefopt, n, name, "defopt");
347
348
	/*
349
	 * Insert a verbatim copy of the option name, as well,
350
	 * to speed lookups when creating the Makefile.
351
	 */
352
	(void)ht_insert(defopttab, name, (void *)name);
353
}
354
355
/*
356
 * Remove an option.
357
 */
358
void
359
removeoption(const char *name)
360
{
361
	struct nvlist *nv, *nvt;
362
	char *p, *low, c;
363
	const char *n;
364
365
	if ((nv = ht_lookup(opttab, name)) != NULL) {
366
		if (options == nv) {
367
			options = nv->nv_next;
368
			nvfree(nv);
369
		} else {
370
			nvt = options;
371
			while (nvt->nv_next != NULL) {
372
				if (nvt->nv_next == nv) {
373
					nvt->nv_next = nvt->nv_next->nv_next;
374
					nvfree(nv);
375
					break;
376
				} else
377
					nvt = nvt->nv_next;
378
			}
379
		}
380
	}
381
382
	(void)ht_remove(opttab, name);
383
384
	low = emalloc(strlen(name) + 1);
385
	/* make lowercase, then remove from select table */
386
	for (n = name, p = low; (c = *n) != '\0'; n++)
387
		*p++ = isupper((unsigned char)c) ?
388
		    tolower((unsigned char)c) : c;
389
	*p = 0;
390
	n = intern(low);
391
	free(low);
392
	(void)ht_remove(selecttab, n);
393
}
394
395
/*
396
 * Add an option from "options FOO".  Note that this selects things that
397
 * are "optional foo".
398
 */
399
void
400
addoption(const char *name, const char *value)
401
{
402
	char *p, *low, c;
403
	const char *n;
404
405
	if (do_option(opttab, &nextopt, name, value, "options"))
406
		return;
407
408
	low = emalloc(strlen(name) + 1);
409
	/* make lowercase, then add to select table */
410
	for (n = name, p = low; (c = *n) != '\0'; n++)
411
		*p++ = isupper((unsigned char)c) ?
412
		    tolower((unsigned char)c) : c;
413
	*p = 0;
414
	n = intern(low);
415
	free(low);
416
	(void)ht_insert(selecttab, n, (void *)n);
417
}
418
419
/*
420
 * Add a "make" option.
421
 */
422
void
423
addmkoption(const char *name, const char *value)
424
{
425
426
	(void)do_option(mkopttab, &nextmkopt, name, value, "mkoptions");
427
}
428
429
/*
430
 * Add a name=value pair to an option list.  The value may be NULL.
431
 */
432
static int
433
do_option(struct hashtab *ht, struct nvlist ***nppp, const char *name,
434
    const char *value, const char *type)
435
{
436
	struct nvlist *nv;
437
438
	/* assume it will work */
439
	nv = newnv(name, value, NULL, 0, NULL);
440
	if (ht_insert(ht, name, nv) == 0) {
441
		**nppp = nv;
442
		*nppp = &nv->nv_next;
443
		return (0);
444
	}
445
446
	/* oops, already got that option */
447
	nvfree(nv);
448
	if ((nv = ht_lookup(ht, name)) == NULL)
449
		panic("do_option");
450
	if (nv->nv_str != NULL)
451
		error("already have %s `%s=%s'", type, name, nv->nv_str);
452
	else
453
		error("already have %s `%s'", type, name);
454
	return (1);
455
}
456
457
/*
458
 * Return true if there is at least one instance of the given unit
459
 * on the given device attachment (or any units, if unit == WILD).
460
 */
461
int
462
deva_has_instances(struct deva *deva, int unit)
463
{
464
	struct devi *i;
465
466
	if (unit == WILD)
467
		return (deva->d_ihead != NULL);
468
	for (i = deva->d_ihead; i != NULL; i = i->i_asame)
469
		if (unit == i->i_unit)
470
			return (1);
471
	return (0);
472
}
473
474
/*
475
 * Return true if there is at least one instance of the given unit
476
 * on the given base (or any units, if unit == WILD).
477
 */
478
int
479
devbase_has_instances(struct devbase *dev, int unit)
480
{
481
	struct deva *da;
482
483
	for (da = dev->d_ahead; da != NULL; da = da->d_bsame)
484
		if (deva_has_instances(da, unit))
485
			return (1);
486
	return (0);
487
}
488
489
static int
490
hasparent(struct devi *i)
491
{
492
	struct nvlist *nv;
493
	int atunit = i->i_atunit;
494
495
	/*
496
	 * We determine whether or not a device has a parent in in one
497
	 * of two ways:
498
	 *	(1) If a parent device was named in the config file,
499
	 *	    i.e. cases (2) and (3) in sem.c:adddev(), then
500
	 *	    we search its devbase for a matching unit number.
501
	 *	(2) If the device was attach to an attribute, then we
502
	 *	    search all attributes the device can be attached to
503
	 *	    for parents (with appropriate unit numbers) that
504
	 *	    may be able to attach the device.
505
	 */
506
507
	/*
508
	 * Case (1): A parent was named.  Either it's configured, or not.
509
	 */
510
	if (i->i_atdev != NULL)
511
		return (devbase_has_instances(i->i_atdev, atunit));
512
513
	/*
514
	 * Case (2): No parent was named.  Look for devs that provide the attr.
515
	 */
516
	if (i->i_atattr != NULL)
517
		for (nv = i->i_atattr->a_refs; nv != NULL; nv = nv->nv_next)
518
			if (devbase_has_instances(nv->nv_ptr, atunit))
519
				return (1);
520
	return (0);
521
}
522
523
static int
524
cfcrosscheck(struct config *cf, const char *what, struct nvlist *nv)
525
{
526
	struct devbase *dev;
527
	struct devi *pd;
528
	int errs, devminor;
529
530
	if (maxpartitions <= 0)
531
		panic("cfcrosscheck");
532
533
	for (errs = 0; nv != NULL; nv = nv->nv_next) {
534
		if (nv->nv_name == NULL)
535
			continue;
536
		dev = ht_lookup(devbasetab, nv->nv_name);
537
		if (dev == NULL)
538
			panic("cfcrosscheck(%s)", nv->nv_name);
539
		devminor = minor(nv->nv_int) / maxpartitions;
540
		if (devbase_has_instances(dev, devminor))
541
			continue;
542
		if (devbase_has_instances(dev, STAR) &&
543
		    devminor >= dev->d_umax)
544
			continue;
545
		for (pd = allpseudo; pd != NULL; pd = pd->i_next)
546
			if (pd->i_base == dev && devminor < dev->d_umax &&
547
			    devminor >= 0)
548
				goto loop;
549
		(void)fprintf(stderr,
550
		    "%s:%d: %s says %s on %s, but there's no %s\n",
551
		    conffile, cf->cf_lineno,
552
		    cf->cf_name, what, nv->nv_str, nv->nv_str);
553
		errs++;
554
loop:
555
		;
556
	}
557
	return (errs);
558
}
559
560
/*
561
 * Cross-check the configuration: make sure that each target device
562
 * or attribute (`at foo[0*?]') names at least one real device.  Also
563
 * see that the root, swap, and dump devices for all configurations
564
 * are there.
565
 */
566
int
567
crosscheck(void)
568
{
569
	struct devi *i;
570
	struct config *cf;
571
	int errs;
572
573
	errs = 0;
574
	for (i = alldevi; i != NULL; i = i->i_next) {
575
		if (i->i_at == NULL || hasparent(i))
576
			continue;
577
		xerror(conffile, i->i_lineno,
578
		    "%s at %s is orphaned", i->i_name, i->i_at);
579
		(void)fprintf(stderr, " (%s %s declared)\n",
580
		    i->i_atunit == WILD ? "nothing matching" : "no",
581
		    i->i_at);
582
		errs++;
583
	}
584
	if (allcf == NULL) {
585
		(void)fprintf(stderr, "%s has no configurations!\n",
586
		    conffile);
587
		errs++;
588
	}
589
	for (cf = allcf; cf != NULL; cf = cf->cf_next) {
590
		if (cf->cf_root != NULL) {	/* i.e., not swap generic */
591
			errs += cfcrosscheck(cf, "root", cf->cf_root);
592
			errs += cfcrosscheck(cf, "swap", cf->cf_swap);
593
			errs += cfcrosscheck(cf, "dumps", cf->cf_dump);
594
		}
595
	}
596
	return (errs);
597
}
598
599
/*
600
 * Check to see if there is a *'d unit with a needs-count file.
601
 */
602
int
603
badstar(void)
604
{
605
	struct devbase *d;
606
	struct deva *da;
607
	struct devi *i;
608
	int errs, n;
609
610
	errs = 0;
611
	for (d = allbases; d != NULL; d = d->d_next) {
612
		for (da = d->d_ahead; da != NULL; da = da->d_bsame)
613
			for (i = da->d_ihead; i != NULL; i = i->i_asame) {
614
				if (i->i_unit == STAR)
615
					goto foundstar;
616
			}
617
		continue;
618
	foundstar:
619
		if (ht_lookup(needcnttab, d->d_name)) {
620
			warnx("%s's cannot be *'d until its driver is fixed",
621
			    d->d_name);
622
			errs++;
623
			continue;
624
		}
625
		for (n = 0; i != NULL; i = i->i_alias)
626
			if (!i->i_collapsed)
627
				n++;
628
		if (n < 1)
629
			panic("badstar() n<1");
630
	}
631
	return (errs);
632
}
633
634
/*
635
 * Verify/create builddir if necessary, change to it, and verify srcdir.
636
 * This will be called when we see the first include.
637
 */
638
void
639
setupdirs(void)
640
{
641
	struct stat st;
642
	FILE *fp;
643
644
	/* srcdir must be specified if builddir is not specified or if
645
	 * no configuration filename was specified. */
646
	if ((builddir || strcmp(defbuilddir, ".") == 0) && !srcdir) {
647
		error("source directory must be specified");
648
		exit(1);
649
	}
650
651
	if (srcdir == NULL)
652
		srcdir = "../../../..";
653
	if (builddir == NULL)
654
		builddir = defbuilddir;
655
656
	if (stat(builddir, &st) != 0) {
657
		if (mkdir(builddir, 0777))
658
			err(2, "cannot create %s", builddir);
659
	} else if (!S_ISDIR(st.st_mode))
660
		errc(2, ENOTDIR, "%s", builddir);
661
	if (chdir(builddir) != 0)
662
		errx(2, "cannot change to %s", builddir);
663
	if (stat(srcdir, &st) != 0 || !S_ISDIR(st.st_mode))
664
		errc(2, ENOTDIR, "%s", srcdir);
665
666
	if (bflag) {
667
		if (pledge("stdio rpath wpath cpath flock", NULL) == -1)
668
			err(1, "pledge");
669
		return;
670
	}
671
672
	if (stat("obj", &st) == 0)
673
		goto reconfig;
674
675
	fp = fopen("Makefile", "w");
676
	if (!fp)
677
		errx(2, "cannot create Makefile");
678
	if (fprintf(fp, ".include \"../Makefile.inc\"\n") < 0 ||
679
	    fclose(fp) == EOF)
680
		errx(2, "cannot write Makefile");
681
682
reconfig:
683
	if (system("make obj") != 0)
684
		exit(2);
685
	if (system("make config") != 0)
686
		exit(2);
687
	exit(0);
688
}
689
690
struct opt {
691
	const char *name;
692
	const char *val;
693
};
694
695
int
696
optcmp(const void *v1, const void *v2)
697
{
698
	const struct opt *sp1 = v1, *sp2 = v2;
699
	int r;
700
701
	r = strcmp(sp1->name, sp2->name);
702
	if (r == 0) {
703
		if (!sp1->val && !sp2->val)
704
			r = 0;
705
		else if (sp1->val && !sp2->val)
706
			r = -1;
707
		else if (sp2->val && !sp1->val)
708
			r = 1;
709
		else r = strcmp(sp1->val, sp2->val);
710
	}
711
	return (r);
712
}
713
714
void
715
optiondelta(void)
716
{
717
	struct nvlist *nv;
718
	char nbuf[BUFSIZ], obuf[BUFSIZ];	/* XXX size */
719
	int nnewopts, ret = 0, i;
720
	struct opt *newopts;
721
	FILE *fp;
722
723
	for (nnewopts = 0, nv = options; nv != NULL; nv = nv->nv_next)
724
		nnewopts++;
725
	newopts = ereallocarray(NULL, nnewopts, sizeof(struct opt));
726
	if (newopts == NULL)
727
		ret = 0;
728
	for (i = 0, nv = options; nv != NULL; nv = nv->nv_next, i++) {
729
		newopts[i].name = nv->nv_name;
730
		newopts[i].val = nv->nv_str;
731
	}
732
	qsort(newopts, nnewopts, sizeof (struct opt), optcmp);
733
734
	/* compare options against previous config */
735
	if ((fp = fopen("options", "r"))) {
736
		for (i = 0; !feof(fp) && i < nnewopts && ret == 0; i++) {
737
			if (newopts[i].val)
738
				snprintf(nbuf, sizeof nbuf, "%s=%s\n",
739
				    newopts[i].name, newopts[i].val);
740
			else
741
				snprintf(nbuf, sizeof nbuf, "%s\n",
742
				    newopts[i].name);
743
			if (fgets(obuf, sizeof obuf, fp) == NULL ||
744
			    strcmp(nbuf, obuf))
745
				ret = 1;
746
		}
747
		fclose(fp);
748
		fp = NULL;
749
	} else if (access("options", F_OK) == 0)
750
		ret = 1;
751
752
	/* replace with the new list of options */
753
	if ((fp = fopen("options", "w+"))) {
754
		rewind(fp);
755
		for (i = 0; i < nnewopts; i++) {
756
			if (newopts[i].val)
757
				fprintf(fp, "%s=%s\n", newopts[i].name,
758
				    newopts[i].val);
759
			else
760
				fprintf(fp, "%s\n", newopts[i].name);
761
		}
762
		fclose(fp);
763
	}
764
	free(newopts);
765
	if (ret == 0)
766
		return;
767
	(void)printf("Kernel options have changed -- you must run \"make clean\"\n");
768
}