*BSD News Article 61012


Return to BSD News archive

Newsgroups: comp.bugs.2bsd
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.cs.su.oz.au!inferno.mpx.com.au!news.unimelb.EDU.AU!munnari.OZ.AU!news.hawaii.edu!ames!usenet.kornet.nm.kr!news.kreonet.re.kr!usenet.seri.re.kr!news.cais.net!ringer.cs.utsa.edu!swrinde!cssun.mathcs.emory.edu!gatech!news.mathworks.com!uunet!in2.uu.net!news.new-york.net!wlbr!sms
From: sms@wlv.iipo.gtegsc.com (Steven M. Schultz)
Subject: mount(8) options, !/etc/mtab, libkern.a, MANY others (#292 part 1 of 8)
Sender: news@wlbr.iipo.gtegsc.com (Steven M. Schultz)
Organization: GTE Government Systems, Thousand Oaks CA USA
Message-ID: <DM4rMv.Lw0@wlbr.iipo.gtegsc.com>
X-Nntp-Posting-Host: wlv.iipo.gtegsc.com
Date: Fri, 2 Feb 1996 04:11:19 GMT
Lines: 565

Subject: mount(8) options, !/etc/mtab, libkern.a, MANY others (#292 part 1 of 8)
Index:	many/many 2.11BSD

Description:
	Mount(8) does not pass options other than 'readonly' thru to the
	kernel even though the kernel understands many more options than
	that.

	/etc/mtab is not needed any longer because applications (mount, umount,
	others) can obtain the list of mounted filesystems via getmntinfo(3),
	or getfsstat(2)

	There are copies of 15 libc routines in the kernel directories.  These
	are invariant but nevertheless are always being recompiled/assembled
	whenever a kernel is built.

Repeat-By:
	It sounds inadequate, but, "observation".  Read on for a tale of
	how this all started from a "simple" observation...

Fix:
	This is #292 (part 1 of 8).

	The remaining parts will not contain the following description
	but will instead merely say "refer to part 1 (#292)".

	Before beginning the detailed installation instructions a "brief"
	narrative describing what is changing and why/how the update kit
	grew to be so large.

	There were two 'simple' (ha!) goals which rapidly snowballed into
	a monster update kit:

	1) Add support the 'mount options' to mount(8) for which kernel 
	   support already exists (MNT_NOEXEC, MNT_NOSUID, MNT_NODEV) but for 
	   which the current version of mount/umount did not know how to handle.

	2) Create a 'libkern.a' into which "static" modules of the kernel
	   could be placed thus saving the need to recompile or assemble them
	   each time a kernel was made.  These routines are copies of libc.a
	   routines which need to be compiled slightly differently (in a couple
	   cases) but which do not change except under extremely bizarre
	   circumstances.

	From those two, seemingly simple, goals grew an 8 part update
	kit which will affect (at last count) 159 files in the system!  How'd
	this happen?

	Well, the new (4.4-Lite) "mount" program needed the new fstab(5)
	file format in order to handle the additional options. 

	The new fstab(5) file required a new routine to scan it, thus the
	4.4 version of fstab(3) (which contains the routines getfsent() and
	so on) had to be ported.

	The new fstab(3) routine used 'strsep(3)' to scan strings.   The
	4.4 version of strsep(3) has a different calling convention than the
	old version of strsep() currently in 2.11BSD. 

	At this point it was decided to call a halt to the (evil) practice
	of "private copies" of routines which properly belong in libc.a.  In
	the past a local/private 'strsep.c' was placed in individual utilities
	as they were ported.

	As you can see the list is growing quickly.  Now it was necessary
	to modify all files in the system which referenced 'strsep'.  Luckily
	there were only 8 or 9 of them.

	As the port of mount, umount crept along it was noticed that 'strstr(3)'
	was needed.  OK, enough is enough - grab the whole (or most of) 
	4.4's libc/string directory and do it all at once.  At the same time
	a new version of getopt(3) was ported since 'mount' required that too!

	And of course there were corresponding manpages to be translated and
	ported along with the .c files...

	Once mount(8) and umount(8) were ported and running the /etc/mtab
	file is no longer needed, right?  Well... wrong.  The quota related
	programs such as 'quotaoff(8)/quotaon' and 'quotacheck(8)' use 
	/etc/mtab to determine if a filesystem was mounted with quotas or
	not.

	Sigh - this is getting old.  To make a long story somewhat short
	all the quota related programs:  quotacheck, qutoaon, repquota, 
	and edquota were ported from 4.4-Lite.  This had the pleasant 
	side effect of removing any dependence on NMOUNT as a compile time
	constant.

	To aid in the porting process several new #include files were
	ported or enhanced.

	The System-V string compatibility part of libc.a has been reduced
	to almost nothing as a result of removing obsolete routines and
	porting part of 'libc/stdlib' and most of 'libc/string' from 4.4-Lite.

	You may notice that a large number of Makefiles are update in the
	patches which follow.  This is because after the drastic changes
	to libc.a the entire system was built from source and it was noticed
	that quite a few Makefiles did not create the formatted manpages
	during the "make build" phase but instead waited until the "make
	install" was done.  This felt "wrong" - the manpages should have
	been created at the same time as the executables!  In addition to
	that problem a number of Makefiles recompiled the sources when
	doing a 'make install' (believe it or not).  This greatly lengthened
	the amount of time taken to do the "make install" and those Makefiles
	have been fixed.

	And now for what turned out to be the shortest part of the entire
	project:  libkern.a.  This went very smoothly and quickly.  The
	directory "/usr/src/lib/libkern" was created and populated with
	only a Makefile.  The Makefile uses the VPATH capability of 'make'
	to reference the sources where they reside in the libc directories.
	The library libkern.a resides in /usr/lib and need only be created
	ONCE - all kernels use it now (the kernel Make.* files have been
	modified to reflect this).

	DESCRIPTION Of Contents
	=======================

	The update kit is composed of 8 parts, #292 thru #299 inclusive.

	#	Part	Contents
	----	----	--------
	292	1	Description of "problem", introduction, and the script
			which removes (or renames) existing files from (within)
			the system.

	293	2	The first of three shar files containing new files
			being added to the system.

	294	3	The second of three shar files containing new files
			being added to the system.

	295	4	The third of three shar files containing new files
			being added to the system.

	296	5	The first of four patch files used to update files 
			in the system.

	297	6	The second of four patch files used to update files
			in the system.

	298	7	The third of four patch files used to udpate files
			in the system.
		
	299	8	The fourth of four patch files used to update files
			in the system.

	DIRECTIONS For Kit Installation
	-------------------------------

	Make sure you have all 8 parts (#292 thru 299 inclusive).

	Have a copy of this part (#292) printed out if possible starting
	at the 'DESCRIPTION' line above, but at least starting from
	'DIRECTIONS'.

	Make *copies* (saving the originals in a safe place) of all 8 parts
	in /tmp and then _cut_ where indicated (remove everything down to
	and including the "-----cut here-----" line).

	At this point you should have, in /tmp, the files: 292, 293, 294, 295,
	296, 297, 298 and 299.

	Change into the /tmp directory:

		cd /tmp

	Unpack part #1:

		sh 292

	This produces two shell scripts:  'remove' and 'rename'.  You will
	execute ONE of them.  If you have current backups or otherwise don't
	care to keep old files around then you will want to run 'remove'.
	If you prefer to rename files rather than removing them you will
	execute 'rename'.  

		./remove

	OR

		./rename

	A bit of cleanup:

		rm 292 remove rename

	Install all of the new files into the system:

		sh 293
		sh 294
		sh 295

	Some cleanup:

		rm 293 294 295

	Apply the patches.  NOTE:  Don't worry too much if games/warp/Makefile
	gives an error or if one or two of the Makefile patches fail but only
	in the 'dependency' areas - you can later run "make depend" in those
	directories.

		patch -p0 < 296
		patch -p0 < 297
		patch -p0 < 298
		patch -p0 < 299

	And a bit of cleanup:

		rm 296 297 298 299

	NOTE:  Some of the Makefiles which have just been updated are in
	       the kernel.  You will need to copy/update the Make.pdp file
	       and Makefile in each of the kernel config directories.  The
	       GENERIC kernel has been done for you when the patches were
	       applied.

	Now the C library _must_ be rebuilt.  This will take about an hour
	and a half.  After this a fairly large number of utilities have to
	be rebuilt.  If you are so inclined and have about a day (a 24 hour
	day, not an 8 hour working day ;-)) you may want to rebuild the 
	entire system using "cd /usr/src; make; make install".  That is what
	I did, but it is arguably overkill.   If you do not want to rebuild
	the entire system then:

		cd /usr/src/lib/libc
		make clean
		make
		make install

	The kernel library (libkern.a) is now created.  This is only done
	once (or whever a complete 'make' is done from /usr/src):

		cd /usr/src/lib/libkern
		make
		make install
		make clean

	Next the various programs are rebuilt.  The following should be
	suitable for inclusion in a 'csh' script:

		cd /usr/src/usr.bin/lint
		./libs
		cd /usr/src/bin
		make ar chflags df login ls mail passwd sysctl
		foreach dir (ar chflags login ls mail passwd sysctl)
			(cd $dir; make install; make clean)
		end
		install -m 2755 -s -g operator df /bin/df
	
		cd /usr/src/bin
		make chroot edquota mkpasswd mount ping quotacheck quotaon
		make repquota syslogd umount vipw
		make dump fsck
		foreach dir (chroot mkpasswd mount ping quotacheck umount 
				fsck dump vipw)
			(cd $dir; make install; make clean)
		end
		
	NOTE:  'dump' and 'fsck' were not modified but both of them use
		'getfsent(3)' which _has_ been updated in libc.a.

		install -m 755 -o bin -g bin -s edquota quotaon repquota /etc
		install -m 755 -o bin -g bin -s fsck dump syslogd /etc
		rm -f /etc/quotaoff
		ln /etc/quotaon /etc/quotaoff

		cd /usr/src/ucb
		make Mail finger quota
		(cd Mail; make install; make clean)
		(cd /usr/src/ucb/finger; make install; make clean)
		install -s -m 4755 -o root quota /usr/ucb/quota

	Now the man pages need to be done.  Only 1 page in chapter 2 was
	updated so it can be done manually:

		cd /usr/src/man/man2
		/usr/man/manroff mount.2 > /usr/man/cat2/mount.0

	There were many additions and deletions in chapter 3 so it is
	a "good idea" to simply remake the entire chapter:

		cd /usr/src/man/man3
		make
		make install
		make clean

	Many of the device manpages in chapter 4 were updated too.  There
	are not very many of them so it is easiest to simply reformat all
	of the chapter:

		cd /usr/src/man/man4
		make
		make install
		make clean

	Only 2 manpages were updated in chapter 5:

		cd /usr/src/man/man5
		/usr/man/manroff fs.5 > /usr/man/cat5/fs.0
		/usr/man/manroff fstab.5 > /usr/man/cat5/fstab.0

	Only 1 manpage was changed in chapter 8:

		cd /usr/src/man/man8
		/usr/man/manroff quotaon.8 > /usr/man/cat8/quotaon.0


	In the kernel only the various Make files were changed - there were
	no other modifications. 

	The GENERIC kernel Makefile and Make.pdp are updated when the patches
	are applied.  Other kernel config/build directories will need to
	be updated locally.  There are two ways to do this:

		1) Simply remove the existing "/sys/YOUR_KERNEL" directory
		   and reconfigure (cd /sys/conf; ./config YOUR_KERNEL) the
		   kernel.  This has the advantage of being simple but you
		   will likely find it necessary to readjust the overlay
		   setup.

		2) Into each kernel build directory copy the Make.pdp and
		   Make.pdpnet files from the conf/ directory:

			cd /sys/conf
			foreach dir ( ../YOUR_KERNEL ../PICKLE ...)
			   cp Make.pdp ../${dir}
			   cp Make.pdpnet ../${dir}
			end

	NOTE:  the Make.pdpnet file only needs to be copied for Networking
	       kernels. 

		   Then update the Makefile in each kernel build directory.

		   Look in #299  for the part of the patch which updates
		   Make.nsunix and/or Make.sunix and apply that to the Makefile
		   in each kernel build directory.

	Lastly one module in the standalone utilities was updated.  There
	were a couple missing casts to '(long)' in the standalone disklabel
	program.  Entering a partition size in "cylinders" would cause the 
	partition size to be miscalculated.

	Eventually it would be a very good idea to recreate any emergency
	boot media (floppies, tapes) with the new version of the standalone
	disklabel.  

		cd /sys/pdpstand
		make
		(update boot media)

	It is a good idea (but not 100% necessary) at this point to rebuild 
	and install a new kernel.  This will make sure that the Makefiles 
	have been correctly updated _and_ the networking image will be 
	slightly smaller.  It turns out that extra object modules were being 
	included unnecessarily.  Using 'libkern.a' allows the linker to 
	bypass them.

	In any case the system should now be rebooted, but not fastboot'd.
	This is a good time to allow fsck to check things out before
	using the new 'mount' program.

	You may want to clean up now by:

		cd /usr/src
		make clean

	There are also all the "*~" files created by the patching - you may
	want to reclaim the disk space by finding "*~" and removing them:

		find / -name '*~' -print > /tmp/tilde
		(review the list and edit it if you do not want to delete
		 a particular ~ file)
		rm `cat /tmp'tilde`

	You may now remove the 'mtab' file since it is no longer used:

		rm /etc/mtab

	Congratulations - you're done!  If you wish to change /etc/fstab
	to the new format (whitespace separated fields instead of colon (:)
	separated ones) feel free to do so - the updated man pages should
	provide all the necessary information.  For example, instead of

		/dev/ra0e:/usr:rw:1:3

	you can use:

		/dev/ra0e  /usr  ufs  rw  1  3

	if you desire to prevent special (device) nodes from being used on
	a filesystem then:

		/dev/ra0e  /usr  ufs  rw,nodev  1  3

	will do what you want.

	Quotas handling is slightly different (the old method of using 'rq'
	is permitted but deprecated):

		/dev/ra0f:/userfiles:rq:1:4

	will work.  The new method would be:

		/dev/ra0f  /userfiles  ufs  rw,quotas  1  4

	The ability to define entries in /etc/fstab but NOT have them used
	when the system boots (and performs "mount -a") is supported.  The
	"na" (no auto) option:

		/dev/ra8c  /mnt  ufs rw,na  1  4

	will permit you to later on, after the system is up, do a 

		mount /mnt

	but the system will not automatically mount 'ra8c' when the system
	enters the multiuser state.

	YET another benefit of all the work done above is the ability to
	"umount" using the directory name!

	Previously the "umount" program insisted on being given the special
	device name.  I.e.  You could:

		umount /dev/ra0e

	but you could not simply say:

		umount /userfiles

	The new 'umount' corrects that shortcoming.

	Oh - the old version of 'quotacheck' miscalculated quotas slightly.  
	It would calculate a different number of total inodes on the filesystem
	than the kernel said were there.

	The new version of quotacheck(8) agrees with the kernel on the number
	of inodes in the filesystem and as a result the quotas calculated
	for each user are accurate now.

		THE END

