diff --git a/tools/kconfig/Makefile b/tools/kconfig/Makefile index 3553bae..57f981f 100644 --- a/tools/kconfig/Makefile +++ b/tools/kconfig/Makefile @@ -6,12 +6,16 @@ OBJS = config.o main.o lang.o mkioconf.o mkmakefile.o mkheaders.o \ mkswapconf.o PROG = kconfig -all: $(PROG) +all: $(PROG) $(PROG).0 install: $(PROG) install -s $(PROG) ${DESTDIR}/bin/$(PROG) + +$(PROG).0: $(PROG).8 + nroff -man $< > $@ + clean: - rm -rf *~ *.o *.lst *.dis $(PROG) $(PROG).dSYM y.tab.[ch] lang.c config.c + rm -rf *~ *.o *.lst *.dis $(PROG) $(PROG).0 $(PROG).dSYM y.tab.[ch] lang.c config.c $(PROG): $(OBJS) $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) diff --git a/tools/kconfig/config.8 b/tools/kconfig/config.8 deleted file mode 100644 index 3a2794c..0000000 --- a/tools/kconfig/config.8 +++ /dev/null @@ -1,156 +0,0 @@ -.\" Copyright (c) 1980, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)config.8 8.2 (Berkeley) 4/19/94 -.\" -.Dd April 19, 1994 -.Dt CONFIG 8 -.Os BSD 4 -.Sh NAME -.Nm kconfig -.Nd build system configuration files -.Sh SYNOPSIS -.Nm kconfig -.Op Fl p -.Ar system_name -.Sh DESCRIPTION -.Pp -.Nm Kconfig -builds a set of system configuration files from the file -.Ar SYSTEM_NAME -which describes -the system to configure. -A second file -tells -.Nm kconfig -what files are needed to generate a system and -can be augmented by configuration specific set of files -that give alternate files for a specific machine. -(see the -.Sx FILES -section below) -.Pp -Available option and operand: -.Pp -.Bl -tag -width SYSTEM_NAME -.It Fl p -If the -.Fl p -option is supplied, -.Nm kconfig -will configure a system for profiling; for example, -.Xr kgmon 8 -and -.Xr gprof 1 . -.It Ar SYSTEM_NAME -specifies the name of the system configuration file -containing device specifications, configuration options -and other system parameters for one system configuration. -.El -.Pp -.Nm Config -should be run from the -.Pa conf -subdirectory of the system source (usually -.Pa /sys/conf ) . -.Nm Config -assumes the directory -.Pa ../SYSTEM_NAME -exists and places all output files there. -The output of -.Nm kconfig -consists of a number of files; for the -.Tn VAX , -they are: -.Pa ioconf.c , -a description -of what I/O devices are attached to the system; -.Pa ubvec.s , -offsets into a structure used for counting per-device interrupts; -.Pa Makefile , -used by -.Xr make 1 -in building the system; -header files, -definitions of -the number of various devices that will be compiled into the system; -swap configuration files, -definitions for -the disk areas to be used for swapping, the root file system, -argument processing, and system dumps. -.Pp -After running -.Nm kconfig , -it is necessary to run -.Dq Li make depend -in the directory where the new makefile -was created. -.Nm Config -prints a reminder of this when it completes. -.Pp -If any other error messages are produced by -.Nm kconfig , -the problems in the configuration file should be corrected and -.Nm kconfig -should be run again. -Attempts to compile a system that had configuration errors -are likely to fail. -.Sh FILES -.Bl -tag -width /sys/conf/Makefile.pic32 -compact -.It Pa /sys/conf/Makefile.pic32 -generic makefile for the -.Tn VAX -.It Pa /sys/conf/files -list of common files system is built from -.It Pa /sys/conf/files.pic32 -list of -.Tn VAX -specific files -.It Pa /sys/conf/devices.pic32 -name to major device mapping file for the -.Tn VAX -.It Pa /sys/conf/files. Ns Em ERNIE -list of files specific to -.Em ERNIE -system -.El -.Sh SEE ALSO -The SYNOPSIS portion of each device in section 4. -.Rs -.%T "Building RetroBSD Kernel with kconfig" -.Re -.Sh BUGS -The line numbers reported in error messages are usually off by one. -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.1 . diff --git a/tools/kconfig/config.h b/tools/kconfig/config.h index 7a42a11..c08ff50 100644 --- a/tools/kconfig/config.h +++ b/tools/kconfig/config.h @@ -88,8 +88,6 @@ struct file_list { #define PROFILING 4 #define SYSTEMSPEC 5 #define SWAPSPEC 6 -#define COMPDEVICE 7 -#define COMPSPEC 8 /* * Attributes (flags). @@ -163,8 +161,6 @@ char *ldscript; int do_trace; -int seen_cd; - struct device *dtab; char errbuf[80]; @@ -185,7 +181,7 @@ int maxusers; char *get_word(FILE *); char *get_quoted_word(FILE *); char *raise(char *); -dev_t nametodev(char *, int, char); +dev_t nametodev(char *, int); char *devtoname(dev_t); void init_dev(struct device *); int yyparse(void); diff --git a/tools/kconfig/config.y b/tools/kconfig/config.y index aa89a34..e72f9c2 100644 --- a/tools/kconfig/config.y +++ b/tools/kconfig/config.y @@ -22,7 +22,6 @@ %token FLAGS %token HZ %token IDENT -%token INTERLEAVE %token LDSCRIPT %token MACHINE %token MAJOR @@ -57,11 +56,9 @@ %type optional_sflag %type device_name %type major_minor -%type arg_device_spec %type root_device_spec %type dump_device_spec %type swap_device_spec -%type comp_device_spec %{ @@ -263,7 +260,7 @@ swap_device_spec: if (eq($1, "generic")) fl->f_fn = $1; else { - fl->f_swapdev = nametodev($1, 0, 'b'); + fl->f_swapdev = nametodev($1, 0); fl->f_fn = devtoname(fl->f_swapdev); } $$ = fl; @@ -293,7 +290,7 @@ root_spec: root_device_spec: device_name - = { $$ = nametodev($1, 0, 'a'); } + = { $$ = nametodev($1, 0); } | major_minor ; @@ -312,14 +309,7 @@ dump_spec: dump_device_spec: device_name - = { $$ = nametodev($1, 0, 'b'); } - | - major_minor - ; - -arg_device_spec: - device_name - = { $$ = nametodev($1, 0, 'b'); } + = { $$ = nametodev($1, 0); } | major_minor ; @@ -469,68 +459,6 @@ Device_spec: 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"); - seen_cd = 1; - 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, '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: @@ -556,14 +484,7 @@ Dev_info: Con_info: AT Dev NUMBER - = { - if (eq(cur.d_name, "mba") || eq(cur.d_name, "uba")) { - (void) sprintf(errbuf, - "%s must be connected to a nexus", cur.d_name); - yyerror(errbuf); - } - cur.d_conn = connect($2, $3); - } + = { cur.d_conn = connect($2, $3); } ; Info_list: @@ -712,51 +633,13 @@ void mkswap(system, fl, size, flag) */ if (system->f_fn) return; + if (eq(fl->f_fn, "generic")) system->f_fn = strdup(fl->f_fn); else system->f_fn = strdup(system->f_needs); } -void mkcomp(dp) - register struct device *dp; -{ - register struct file_list *fl, **flp; - char buf[80]; - - fl = (struct file_list *) malloc(sizeof *fl); - fl->f_type = COMPDEVICE; - fl->f_compinfo = dp->d_unit; - fl->f_fn = strdup(dp->d_name); - (void) sprintf(buf, "%s%d", dp->d_name, dp->d_unit); - fl->f_needs = strdup(buf); - fl->f_next = 0; - for (flp = compp; *flp; flp = &(*flp)->f_next) - ; - *flp = fl; - compp = flp; -} - -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 @@ -932,7 +815,7 @@ void checksystemspec(fl) yyerror(buf); } swap->f_swapdev = - makedev(major(dev), (minor(dev) &~ 07) | ('b' - 'a')); + makedev(major(dev), (minor(dev) &~ 07) | ('b' - 'a' + 1)); swap->f_fn = devtoname(swap->f_swapdev); mkswap(fl, swap, 0, 0); } @@ -1018,23 +901,6 @@ verifyswap(fl, checked, pchecked) return (pchecked); } -/* - * Verify that components of a compound device have themselves been config'ed - */ -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; - fprintf(stderr, - "config: %s: component device %s not configured\n", - dname, fl->f_needs); - } -} - /* * Has a device already been checked * for it's existence in the configuration? diff --git a/tools/kconfig/kconfig.8 b/tools/kconfig/kconfig.8 new file mode 100644 index 0000000..cb9f9c4 --- /dev/null +++ b/tools/kconfig/kconfig.8 @@ -0,0 +1,102 @@ +.Dd June 1, 2015 +.Dt CONFIG 8 +.Os RetroBSD +.Sh NAME +.Nm kconfig +.Nd build kernel configuration files +.Sh SYNOPSIS +.Nm kconfig +.Op Fl p +.Ar system_name +.Sh DESCRIPTION +.Pp +.Nm Kconfig +builds a set of kernel configuration files from the file +.Ar SYSTEM_NAME +which describes the kernel to configure. +A second file tells +.Nm kconfig +what files are needed to generate a kernel and +can be augmented by configuration specific set of files +that give alternate files for a specific machine. +(see the +.Sx FILES +section below) +.Pp +Available option and operand: +.Pp +.Bl -tag -width SYSTEM_NAME +.It Fl p +If the +.Fl p +option is supplied, +.Nm kconfig +will configure a kernel for profiling; for example, +.Xr kgmon 8 +and +.Xr gprof 1 . +.It Ar SYSTEM_NAME +specifies the name of the kernel configuration file +containing device specifications, configuration options +and other system parameters for one kernel configuration. +.El +.Pp +.Nm Kconfig +should be run from the machine and board specific +subdirectory of the system source (like +.Pa sys/pic32/max32 ) . +.Nm Kconfig +places all output files in the current directory. +The output of +.Nm kconfig +consists of a number of files: +.Pa ioconf.c , +a description +of what I/O devices are attached to the system; +.Pa Makefile , +used by +.Xr make 1 +in building the kernel; +header files, definitions of +the number of various devices that will be compiled into the kernel; +swap configuration files, definitions for +the disk areas to be used for swapping, the root file system, +argument processing, and kernel dumps. +.Pp +After running +.Nm kconfig , +it is necessary to run +.Dq Li make depend +in the directory where the new makefile +was created (current directory). +.Nm Kconfig +prints a reminder of this when it completes. +.Pp +If any other error messages are produced by +.Nm kconfig , +the problems in the configuration file should be corrected and +.Nm kconfig +should be run again. +Attempts to compile a kernel that had configuration errors +are likely to fail. +.Sh FILES +.Bl -tag -width ../Makefile.kconf -compact +.It Pa ../Makefile.kconf +generic makefile for the platform +.It Pa ../files.kconf +list of files kernel is built from +.It Pa ../devices.kconf +name to major device mapping file +.El +.Sh SEE ALSO +The SYNOPSIS portion of each device in section 4. +.Rs +.%T "Building RetroBSD Kernel with kconfig" +.Re +.Sh BUGS +The line numbers reported in error messages are usually off by one. +.Sh HISTORY +The +.Nm +command appeared in +.Bx 4.1 . diff --git a/tools/kconfig/lang.l b/tools/kconfig/lang.l index 4e38c00..08e5bd2 100644 --- a/tools/kconfig/lang.l +++ b/tools/kconfig/lang.l @@ -36,7 +36,6 @@ * * @(#)lang.l 8.1 (Berkeley) 6/6/93 */ - #include #include "y.tab.h" #include "config.h" @@ -46,11 +45,12 @@ /* * Key word table */ - struct kt { char *kt_name; int kt_val; -} key_words[] = { +}; + +static struct kt key_words[] = { { "and", AND }, { "at", AT }, { "config", CONFIG }, @@ -65,7 +65,6 @@ struct kt { { "flags", FLAGS }, { "hz", HZ }, { "ident", IDENT }, - { "interleave", INTERLEAVE }, { "ldscript", LDSCRIPT }, { "machine", MACHINE }, { "major", MAJOR }, @@ -89,9 +88,21 @@ struct kt { { 0, 0 }, }; -int kw_lookup(char *word); -int octal(char *str); -int hex(char *str); +/* + * Look up a string in the keyword table. Returns a -1 if the + * string is not a keyword otherwise it returns the keyword number + */ +static int +kw_lookup(word) + register char *word; +{ + register struct kt *kp; + + for (kp = key_words; kp->kt_name != 0; kp++) + if (eq(word, kp->kt_name)) + return kp->kt_val; + return -1; +} %} WORD [A-Za-z_][-A-Za-z_]* %% @@ -113,12 +124,12 @@ WORD [A-Za-z_][-A-Za-z_]* return ID; } 0[0-7]* { - yylval.val = octal(yytext); + yylval.val = strtoul(yytext, 0, 8); tprintf("#O:%o ", yylval.val); return NUMBER; } 0x[0-9a-fA-F]+ { - yylval.val = hex(yytext); + yylval.val = strtoul(yytext, 0, 16); tprintf("#X:%x ", yylval.val); return NUMBER; } @@ -158,42 +169,3 @@ WORD [A-Za-z_][-A-Za-z_]* . { return yytext[0]; } %% -/* - * kw_lookup - * Look up a string in the keyword table. Returns a -1 if the - * string is not a keyword otherwise it returns the keyword number - */ -int -kw_lookup(word) - register char *word; -{ - register struct kt *kp; - - for (kp = key_words; kp->kt_name != 0; kp++) - if (eq(word, kp->kt_name)) - return kp->kt_val; - return -1; -} - -/* - * Number conversion routines - */ -int -octal(str) - char *str; -{ - int num; - - (void) sscanf(str, "%o", &num); - return num; -} - -int -hex(str) - char *str; -{ - int num; - - (void) sscanf(str+2, "%x", &num); - return num; -} diff --git a/tools/kconfig/max32/MAX32 b/tools/kconfig/max32/Config similarity index 93% rename from tools/kconfig/max32/MAX32 rename to tools/kconfig/max32/Config index b36951d..7a8656d 100644 --- a/tools/kconfig/max32/MAX32 +++ b/tools/kconfig/max32/Config @@ -25,9 +25,9 @@ options "CPU_KHZ=80000" # Oscillator frequency of CPU core options "HZ=100" # Frequency of clock interrupt # Root filesystem at /dev/sd0a, swap at /dev/sd0b -config unix root on major 0 minor 1 - swap on major 0 minor 2 - dumps on major 0 minor 2 +config unix root on sd0a + swap on sd0b + dumps on sd0b # UART ports device uart1 flags 0x614f # pins rx=RD14, tx=RD15 - logical 39/40 diff --git a/tools/kconfig/mkioconf.c b/tools/kconfig/mkioconf.c index b56e11b..c01ec62 100644 --- a/tools/kconfig/mkioconf.c +++ b/tools/kconfig/mkioconf.c @@ -33,40 +33,6 @@ #include "y.tab.h" #include "config.h" -static void -comp_config(fp) - FILE *fp; -{ - register struct file_list *fl; - register struct device *dp; - - fprintf(fp, "\n#include \"dev/cdvar.h\"\n"); - fprintf(fp, "\nstruct cddevice cddevice[] = {\n"); - fprintf(fp, "/*\tunit\tileave\tflags\tdk\tdevs\t\t\t\t*/\n"); - - fl = comp_list; - while (fl) { - if (fl->f_type != COMPDEVICE) { - fl = fl->f_next; - continue; - } - for (dp = dtab; dp != 0; dp = dp->d_next) - if (dp->d_type == DEVICE && - eq(dp->d_name, fl->f_fn) && - dp->d_unit == fl->f_compinfo) - break; - if (dp == 0) - continue; - fprintf(fp, "\t%d,\t%d,\t%d,\t%d,\t{", - dp->d_unit, dp->d_pri < 0 ? 0 : dp->d_pri, - dp->d_flags, 1); - for (fl = fl->f_next; fl->f_type == COMPSPEC; fl = fl->f_next) - fprintf(fp, " 0x%x,", (unsigned) fl->f_compdev); - fprintf(fp, " NODEV },\n"); - } - fprintf(fp, "\t-1,\t0,\t0,\t0,\t{ 0 },\n};\n"); -} - /* * build the ioconf.c file */ @@ -76,38 +42,18 @@ pseudo_ioconf(fp) { register struct device *dp; - (void)fprintf(fp, "\n#include \n\n"); for (dp = dtab; dp != NULL; dp = dp->d_next) if (dp->d_type == PSEUDO_DEVICE) - (void)fprintf(fp, "extern void %sattach __P((int));\n", + fprintf(fp, "extern void %sattach __P((int));\n", dp->d_name); - /* - * XXX concatonated disks are pseudo-devices but appear as DEVICEs - * since they don't adhere to normal pseudo-device conventions - * (i.e. one entry with total count in d_slave). - */ - if (seen_cd) - (void)fprintf(fp, "extern void cdattach __P((int));\n"); - (void)fprintf(fp, "\nstruct pdevinit pdevinit[] = {\n"); + + fprintf(fp, "\nstruct conf_pdev conf_pdinit[] = {\n"); for (dp = dtab; dp != NULL; dp = dp->d_next) if (dp->d_type == PSEUDO_DEVICE) - (void)fprintf(fp, "\t{ %sattach, %d },\n", dp->d_name, + fprintf(fp, " { %sattach, %d },\n", dp->d_name, dp->d_slave > 0 ? dp->d_slave : 1); - /* - * XXX count up cds and put out an entry - */ - if (seen_cd) { - struct file_list *fl; - int cdmax = -1; - for (fl = comp_list; fl != NULL; fl = fl->f_next) - if (fl->f_type == COMPDEVICE && fl->f_compinfo > cdmax) - cdmax = fl->f_compinfo; - (void)fprintf(fp, "\t{ cdattach, %d },\n", cdmax+1); - } - (void)fprintf(fp, "\t{ 0, 0 }\n};\n"); - if (seen_cd) - comp_config(fp); + fprintf(fp, " { 0, 0 }\n};\n"); } static char * @@ -115,7 +61,7 @@ wnum(num) { if (num == QUES || num == UNKNOWN) return ("?"); - (void) sprintf(errbuf, "%d", num); + sprintf(errbuf, "%d", num); return (errbuf); } @@ -142,7 +88,7 @@ void pic32_ioconf() fprintf(fp, "extern struct driver %sdriver;\n", dp->d_name); } fprintf(fp, "\nstruct conf_ctlr conf_cinit[] = {\n"); - fprintf(fp, "/*\tdriver,\t\tunit,\taddr,\t\tpri,\tflags */\n"); + fprintf(fp, " /* driver,\t\tunit,\taddr,\t\tpri,\tflags */\n"); for (dp = dtab; dp != 0; dp = dp->d_next) { if (dp->d_type != CONTROLLER && dp->d_type != MASTER) continue; @@ -154,23 +100,23 @@ void pic32_ioconf() if (dp->d_unit == UNKNOWN || dp->d_unit == QUES) dp->d_unit = 0; fprintf(fp, - "\t{ &%sdriver,\t%d,\tC 0x%08x,\t%d,\t0x%x },\n", + " { &%sdriver,\t%d,\tC 0x%08x,\t%d,\t0x%x },\n", dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri, dp->d_flags); } - fprintf(fp, "\t{ 0 }\n};\n"); + fprintf(fp, " { 0 }\n};\n"); /* print devices connected to other controllers */ fprintf(fp, "\nstruct conf_device conf_dinit[] = {\n"); fprintf(fp, - "/*driver,\tcdriver,\tunit,\tctlr,\tdrive,\tslave,\tdk,\tflags*/\n"); + " /* driver,\t\tctlr driver,\tunit,\tctlr,\tdrive,\tslave,\tdk,\tflags */\n"); for (dp = dtab; dp != 0; dp = dp->d_next) { if (dp->d_type == CONTROLLER || dp->d_type == MASTER || dp->d_type == PSEUDO_DEVICE) continue; mp = dp->d_conn; - fprintf(fp, "{ &%sdriver,\t", dp->d_name); + fprintf(fp, " { &%sdriver,\t", dp->d_name); if (mp) { fprintf(fp, "&%sdriver,\t%d,\t%d,\t", mp->d_name, dp->d_unit, mp->d_unit); @@ -181,8 +127,8 @@ void pic32_ioconf() fprintf(fp, "%d,\t%d,\t%d,\t0x%x },\n", dp->d_drive, dp->d_slave, dp->d_dk, dp->d_flags); } - fprintf(fp, "{ 0 }\n};\n"); + fprintf(fp, " { 0 }\n};\n"); pseudo_ioconf(fp); - (void) fclose(fp); + fclose(fp); } #endif diff --git a/tools/kconfig/mkswapconf.c b/tools/kconfig/mkswapconf.c index c7cfefd..e680528 100644 --- a/tools/kconfig/mkswapconf.c +++ b/tools/kconfig/mkswapconf.c @@ -87,15 +87,17 @@ do_swap(fl) fclose(fp); return (swap); } - fprintf(fp, "dev_t\trootdev = makedev(%d, %d);\n", - major(fl->f_rootdev), minor(fl->f_rootdev)); - fprintf(fp, "dev_t\tdumpdev = makedev(%d, %d);\n", - major(fl->f_dumpdev), minor(fl->f_dumpdev)); + fprintf(fp, "dev_t\trootdev = makedev(%d, %d);\t/* %s */\n", + major(fl->f_rootdev), minor(fl->f_rootdev), + devtoname(fl->f_rootdev)); + fprintf(fp, "dev_t\tdumpdev = makedev(%d, %d);\t/* %s */\n", + major(fl->f_dumpdev), minor(fl->f_dumpdev), + devtoname(fl->f_dumpdev)); fprintf(fp, "\n"); fprintf(fp, "struct\tswdevt swdevt[] = {\n"); do { dev = swap->f_swapdev; - fprintf(fp, "\t{ makedev(%d, %d),\t%d,\t%d },\t/* %s */\n", + fprintf(fp, "\t{ makedev(%d, %d), %d, %d },\t/* %s */\n", major(dev), minor(dev), swap->f_swapflag, swap->f_swapsize, swap->f_fn); swap = swap->f_next; @@ -148,10 +150,9 @@ void initdevtable() * terms of major/minor instead of string names. */ dev_t -nametodev(name, defunit, defpartition) +nametodev(name, defunit) char *name; int defunit; - char defpartition; { char *cp, partition; int unit; @@ -176,11 +177,11 @@ nametodev(name, defunit, defpartition) while (*cp && isdigit(*cp)) cp++; } - partition = *cp ? *cp : defpartition; - if (partition < 'a' || partition > 'h') { + partition = *cp ? *cp : '`'; + if (partition < '`' || partition > 'd') { fprintf(stderr, "config: %c: invalid device specification, bad partition\n", *cp); - partition = defpartition; /* carry on */ + partition = 'a'; /* carry on */ } if (devtablenotread) initdevtable(); @@ -191,7 +192,7 @@ nametodev(name, defunit, defpartition) fprintf(stderr, "config: %s: unknown device\n", name); return (NODEV); } - return (makedev(dp->dev_major, (unit << 3) + (partition - 'a'))); + return (makedev(dp->dev_major, (unit << 3) + (partition - '`'))); } char * @@ -208,7 +209,11 @@ devtoname(dev) break; if (dp == 0) dp = devtable; - (void) sprintf(buf, "%s%d%c", dp->dev_name, - minor(dev) >> 3, (minor(dev) & 07) + 'a'); + + if (minor(dev) == 0) + sprintf(buf, "%s%d", dp->dev_name, minor(dev) >> 3); + else + sprintf(buf, "%s%d%c", dp->dev_name, minor(dev) >> 3, + (minor(dev) & 07) + 'a' - 1); return strdup(buf); }