Subject: Re: /sys/doc/options.doc
To: Julian Howard Stacey <>
From: Luke Mewburn <>
List: current-users
Date: 07/28/1994 10:41:28
> I suggest NetBSD might like to adopt something like
> FreeBSD's /sys/doc/options.doc (by Garrett A. Wollman)
> While referencing my NetBSD-pc532 options (FASTLINKS etc),
> I had to fall back to my i486-Freebsd /sys/doc/options.doc
> Luckily I have both BSDs, but some pc532 owners (& other NetBSD users) dont,
> so those folk might appreciate /sys/doc/options.doc.

Whilst trying to keep uptodate with such options, I wrote the
following (pretty crud, I admit) perl script which you run on a config
file and it tells you what each option does.

For options that it doesn't know about, or that have been made obsolete,
it will tell you.  It doesn't check the validity of devices right now,
and I've only setup the arrays for the i386 port, but it's a start that
you could use.

--- cut here --- file: unix/netbsd/checkconf
# checkconf --
#	check the validity of netbsd kernel config files
# Version 1.4, 940716. Luke Mewburn <>
#   940518	simplistic script first whipped up
#   940521	cleaned up output, updated tables, enhanced device checking.
#   940522	tagged maxfdescs as obsolete
#   940705	ISOFS is obsolete, use CD9660. added le0.
#   940716	fixed up handling of whitespace between options

#	constants
$MAX_COLS = 80;