------------------------cut here-----------------------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	/tmp/remove
#	/tmp/rename
# This archive created: Tue Jan 30 21:47:15 1996
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f '/tmp/remove'
then
	echo shar: "will not over-write existing file '/tmp/remove'"
else
sed 's/^X//' << \SHAR_EOF > '/tmp/remove'
X#!/bin/sh
X
X# rm -f /etc/mtab
Xrm -f /usr/include/fstab.h
Xrm -f /usr/include/strings.h
Xrm -f /usr/man/cat5/mtab.0
Xrm -f /usr/src/bin/ls/strsep.c
Xrm -f /usr/src/etc/mount.c
Xrm -f /usr/src/etc/quotacheck.c
Xrm -f /usr/src/etc/umount.c
Xrm -f /usr/src/etc/edquota.c
Xrm -f /usr/src/etc/quotaon.c
Xrm -f /usr/src/etc/repquota.c
Xrm -f /usr/src/lib/libc/gen/fstab.c
Xrm -f /usr/src/lib/libc/compat-sys5/getopt.c
Xrm -f /usr/src/lib/libc/compat-sys5/strcatn.c
Xrm -f /usr/src/lib/libc/compat-sys5/strcmpn.c
Xrm -f /usr/src/lib/libc/compat-sys5/strcpyn.c
Xrm -f /usr/src/lib/libc/compat-sys5/strcspn.c
Xrm -f /usr/src/lib/libc/compat-sys5/strpbrk.c
Xrm -f /usr/src/lib/libc/compat-sys5/strspn.c
Xrm -f /usr/src/lib/libc/compat-sys5/strtok.c
Xrm -f /usr/src/lib/libc/compat-sys5/strtol.c
Xrm -f /usr/src/man/man5/fstab.5
Xrm -f /usr/src/man/man3/getopt.3
Xrm -f /usr/src/man/man3/strtok.3
Xrm -f /usr/src/man/man5/mtab.5
Xrm -f /usr/src/man/man8/mount.8
Xrm -f /usr/src/man/man8/quotaon.8
Xrm -f /usr/src/man/man8/quotacheck.8
Xrm -f /usr/src/new/shar/getopt.c
Xrm -f /usr/src/sys/pdp/libc_bcmp.s
Xrm -f /usr/src/sys/pdp/libc_bcopy.s
Xrm -f /usr/src/sys/pdp/libc_bzero.s
Xrm -f /usr/src/sys/pdp/libc_ffs.s
Xrm -f /usr/src/sys/pdp/libc_htonl.s
Xrm -f /usr/src/sys/pdp/libc_htons.s
Xrm -f /usr/src/sys/pdp/libc_insque.s
Xrm -f /usr/src/sys/pdp/libc_ldiv.s
Xrm -f /usr/src/sys/pdp/libc_lmul.s
Xrm -f /usr/src/sys/pdp/libc_lrem.s
Xrm -f /usr/src/sys/pdp/libc_remque.s
Xrm -f /usr/src/sys/pdp/libc_strlen.s
Xrm -f /usr/src/sys/pdp/libc_udiv.s
Xrm -f /usr/src/sys/pdp/libc_uldiv.s
Xrm -f /usr/src/sys/pdp/libc_ulsh.s
SHAR_EOF
chmod 755 '/tmp/remove'
fi
if test -f '/tmp/rename'
then
	echo shar: "will not over-write existing file '/tmp/rename'"