%machines = (
    'i386',		'Intel 386 or higher',

%cpus = (
    'I386_CPU',	'80386',
    'I486_CPU',	'i486',
    'I586_CPU',	'pentium',

%options = (
    'MATH_EMULATE',	'floating point emulation',
    'DUMMY_NOPS',	'make the kernel a little faster; will break on some machines',
    'MACHINE_NONCONTIG','temporary kluge while adding support for non-contiguous physical memory',
    'SWAPPAGER',	'paging of processes; REQUIRED',
    'VNODEPAGER',	'caching of vnodes; REQUIRED',
    'DEVPAGER',		'caching of devices; REQUIRED',
    'DIAGNOSTIC',	'kernel diagnostics',
    'KTRACE',		'system call tracing, a la ktrace(1)',
    'FASTLINKS',	'store short symlinks in the inode instead of the filesystem',
    'FIFO',		'FIFOs',
    'SYSVMSG',		'System V-like message queues',
    'SYSVSEM',		'System V-like semaphores',
    'SYSVSHM',		'System V-like memory sharing',
    'SHMMAXPGS',	'maximum pages for SYSVSHM, default = 1024 pages',
    'SCSI',		'generic SCSI system',
    'FFS',		'UFS',
    'LKM',		'loadable kernel modules',
    'XSERVER',		'machine is an X server',
    'UCONSOLE',		'use console as X server',
    'QUOTA',		'quotas in UFS',
    'MFS',		'memory file system (shares memory and swap space)',
    'NFSSERVER',	'Sun\'s Network File System - server',
    'NFSCLIENT',	'Sun\'s Network File System - client',
    'ISOFS',		'ISO 9660 file system, with Rock Ridge [OBSOLETE]',
    'CD9660',		'ISO 9660 file system, with Rock Ridge',
    'MSDOSFS',		'MS-DOS file system',
    'LOFS',		'loopback filesystem [OBSOLETE]',
    'NULLFS',		'null filesystem (incorporates lofs)',
    'PORTAL',		'portal filesystem',
    'PROCFS',		'proc filesystem',
    'FDESC',		'/dev/fd',
    'KERNFS',		'kernel file system',
    'IMP',		'XXX: some network protocol',
    'INET',		'internet domain sockets',
    'NS',		'xerox ns protocol',
    'ISO',		'OSI',
    'TPIP',		'XXX: some network protocol',
    'EON',		'XXX: some network protocol',
    'CCITT',		'x.25',
    'HDLC',		'x.25 hdlc (needed by CCITT)',
    'LLC',		'x.25 llc (needed by CCITT)',
    'GATEWAY',		'packet forwarding',
    'MULTICAST',	'multicast networking',
    'MROUTING',		'multicast routing',
    'DDB',		'kernel debugger',
    'USER_LDT',		'user creatable i386 LDTs (for Wine Windows wemulator)',
    'COMPAT_NOMID',	'NetBSD 0.8 compatibility (executable format?)',
    'COMPAT_09',	'NetBSD 0.9 compatibility',
    'COMPAT_43',	'BSD 4.3 compatibility',
    'TCP_COMPAT_42',	'BSD 4.2 TCP/IP compatibility',
    'SBPRO',		'SoundBlaster Pro',
    'SETUIDSCRIPTS',	'Allow safe SetUID scripts',
    'FDSCRIPTS',	'Allow execute-only scripts',

# devices (master, controller, device, disk, and tape entries)
%devices = (
    'isa0',	'PC clone ISA bus',
    'wdc0',	'PC ST506/IDE controller',
    'wd0',	'PC ST506/IDE disk 0',
    'wd1',	'PC ST506/IDE disk 1',
    'fdc0',	'PC floppy controller',
    'fd0',	'PC floppy drive 0',
    'fd1',	'PC floppy drive 1',
    'aha0',	'Adaptec 154x ISA SCSI controller',
    'ahb0',	'Adaptec 174x EISA SCSI controller',
    'bt0',	'BusLogic 742 SCSI controller',
    'uha0',	'UltraStor 14f SCSI controller',
    'sea0',	'unknown Seagate SCSI controller',
    'aic0',	'Adaptec 6360 EISA SCSI controller???',
    'scsibus0',	'SCSI bus 0',
    'scsibus1',	'SCSI bus 1',
    'scsibus2',	'SCSI bus 2',
    'scsibus3',	'SCSI bus 3',
    'pc0',	'pccons console driver for PC keyboard & monitor',
    'vt0',	'pcvt virtual multi-console driver PC keyboard & monitor',
    'ast0',	'4 port serial card',
    'com0',	'serial port 0',
    'com1',	'serial port 1',
    'com2',	'serial port 2',
    'com3',	'serial port 3',
    'com4',	'serial port 4',
    'lpt0',	'parallel port 0',
    'lpt1',	'parallel port 1',
    'lpt2',	'parallel port 2',
    'mms0',	'microsoft InPort bus mouse',
    'lms0',	'logitech mouse',
    'pms0',	'PS/2 auxiliary port',
    'wt0',	'non-scsi tape drive',
    'mcd0',	'mitsumi non-scsi CDROM',
    'sb0',	'sound blaster',
    'ed0',	'wd 80x3, 3com 3c503, ne[12]k ethernet',
    'ed1',	'wd 80x3, 3com 3c503, ne[12]k ethernet #2',
    'ed2',	'wd 80x3, 3com 3c503, ne[12]k ethernet #3',
    'hp0',	'hp ISA ethernet',
    'is0',	'isolan ethernet',
    'ie0',	'intel 82586 ethernet',
    'le0',	'lance ethernet',
    'ep0',	'3com 3c579? ethernet',
    'ep1',	'3com 3c579? ethernet #2',
    'ep2',	'3com 3c579? ethernet #3',
    'npx0',	'80x87 numeric co-processor',
    'sd0',	'SCSI disk 0',
    'sd1',	'SCSI disk 1',
    'sd2',	'SCSI disk 2',
    'sd3',	'SCSI disk 3',
    'sd4',	'SCSI disk 4',
    'sd5',	'SCSI disk 5',
    'sd6',	'SCSI disk 6',
    'st0',	'SCSI tape 0',
    'st1',	'SCSI tape 1',
    'st2',	'SCSI tape 2',
    'cd0',	'SCSI CDROM 0',
    'cd1',	'SCSI CDROM 1',
    'ch0',	'SCSI tape changer 0',
    'ch1',	'SCSI tape changer 1',

%pseudo_devices = (
    'pty',	'pseudo terminals',
    'loop',	'loopback inet interface',
    'ether',	'ethernet; REQUIRED for any ethernet device',
    'log',	'kernel gateway into syslogd',
    'bpfilter',	'berkeley packet filter',
    'sl',	'compressed SLIP',
    'ppp',	'point-to-point protocol',
    'vn',	'vn virtual filesystem device',
    'speaker',	'speaker queue',
    'tb',	'tablet line discipline',
    'tun',	'XXX: unknown',
    'audio',	'/dev/audio',

#	changable entries

%geninfo = ();
@cpuinfo = ();
%optinfo = ();
%devinfo = ();
%pdevinfo = ();

#	slurp in the file
while (<>)
    next if $_ eq "";		# skip blank lines
    next if /^#/;		# skip full comment lines
    s/#.*//;			# remove extra comments
    local($cmd, $arg, @rest) = split;
    $arg =~ s/"//g;		# remove quotes
	$cmd eq "machine" && do
	    print "machine already specified as $geninfo{'machine'}\n"
		    if defined($geninfo{'machine'});
	    $geninfo{'machine'} = $machines{$arg} || ($arg . " [UNDEFINED]");
	    last ENTRY;
	$cmd eq "cpu" && do
	    push(@cpuinfo, $cpus{$arg} || ($arg . " [UNDEFINED]"));
	    last ENTRY;
	$cmd eq "ident" && do
	    print "ident already specified as $geninfo{'ident'}\n"
		    if defined($geninfo{'ident'});
	    $geninfo{'ident'} = $arg;
	    last ENTRY;
	$cmd eq "maxusers" && do
	    print "maxusers already specified as $geninfo{'maxusers'}\n"
		    if defined($geninfo{'maxusers'});
	    $geninfo{'maxusers'} = $arg;
	    last ENTRY;
	$cmd eq "maxfdescs" && do
	    print "maxfdescs already specified as $geninfo{'maxfdescs'}\n"
		    if defined($geninfo{'maxfdescs'});
	    print "maxfdescs has been obsoleted. Please remove it from your config file.\n";
	    $geninfo{'maxfdescs'} = $arg;
	    last ENTRY;
	$cmd eq "timezone" && do			# XXX: improve
	    $geninfo{'timezone'} = $arg . ' ' . join(' ',@rest);
	    last ENTRY;
	$cmd eq "options" && do
	    $arg .= join(' ',@rest);	# add in any options that had whitespace
	    $arg =~ s/\s+//g;		# remove whitespace
	    local(@opts) = split(',', $arg);
	    foreach $option (@opts)
		local($argname, $argval) = split('=', $option);
		$argval = " = " . $argval if (defined($argval));
		$optinfo{$argname} = $argval;
	    last ENTRY;
	$cmd eq "config" && do				# XXX: improve
	    print "config already specified as $geninfo{'config'}\n"
		    if defined($geninfo{'config'});
	    $geninfo{'config'} = $arg . ' ' . join(' ',@rest);
	    last ENTRY;
	$cmd =~ /^(master|controller|device|disk|tape)$/ && do
	    $devinfo{$arg} = join(' ', @rest);
	    last ENTRY;
	$cmd eq "pseudo-device" && do
	    local($val) = " = " . $rest[0] if (defined($rest[0]));
	    $pdevinfo{$arg} = $val;
	    last ENTRY;
	print "Unknown directive: $cmd\n";
    } # ENTRY
} # while

#	print the config file's innermost secrets :)

grep ((do {$geninfo{$_} = "undefined" unless defined($geninfo{$_})} ),
	('machine', 'ident', 'maxusers', 'timezone', 'config'));
$cpuinfo = join(' ', @cpuinfo);

print <<GENINFO;
Machine:	$geninfo{'machine'}
Cpus:		$cpuinfo
Ident:		$geninfo{'ident'}
Config:		$geninfo{'config'}
Max Users:	$geninfo{'maxusers'}

print "\nOptions:\n--------\n";
foreach $opt (sort keys %optinfo)
    &print_block($opt . $optinfo{$opt}, 24, $options{$opt} || " [UNDEFINED]");

print "\nDevices:\n--------\n";
foreach $dev (sort keys %devinfo)
    &print_block($dev, 24, $devices{$dev} || " [UNDEFINED]");

print "\nPseudo devices:\n---------------\n";
foreach $pdev (sort keys %pdevinfo)
    &print_block($pdev . $pdevinfo{$pdev}, 24,
   		 $pseudo_devices{$pdev} || " [UNDEFINED]");

exit 0;

# print_block --
#	display info in the form:
#  v---------$MAX_COLS------------------v
#  v--$offset--v  
#  $tag           $lines
#	($lines may cross multiple lines. $tag is printed for 1st line only)

    local($tag, $offset, $lines) = @_;
    local($width) = $MAX_COLS - $offset - 2;
    local($indent) = '@' . '<' x ($offset - 1);
    local($para) = '^' . '<' x ($width - 1);
    local($form) = <<"EOFORM";
format STDOUT =
$indent $para
\$tag,  \$lines
    eval $form;
    $tag = "";
    write while ($lines);
} # print_block
--- cut here ---

"When I left the monastery, it was not in pursuit of scholarship,
however, but in pursuit of an unparalleled career in crime.
It was quite a shock for me to discover that crime was so easy    Luke Mewburn
that it was boring.  [ ...  ] Solving crime, I had belatedly    <>
discovered, was at least a hundred times more difficult than
committing it, so I hung the sign of a half-closed eye above
my door and I have never regretted it."
	-- Li Kao, in Barry Hughart's "Bridge of Birds".