else
sed 's/^X//' << \SHAR_EOF > '/tmp/rename'
X#!/bin/sh
X
X# mv -f /etc/mtab  /etc/mtab~
Xmv -f /usr/include/fstab.h  /usr/include/fstab.h~
Xmv -f /usr/include/strings.h  /usr/include/strings.h~
Xmv -f /usr/man/cat5/mtab.0  /usr/man/cat5/mtab.0~
Xmv -f /usr/src/bin/ls/strsep.c  /usr/src/bin/ls/strsep.c~
Xmv -f /usr/src/etc/mount.c  /usr/src/etc/mount.c~
Xmv -f /usr/src/etc/quotacheck.c  /usr/src/etc/quotacheck.c~
Xmv -f /usr/src/etc/edquota.c  /usr/src/etc/edquota.c~
Xmv -f /usr/src/etc/quotaon.c  /usr/src/etc/quotaon.c~
Xmv -f /usr/src/etc/repquota.c /usr/src/etc/repquota.c~
Xmv -f /usr/src/etc/umount.c  /usr/src/etc/umount.c~
Xmv -f /usr/src/lib/libc/gen/fstab.c /usr/src/lib/libc/gen/fstab.c~
Xmv -f /usr/src/lib/libc/compat-sys5/getopt.c  /usr/src/lib/libc/compat-sys5/getopt.c~
Xmv -f /usr/src/lib/libc/compat-sys5/strcatn.c  /usr/src/lib/libc/compat-sys5/strcatn.c~
Xmv -f /usr/src/lib/libc/compat-sys5/strcmpn.c  /usr/src/lib/libc/compat-sys5/strcmpn.c~
Xmv -f /usr/src/lib/libc/compat-sys5/strcpyn.c  /usr/src/lib/libc/compat-sys5/strcpyn.c~
Xmv -f /usr/src/lib/libc/compat-sys5/strcspn.c  /usr/src/lib/libc/compat-sys5/strcspn.c~
Xmv -f /usr/src/lib/libc/compat-sys5/strpbrk.c  /usr/src/lib/libc/compat-sys5/strpbrk.c~
Xmv -f /usr/src/lib/libc/compat-sys5/strspn.c  /usr/src/lib/libc/compat-sys5/strspn.c~
Xmv -f /usr/src/lib/libc/compat-sys5/strtok.c  /usr/src/lib/libc/compat-sys5/strtok.c~
Xmv -f /usr/src/lib/libc/compat-sys5/strtol.c  /usr/src/lib/libc/compat-sys5/strtol.c~
Xmv -f  /usr/src/man/man5/fstab.5  /usr/src/man/man5/fstab.5~
Xmv -f /usr/src/man/man3/getopt.3  /usr/src/man/man3/getopt.3~
Xmv -f /usr/src/man/man3/strtok.3  /usr/src/man/man3/strtok.3~
Xmv -f /usr/src/man/man5/mtab.5  /usr/src/man/man5/mtab.5~
Xmv -f /usr/src/man/man8/mount.8  /usr/src/man/man8/mount.8~
Xmv -f /usr/src/man/man8/quotaon.8  /usr/src/man/man8/quotaon.8~
Xmv -f /usr/src/man/man8/quotacheck.8  /usr/src/man/man8/quotacheck.8~
Xmv -f /usr/src/new/shar/getopt.c  /usr/src/new/shar/getopt.c~
Xmv -f /usr/src/sys/pdp/libc_bcmp.s  /usr/src/sys/pdp/libc_bcmp.s~
Xmv -f /usr/src/sys/pdp/libc_bcopy.s  /usr/src/sys/pdp/libc_bcopy.s~
Xmv -f /usr/src/sys/pdp/libc_bzero.s  /usr/src/sys/pdp/libc_bzero.s~
Xmv -f /usr/src/sys/pdp/libc_ffs.s  /usr/src/sys/pdp/libc_ffs.s~
Xmv -f /usr/src/sys/pdp/libc_htonl.s  /usr/src/sys/pdp/libc_htonl.s~
Xmv -f /usr/src/sys/pdp/libc_htons.s  /usr/src/sys/pdp/libc_htons.s~
Xmv -f /usr/src/sys/pdp/libc_insque.s  /usr/src/sys/pdp/libc_insque.s~
Xmv -f /usr/src/sys/pdp/libc_ldiv.s  /usr/src/sys/pdp/libc_ldiv.s~
Xmv -f /usr/src/sys/pdp/libc_lmul.s  /usr/src/sys/pdp/libc_lmul.s~
Xmv -f /usr/src/sys/pdp/libc_lrem.s  /usr/src/sys/pdp/libc_lrem.s~
Xmv -f /usr/src/sys/pdp/libc_remque.s  /usr/src/sys/pdp/libc_remque.s~
Xmv -f /usr/src/sys/pdp/libc_strlen.s  /usr/src/sys/pdp/libc_strlen.s~
Xmv -f /usr/src/sys/pdp/libc_udiv.s  /usr/src/sys/pdp/libc_udiv.s~
Xmv -f /usr/src/sys/pdp/libc_uldiv.s  /usr/src/sys/pdp/libc_uldiv.s~
Xmv -f /usr/src/sys/pdp/libc_ulsh.s  /usr/src/sys/pdp/libc_ulsh.s~
SHAR_EOF
chmod 755 '/tmp/rename'
fi
exit 0
#	End of shell archive