Subject: mount*(8) linked as one binary ?
To: None <tech-userlevel@netbsd.org>
From: Jaromír Dolecek <dolecek@ibis.cz>
List: tech-userlevel
Date: 10/26/2000 23:52:57
Hi,
since 2.5MB of space which /sbin/mount* take together on 1.5_BETA/i386
seemed like too much, I've tried to modify the sources so that it's all
linked into one big mount binary, which runs appropriate mount code
depending upon argv[0]. This turned out to not be too hard. I've put
together all mount* but mount_portal, which has some other stuff.

This bringed the size of /sbin/mount* from 2445100 bytes down to
571564 bytes.  I'm appending the patch.

Does this seem ok to pull into tree ?

Jaromir

XXXXX
Index: mount/Makefile
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount/Makefile,v
retrieving revision 1.14
diff -u -r1.14 Makefile
--- mount/Makefile	1997/09/16 12:22:39	1.14
+++ mount/Makefile	2000/10/26 21:40:01
@@ -9,4 +9,41 @@
 # is used by other mount programs which use .PATH directives to use
 # the version here.
 
+SRCS+= getmntopts.c fattr.c checkname.c
+CPPFLAGS+= -I${.CURDIR} -DMOUNT_NOMAIN
+
+# mount_portal has some other stuff, so it's not compiled into mount
+# and is separate
+MOUNT_PROGS=	mount_ados mount_cd9660 mount_ext2fs mount_fdesc mount_ffs \
+		mount_filecore mount_kernfs mount_lfs mount_msdos mount_nfs \
+		mount_ntfs mount_null mount_overlay mount_procfs mount_umap \
+		mount_union
+	
+.for p in ${MOUNT_PROGS}
+.PATH: ${.CURDIR}/../${p}
+SRCS+=	${p}.c
+MAN+=	${p}.8
+LINKS+=	${BINDIR}/${PROG} ${BINDIR}/${p}
+.endfor
+
+# make mount_ufs alias for mount_ffs (this needs also support in checkname.c)
+LINKS+= ${BINDIR}/mount ${BINDIR}/mount_ufs
+
+checkname.c: ${.CURDIR}/Makefile
+	@if true; then \
+	  echo "/* File generated by make - DO NOT EDIT */";	\
+	  echo "#include <sys/types.h>";			\
+	  echo "#include <mntopts.h>";			\
+	  echo "void checkname(int, char **);";		\
+	  echo "void checkname(int argc, char **argv) {"; \
+	  echo "  extern char *__progname;";		\
+	  for p in ${MOUNT_PROGS}; do \
+		echo "if (strcmp(__progname, \"$$p\") == 0)"; \
+		echo " exit($$p(argc, argv));";		\
+	  done;		\
+	  echo "if (strcmp(__progname, \"mount_ufs\") == 0)"; \
+	  echo " exit(mount_ffs(argc, argv));";		\
+	  echo "}";	\
+	fi > ${.TARGET}
+
 .include <bsd.prog.mk>
Index: mount/fattr.c
===================================================================
RCS file: fattr.c
diff -N fattr.c
--- /dev/null	Thu Oct 26 03:23:59 2000
+++ fattr.c	Fri Oct 27 00:40:01 2000
@@ -0,0 +1,115 @@
+/* $NetBSD: mount_ados.c,v 1.11 2000/06/14 17:25:26 cgd Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Scott Telford <s.telford@ed.ac.uk>.
+ *
+ * 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 NetBSD
+ *	Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__RCSID("$NetBSD: mount_ados.c,v 1.11 2000/06/14 17:25:26 cgd Exp $");
+#endif /* not lint */
+
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <ctype.h>
+#include <err.h>
+#include <grp.h>
+#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "fattr.h"
+
+gid_t
+a_gid(s)
+	char *s;
+{
+	struct group *gr;
+	char *gname;
+	gid_t gid;
+
+	if ((gr = getgrnam(s)) != NULL)
+		gid = gr->gr_gid;
+	else {
+		for (gname = s; *s && isdigit(*s); ++s);
+		if (!*s)
+			gid = atoi(gname);
+		else
+			errx(1, "unknown group id: %s", gname);
+	}
+	return (gid);
+}
+
+uid_t
+a_uid(s)
+	char *s;
+{
+	struct passwd *pw;
+	char *uname;
+	uid_t uid;
+
+	if ((pw = getpwnam(s)) != NULL)
+		uid = pw->pw_uid;
+	else {
+		for (uname = s; *s && isdigit(*s); ++s);
+		if (!*s)
+			uid = atoi(uname);
+		else
+			errx(1, "unknown user id: %s", uname);
+	}
+	return (uid);
+}
+
+mode_t
+a_mask(s)
+	char *s;
+{
+	int done, rv;
+	char *ep;
+
+	done = 0;
+	rv = -1;
+	if (*s >= '0' && *s <= '7') {
+		done = 1;
+		rv = strtol(optarg, &ep, 8);
+	}
+	if (!done || rv < 0 || *ep)
+		errx(1, "invalid file mode: %s", s);
+	return (rv);
+}
Index: mount/fattr.h
===================================================================
RCS file: fattr.h
diff -N fattr.h
--- /dev/null	Thu Oct 26 03:23:59 2000
+++ fattr.h	Fri Oct 27 00:40:01 2000
@@ -0,0 +1,41 @@
+/* $NetBSD: mount_ados.c,v 1.11 2000/06/14 17:25:26 cgd Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Scott Telford <s.telford@ed.ac.uk>.
+ *
+ * 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 NetBSD
+ *	Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+gid_t a_gid __P((char *));
+uid_t a_uid __P((char *));
+mode_t a_mask __P((char *));
Index: mount/mntopts.h
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount/mntopts.h,v
retrieving revision 1.9
diff -u -r1.9 mntopts.h
--- mount/mntopts.h	2000/06/15 22:36:07	1.9
+++ mount/mntopts.h	2000/10/26 21:40:01
@@ -90,3 +90,22 @@
 
 void getmntopts __P((const char *, const struct mntopt *, int *, int *));
 extern int getmnt_silent;
+
+/* these are defined in respective mount *.c files */
+int mount_ados __P((int argc, char **argv));
+int mount_cd9660 __P((int argc, char **argv));
+int mount_ext2fs __P((int argc, char **argv));
+int mount_fdesc __P((int argc, char **argv));
+int mount_ffs __P((int argc, char **argv));
+int mount_filecore __P((int argc, char **argv));
+int mount_kernfs __P((int argc, char **argv));
+int mount_lfs __P((int argc, char **argv));
+int mount_msdos __P((int argc, char **argv));
+int mount_nfs __P((int argc, char **argv));
+int mount_ntfs __P((int argc, char **argv));
+int mount_null __P((int argc, char **argv));
+int mount_overlay __P((int argc, char **argv));
+int mount_portal __P((int argc, char **argv));
+int mount_procfs __P((int argc, char **argv));
+int mount_umap __P((int argc, char **argv));
+int mount_union __P((int argc, char **argv));
Index: mount/mount.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount/mount.c,v
retrieving revision 1.51
diff -u -r1.51 mount.c
--- mount/mount.c	2000/10/11 17:56:05	1.51
+++ mount/mount.c	2000/10/26 21:40:03
@@ -67,6 +67,7 @@
 #include <sys/ioctl.h>
 
 #include "pathnames.h"
+#include "mntopts.h"
 
 int	debug, verbose;
 
@@ -84,8 +85,9 @@
 int	mountfs __P((const char *, const char *, const char *,
 			int, const char *, const char *, int));
 void	prmount __P((struct statfs *));
-void	usage __P((void));
+static void	usage __P((void));
 int	main __P((int, char *[]));
+void	checkname __P((int, char *[]));
 
 /* Map from mount otions to printable formats. */
 static struct opt {
@@ -131,6 +133,10 @@
 	char *options;
 	const char *mountopts, *fstypename;
 
+	/* if called as specific mount, call it's main mount routine */
+	checkname(argc, argv);
+
+	/* started as "mount" */
 	all = forceall = init_flags = 0;
 	options = NULL;
 	vfslist = NULL;
@@ -631,7 +637,7 @@
 	return vfstype;
 }
 
-void
+static void
 usage()
 {
 
Index: mount_ados/Makefile
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_ados/Makefile,v
retrieving revision 1.8
diff -u -r1.8 Makefile
--- mount_ados/Makefile	1998/03/01 02:20:11	1.8
+++ mount_ados/Makefile	2000/10/26 21:40:04
@@ -1,7 +1,7 @@
 #	$NetBSD: Makefile,v 1.8 1998/03/01 02:20:11 fvdl Exp $
 
 PROG=	mount_ados
-SRCS=	mount_ados.c getmntopts.c
+SRCS=	mount_ados.c getmntopts.c fattr.c
 MAN=	mount_ados.8
 
 MOUNT=	${.CURDIR}/../mount
Index: mount_ados/mount_ados.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_ados/mount_ados.c,v
retrieving revision 1.11
diff -u -r1.11 mount_ados.c
--- mount_ados/mount_ados.c	2000/06/14 17:25:26	1.11
+++ mount_ados/mount_ados.c	2000/10/26 21:40:04
@@ -55,20 +55,26 @@
 #include <adosfs/adosfs.h>
 
 #include "mntopts.h"
+#include <fattr.h>
 
-const struct mntopt mopts[] = {
+static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	{ NULL }
 };
 
-gid_t	a_gid __P((char *));
-uid_t	a_uid __P((char *));
-mode_t	a_mask __P((char *));
 int	main __P((int, char *[]));
-void	usage __P((void));
+static void	usage __P((void));
 
+#ifndef MOUNT_NOMAIN
 int
-main(argc, argv)
+main(int argc, char **argv)
+{
+	return mount_ados(argc, argv);
+}
+#endif
+
+int
+mount_ados(argc, argv)
 	int argc;
 	char **argv;
 {
@@ -142,66 +148,8 @@
 
 	exit (0);
 }
-
-gid_t
-a_gid(s)
-	char *s;
-{
-	struct group *gr;
-	char *gname;
-	gid_t gid;
-
-	if ((gr = getgrnam(s)) != NULL)
-		gid = gr->gr_gid;
-	else {
-		for (gname = s; *s && isdigit(*s); ++s);
-		if (!*s)
-			gid = atoi(gname);
-		else
-			errx(1, "unknown group id: %s", gname);
-	}
-	return (gid);
-}
-
-uid_t
-a_uid(s)
-	char *s;
-{
-	struct passwd *pw;
-	char *uname;
-	uid_t uid;
-
-	if ((pw = getpwnam(s)) != NULL)
-		uid = pw->pw_uid;
-	else {
-		for (uname = s; *s && isdigit(*s); ++s);
-		if (!*s)
-			uid = atoi(uname);
-		else
-			errx(1, "unknown user id: %s", uname);
-	}
-	return (uid);
-}
-
-mode_t
-a_mask(s)
-	char *s;
-{
-	int done, rv;
-	char *ep;
-
-	done = 0;
-	rv = -1;
-	if (*s >= '0' && *s <= '7') {
-		done = 1;
-		rv = strtol(optarg, &ep, 8);
-	}
-	if (!done || rv < 0 || *ep)
-		errx(1, "invalid file mode: %s", s);
-	return (rv);
-}
 
-void
+static void
 usage()
 {
 
Index: mount_cd9660/mount_cd9660.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_cd9660/mount_cd9660.c,v
retrieving revision 1.13
diff -u -r1.13 mount_cd9660.c
--- mount_cd9660/mount_cd9660.c	2000/07/15 21:40:43	1.13
+++ mount_cd9660/mount_cd9660.c	2000/10/26 21:40:04
@@ -67,7 +67,7 @@
 
 #include "mntopts.h"
 
-const struct mntopt mopts[] = {
+static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	MOPT_UPDATE,
 	{ "extatt", 0, ISOFSMNT_EXTATT, 1 },
@@ -81,13 +81,23 @@
 };
 
 int	main __P((int, char *[]));
-void	usage __P((void));
+static void	usage __P((void));
 
+#ifndef MOUNT_NOMAIN
 int
 main(argc, argv)
 	int argc;
 	char **argv;
 {
+	return mount_cd9660(argc, argv);
+}
+#endif
+
+int
+mount_cd9660(argc, argv)
+	int argc;
+	char **argv;
+{
 	struct iso_args args;
 	int ch, mntflags, opts;
 	char *dev, *dir;
@@ -146,7 +156,7 @@
 	exit(0);
 }
 
-void
+static void
 usage()
 {
 	(void)fprintf(stderr,
Index: mount_ext2fs/mount_ext2fs.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_ext2fs/mount_ext2fs.c,v
retrieving revision 1.7
diff -u -r1.7 mount_ext2fs.c
--- mount_ext2fs/mount_ext2fs.c	2000/04/14 06:03:39	1.7
+++ mount_ext2fs/mount_ext2fs.c	2000/10/26 21:40:04
@@ -61,7 +61,7 @@
 
 #include "mntopts.h"
 
-void	ext2fs_usage __P((void));
+static void	ext2fs_usage __P((void));
 int	main __P((int, char *[]));
 
 static const struct mntopt mopts[] = {
@@ -75,11 +75,21 @@
 	{ NULL }
 };
 
+#ifndef MOUNT_NOMAIN
 int
 main(argc, argv)
 	int argc;
 	char *argv[];
 {
+	return mount_ext2fs(argc, argv);
+}
+#endif
+
+int
+mount_ext2fs(argc, argv)
+	int argc;
+	char *argv[];
+{
 	struct ufs_args args;		/* XXX ffs_args */
 	int ch, mntflags;
 	char *fs_name;
@@ -133,7 +143,7 @@
 	exit(0);
 }
 
-void
+static void
 ext2fs_usage()
 {
 	(void)fprintf(stderr,
Index: mount_fdesc/mount_fdesc.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_fdesc/mount_fdesc.c,v
retrieving revision 1.10
diff -u -r1.10 mount_fdesc.c
--- mount_fdesc/mount_fdesc.c	1999/06/25 19:28:36	1.10
+++ mount_fdesc/mount_fdesc.c	2000/10/26 21:40:04
@@ -62,17 +62,27 @@
 
 #include "mntopts.h"
 
-const struct mntopt mopts[] = {
+static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	{ NULL }
 };
 
-void	usage __P((void));
+static void	usage __P((void));
 int	main __P((int, char *[]));
 
+#ifndef MOUNT_NOMAIN
 int
 main(argc, argv)
 	int argc;
+	char **argv;
+{
+	return mount_fdesc(argc, argv);
+}
+#endif
+
+int
+mount_fdesc(argc, argv)
+	int argc;
 	char *argv[];
 {
 	int ch, mntflags;
@@ -98,7 +108,7 @@
 	exit(0);
 }
 
-void
+static void
 usage()
 {
 	(void)fprintf(stderr,
Index: mount_ffs/mount_ffs.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_ffs/mount_ffs.c,v
retrieving revision 1.11
diff -u -r1.11 mount_ffs.c
--- mount_ffs/mount_ffs.c	2000/06/15 22:36:46	1.11
+++ mount_ffs/mount_ffs.c	2000/10/26 21:40:04
@@ -61,7 +61,7 @@
 
 #include "mntopts.h"
 
-void	ffs_usage __P((void));
+static void	ffs_usage __P((void));
 int	main __P((int, char *[]));
 
 static const struct mntopt mopts[] = {
@@ -77,9 +77,19 @@
 	{ NULL }
 };
 
+#ifndef MOUNT_NOMAIN
 int
 main(argc, argv)
 	int argc;
+	char **argv;
+{
+	return mount_ffs(argc, argv);
+}
+#endif
+
+int
+mount_ffs(argc, argv)
+	int argc;
 	char *argv[];
 {
 	struct ufs_args args;
@@ -135,7 +145,7 @@
 	exit(0);
 }
 
-void
+static void
 ffs_usage()
 {
 	(void)fprintf(stderr, "usage: mount_ffs [-o options] special node\n");
Index: mount_filecore/Makefile
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_filecore/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- mount_filecore/Makefile	1998/08/14 14:36:52	1.2
+++ mount_filecore/Makefile	2000/10/26 21:40:04
@@ -3,11 +3,11 @@
 #	Makefile	1.0	1998/6/26
 
 PROG=	mount_filecore
-SRCS=	mount_filecore.c getmntopts.c
+SRCS=	mount_filecore.c getmntopts.c fattr.c
 MAN=	mount_filecore.8
 
 MOUNT=	${.CURDIR}/../mount
 CPPFLAGS+= -I${MOUNT}
-.PATH:	${MOUNT}
+.PATH:	${MOUNT} ${.CURDIR}/../mount_ados
 
 .include <bsd.prog.mk>
Index: mount_filecore/mount_filecore.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_filecore/mount_filecore.c,v
retrieving revision 1.3
diff -u -r1.3 mount_filecore.c
--- mount_filecore/mount_filecore.c	2000/06/14 06:49:14	1.3
+++ mount_filecore/mount_filecore.c	2000/10/26 21:40:04
@@ -62,23 +62,32 @@
 #include <filecorefs/filecore_mount.h>
 
 #include "mntopts.h"
+#include <fattr.h>
 
-const struct mntopt mopts[] = {
+static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	MOPT_UPDATE,
 	{ NULL }
 };
 
 int	main __P((int, char *[]));
-void	usage __P((void));
-gid_t   a_gid __P((char *));
-uid_t   a_uid __P((char *));
+static void	usage __P((void));
 
+#ifndef MOUNT_NOMAIN
 int
 main(argc, argv)
 	int argc;
 	char **argv;
 {
+	return mount_filecore(argc, argv);
+}
+#endif
+
+int
+mount_filecore(argc, argv)
+	int argc;
+	char **argv;
+{
 	struct filecore_args args;
 	int ch, mntflags, opts, useuid;
 	char *dev, *dir;
@@ -142,50 +151,10 @@
 	exit(0);
 }
 
-void
+static void
 usage()
 {
 	(void)fprintf(stderr,
 		"usage: mount_filecore [-o options] special node\n");
 	exit(1);
-}
-
-gid_t
-a_gid(s)
-        char *s;
-{
-        struct group *gr;
-        char *gname;
-        gid_t gid;
-
-        if ((gr = getgrnam(s)) != NULL)
-                gid = gr->gr_gid;
-        else {
-                for (gname = s; *s && isdigit(*s); ++s);
-                if (!*s)
-                        gid = atoi(gname);
-                else
-                        errx(1, "unknown group id: %s", gname);
-        }
-        return (gid);
-}
-
-uid_t
-a_uid(s)
-        char *s;
-{
-        struct passwd *pw;
-        char *uname;
-        uid_t uid;
-
-        if ((pw = getpwnam(s)) != NULL)
-                uid = pw->pw_uid;
-        else {
-                for (uname = s; *s && isdigit(*s); ++s);
-                if (!*s)
-                        uid = atoi(uname);
-                else
-                        errx(1, "unknown user id: %s", uname);
-        }
-        return (uid);
 }
Index: mount_kernfs/mount_kernfs.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_kernfs/mount_kernfs.c,v
retrieving revision 1.11
diff -u -r1.11 mount_kernfs.c
--- mount_kernfs/mount_kernfs.c	1999/06/25 19:28:36	1.11
+++ mount_kernfs/mount_kernfs.c	2000/10/26 21:40:04
@@ -62,17 +62,27 @@
 
 #include "mntopts.h"
 
-const struct mntopt mopts[] = {
+static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	{ NULL }
 };
 
 int	main __P((int, char *[]));
-void	usage __P((void));
+static void	usage __P((void));
 
+#ifndef MOUNT_NOMAIN
 int
 main(argc, argv)
 	int argc;
+	char **argv;
+{
+	return mount_kernfs(argc, argv);
+}
+#endif
+
+int
+mount_kernfs(argc, argv)
+	int argc;
 	char *argv[];
 {
 	int ch, mntflags;
@@ -98,7 +108,7 @@
 	exit(0);
 }
 
-void
+static void
 usage()
 {
 	(void)fprintf(stderr,
Index: mount_lfs/mount_lfs.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_lfs/mount_lfs.c,v
retrieving revision 1.10
diff -u -r1.10 mount_lfs.c
--- mount_lfs/mount_lfs.c	2000/09/09 04:49:56	1.10
+++ mount_lfs/mount_lfs.c	2000/10/26 21:40:04
@@ -62,22 +62,32 @@
 #include "mntopts.h"
 #include "pathnames.h"
 
-const struct mntopt mopts[] = {
+static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	MOPT_UPDATE,
 	{ NULL }
 };
 
 int	main __P((int, char *[]));
-void	invoke_cleaner __P((char *));
-void	usage __P((void));
+static void	invoke_cleaner __P((char *));
+static void	usage __P((void));
 
-int short_rds, cleaner_debug, cleaner_bytes;
-char *nsegs;
+static int short_rds, cleaner_debug, cleaner_bytes;
+static char *nsegs;
 
+#ifndef MOUNT_NOMAIN
 int
 main(argc, argv)
 	int argc;
+	char **argv;
+{
+	return mount_lfs(argc, argv);
+}
+#endif
+
+int
+mount_lfs(argc, argv)
+	int argc;
 	char *argv[];
 {
 	struct ufs_args args;
@@ -156,7 +166,7 @@
 	exit(0);
 }
 
-void
+static void
 invoke_cleaner(name)
 	char *name;
 {
@@ -181,7 +191,7 @@
 	err(1, "exec %s", _PATH_LFS_CLEANERD);
 }
 
-void
+static void
 usage()
 {
 	(void)fprintf(stderr,
Index: mount_msdos/Makefile
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_msdos/Makefile,v
retrieving revision 1.14
diff -u -r1.14 Makefile
--- mount_msdos/Makefile	2000/08/14 16:38:40	1.14
+++ mount_msdos/Makefile	2000/10/26 21:40:04
@@ -1,7 +1,7 @@
 #	$NetBSD: Makefile,v 1.14 2000/08/14 16:38:40 deberg Exp $
 
 PROG=	mount_msdos
-SRCS=	mount_msdos.c getmntopts.c
+SRCS=	mount_msdos.c getmntopts.c fattr.c
 MAN=	mount_msdos.8
 
 MOUNT=	${.CURDIR}/../mount
Index: mount_msdos/mount_msdos.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_msdos/mount_msdos.c,v
retrieving revision 1.23
diff -u -r1.23 mount_msdos.c
--- mount_msdos/mount_msdos.c	2000/06/14 17:25:27	1.23
+++ mount_msdos/mount_msdos.c	2000/10/26 21:40:06
@@ -54,8 +54,9 @@
 #include <unistd.h>
 
 #include "mntopts.h"
+#include <fattr.h>
 
-const struct mntopt mopts[] = {
+static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	MOPT_ASYNC,
 	MOPT_SYNC,
@@ -63,17 +64,24 @@
 	{ NULL }
 };
 
-gid_t	a_gid __P((char *));
-uid_t	a_uid __P((char *));
-mode_t	a_mask __P((char *));
 int	main __P((int, char *[]));
-void	usage __P((void));
+static void	usage __P((void));
 
+#ifndef MOUNT_NOMAIN
 int
 main(argc, argv)
 	int argc;
 	char **argv;
 {
+	return mount_msdos(argc, argv);
+}
+#endif
+
+int
+mount_msdos(argc, argv)
+	int argc;
+	char **argv;
+{
 	struct msdosfs_args args;
 	struct stat sb;
 	int c, mntflags, set_gid, set_uid, set_mask;
@@ -156,66 +164,8 @@
 
 	exit (0);
 }
-
-gid_t
-a_gid(s)
-	char *s;
-{
-	struct group *gr;
-	char *gname;
-	gid_t gid;
-
-	if ((gr = getgrnam(s)) != NULL)
-		gid = gr->gr_gid;
-	else {
-		for (gname = s; *s && isdigit(*s); ++s);
-		if (!*s)
-			gid = atoi(gname);
-		else
-			errx(1, "unknown group id: %s", gname);
-	}
-	return (gid);
-}
-
-uid_t
-a_uid(s)
-	char *s;
-{
-	struct passwd *pw;
-	char *uname;
-	uid_t uid;
-
-	if ((pw = getpwnam(s)) != NULL)
-		uid = pw->pw_uid;
-	else {
-		for (uname = s; *s && isdigit(*s); ++s);
-		if (!*s)
-			uid = atoi(uname);
-		else
-			errx(1, "unknown user id: %s", uname);
-	}
-	return (uid);
-}
-
-mode_t
-a_mask(s)
-	char *s;
-{
-	int done, rv;
-	char *ep;
-
-	done = 0;
-	rv = -1;
-	if (*s >= '0' && *s <= '7') {
-		done = 1;
-		rv = strtol(optarg, &ep, 8);
-	}
-	if (!done || rv < 0 || *ep)
-		errx(1, "invalid file mode: %s", s);
-	return (rv);
-}
 
-void
+static void
 usage()
 {
 
Index: mount_nfs/mount_nfs.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_nfs/mount_nfs.c,v
retrieving revision 1.28
diff -u -r1.28 mount_nfs.c
--- mount_nfs/mount_nfs.c	2000/07/16 14:06:08	1.28
+++ mount_nfs/mount_nfs.c	2000/10/26 21:40:08
@@ -107,7 +107,7 @@
 #define ALTF_TCP	0x1000
 #define ALTF_NFSV2	0x2000
 
-const struct mntopt mopts[] = {
+static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	MOPT_FORCE,
 	MOPT_UPDATE,
@@ -171,33 +171,43 @@
 int mnttcp_ok = 1;
 
 #ifdef NFSKERB
-char inst[INST_SZ];
-char realm[REALM_SZ];
-struct {
+static char inst[INST_SZ];
+static char realm[REALM_SZ];
+static struct {
 	u_long		kind;
 	KTEXT_ST	kt;
 } ktick;
-struct nfsrpc_nickverf kverf;
-struct nfsrpc_fullblock kin, kout;
-NFSKERBKEY_T kivec;
-CREDENTIALS kcr;
-struct timeval ktv;
-NFSKERBKEYSCHED_T kerb_keysched;
+static struct nfsrpc_nickverf kverf;
+static struct nfsrpc_fullblock kin, kout;
+static NFSKERBKEY_T kivec;
+static CREDENTIALS kcr;
+static struct timeval ktv;
+static NFSKERBKEYSCHED_T kerb_keysched;
 #endif
 
-int	getnfsargs __P((char *, struct nfs_args *));
+static int	getnfsargs __P((char *, struct nfs_args *));
 #ifdef ISO
-struct	iso_addr *iso_addr __P((const char *));
+static struct	iso_addr *iso_addr __P((const char *));
 #endif
 int	main __P((int, char *[]));
-void	set_rpc_maxgrouplist __P((int));
-void	usage __P((void));
-int	xdr_dir __P((XDR *, char *));
-int	xdr_fh __P((XDR *, struct nfhret *));
+/* void	set_rpc_maxgrouplist __P((int)); */
+static void	usage __P((void));
+static int	xdr_dir __P((XDR *, char *));
+static int	xdr_fh __P((XDR *, struct nfhret *));
 
+#ifndef MOUNT_NOMAIN
 int
 main(argc, argv)
 	int argc;
+	char **argv;
+{
+	return mount_nfs(argc, argv);
+}
+#endif
+
+int
+mount_nfs(argc, argv)
+	int argc;
 	char *argv[];
 {
 	int c;
@@ -540,7 +550,7 @@
 	exit(0);
 }
 
-int
+static int
 getnfsargs(spec, nfsargsp)
 	char *spec;
 	struct nfs_args *nfsargsp;
@@ -792,7 +802,7 @@
 /*
  * xdr routines for mount rpc's
  */
-int
+static int
 xdr_dir(xdrsp, dirp)
 	XDR *xdrsp;
 	char *dirp;
@@ -800,7 +810,7 @@
 	return (xdr_string(xdrsp, &dirp, RPCMNT_PATHLEN));
 }
 
-int
+static int
 xdr_fh(xdrsp, np)
 	XDR *xdrsp;
 	struct nfhret *np;
@@ -842,7 +852,7 @@
 	return (0);
 }
 
-void
+static void
 usage()
 {
 	(void)fprintf(stderr, "usage: mount_nfs %s\n%s\n%s\n%s\n%s\n",
Index: mount_ntfs/Makefile
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_ntfs/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- mount_ntfs/Makefile	1999/05/17 16:44:53	1.3
+++ mount_ntfs/Makefile	2000/10/26 21:40:08
@@ -4,7 +4,7 @@
 #
 
 PROG=	mount_ntfs
-SRCS=	mount_ntfs.c getmntopts.c
+SRCS=	mount_ntfs.c getmntopts.c fattr.c
 MAN=	mount_ntfs.8
 
 MOUNT=	${.CURDIR}/../mount
Index: mount_ntfs/mount_ntfs.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_ntfs/mount_ntfs.c,v
retrieving revision 1.4
diff -u -r1.4 mount_ntfs.c
--- mount_ntfs/mount_ntfs.c	2000/06/14 06:49:15	1.4
+++ mount_ntfs/mount_ntfs.c	2000/10/26 21:40:08
@@ -55,8 +55,9 @@
 #include <unistd.h>
 
 #include "mntopts.h"
+#include <fattr.h>
 
-static struct mntopt mopts[] = {
+static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	{ NULL }
 };
@@ -65,18 +66,24 @@
 #define __dead2 __attribute__((__noreturn__))
 #endif
 
-static gid_t	a_gid __P((char *));
-static uid_t	a_uid __P((char *));
-static mode_t	a_mask __P((char *));
 static void	usage __P((void)) __dead2;
-
 int main __P((int, char **));
 
+#ifndef MOUNT_NOMAIN
 int
 main(argc, argv)
 	int argc;
 	char **argv;
 {
+	return mount_ntfs(argc, argv);
+}
+#endif
+
+int
+mount_ntfs(argc, argv)
+	int argc;
+	char **argv;
+{
 	struct ntfs_args args;
 	struct stat sb;
 	int c, mntflags, set_gid, set_uid, set_mask;
@@ -191,65 +198,8 @@
 
 	exit (0);
 }
-
-gid_t
-a_gid(s)
-	char *s;
-{
-	struct group *gr;
-	char *gname;
-	gid_t gid;
-
-	if ((gr = getgrnam(s)) != NULL)
-		gid = gr->gr_gid;
-	else {
-		for (gname = s; *s && isdigit(*s); ++s);
-		if (!*s)
-			gid = atoi(gname);
-		else
-			errx(EX_NOUSER, "unknown group id: %s", gname);
-	}
-	return (gid);
-}
-
-uid_t
-a_uid(s)
-	char *s;
-{
-	struct passwd *pw;
-	char *uname;
-	uid_t uid;
-
-	if ((pw = getpwnam(s)) != NULL)
-		uid = pw->pw_uid;
-	else {
-		for (uname = s; *s && isdigit(*s); ++s);
-		if (!*s)
-			uid = atoi(uname);
-		else
-			errx(EX_NOUSER, "unknown user id: %s", uname);
-	}
-	return (uid);
-}
-
-mode_t
-a_mask(s)
-	char *s;
-{
-	int done, rv=0;
-	char *ep;
-
-	done = 0;
-	if (*s >= '0' && *s <= '7') {
-		done = 1;
-		rv = strtol(optarg, &ep, 8);
-	}
-	if (!done || rv < 0 || *ep)
-		errx(EX_USAGE, "invalid file mode: %s", s);
-	return (rv);
-}
 
-void
+static void
 usage()
 {
 	fprintf(stderr, "usage: mount_ntfs [-a] [-i] [-u user] [-g group] [-m mask] bdev dir\n");
Index: mount_null/mount_null.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_null/mount_null.c,v
retrieving revision 1.7
diff -u -r1.7 mount_null.c
--- mount_null/mount_null.c	1999/07/08 03:04:39	1.7
+++ mount_null/mount_null.c	2000/10/26 21:40:08
@@ -62,18 +62,28 @@
 
 #include "mntopts.h"
 
-const struct mntopt mopts[] = {
+static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	{ NULL }
 };
 
 int	main __P((int, char *[]));
-int	subdir __P((const char *, const char *));
-void	usage __P((void));
+static int	subdir __P((const char *, const char *));
+static void	usage __P((void));
 
+#ifndef MOUNT_NOMAIN
 int
 main(argc, argv)
 	int argc;
+	char **argv;
+{
+	return mount_null(argc, argv);
+}
+#endif
+
+int
+mount_null(argc, argv)
+	int argc;
 	char *argv[];
 {
 	struct null_args args;
@@ -110,7 +120,7 @@
 	exit(0);
 }
 
-int
+static int
 subdir(p, dir)
 	const char *p;
 	const char *dir;
@@ -127,7 +137,7 @@
 	return (0);
 }
 
-void
+static void
 usage()
 {
 	(void)fprintf(stderr,
Index: mount_overlay/mount_overlay.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_overlay/mount_overlay.c,v
retrieving revision 1.1
diff -u -r1.1 mount_overlay.c
--- mount_overlay/mount_overlay.c	2000/01/20 19:22:11	1.1
+++ mount_overlay/mount_overlay.c	2000/10/26 21:40:08
@@ -62,18 +62,30 @@
 
 #include "mntopts.h"
 
-const struct mntopt mopts[] = {
+static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	{ NULL }
 };
 
 int	main __P((int, char *[]));
-int	subdir __P((const char *, const char *));
-void	usage __P((void));
+#if 0
+static int	subdir __P((const char *, const char *)); 
+#endif
+static void	usage __P((void));
 
+#ifndef MOUNT_NOMAIN
 int
 main(argc, argv)
 	int argc;
+	char **argv;
+{
+	return mount_overlay(argc, argv);
+}
+#endif
+
+int
+mount_overlay(argc, argv)
+	int argc;
 	char *argv[];
 {
 	struct overlay_args args;
@@ -106,7 +118,8 @@
 	exit(0);
 }
 
-int
+#if 0
+static int
 subdir(p, dir)
 	const char *p;
 	const char *dir;
@@ -122,8 +135,9 @@
 
 	return (0);
 }
+#endif
 
-void
+static void
 usage()
 {
 	(void)fprintf(stderr,
Index: mount_procfs/mount_procfs.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_procfs/mount_procfs.c,v
retrieving revision 1.10
diff -u -r1.10 mount_procfs.c
--- mount_procfs/mount_procfs.c	1999/06/25 19:28:37	1.10
+++ mount_procfs/mount_procfs.c	2000/10/26 21:40:09
@@ -62,17 +62,27 @@
 
 #include "mntopts.h"
 
-const struct mntopt mopts[] = {
+static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	{ NULL }
 };
 
 int	main __P((int, char *[]));
-void	usage __P((void));
+static void	usage __P((void));
 
+#ifndef MOUNT_NOMAIN
 int
 main(argc, argv)
 	int argc;
+	char **argv;
+{
+	return mount_procfs(argc, argv);
+}
+#endif
+
+int
+mount_procfs(argc, argv)
+	int argc;
 	char *argv[];
 {
 	int ch, mntflags;
@@ -98,7 +108,7 @@
 	exit(0);
 }
 
-void
+static void
 usage()
 {
 	(void)fprintf(stderr,
Index: mount_umap/mount_umap.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_umap/mount_umap.c,v
retrieving revision 1.10
diff -u -r1.10 mount_umap.c
--- mount_umap/mount_umap.c	1999/07/08 03:04:40	1.10
+++ mount_umap/mount_umap.c	2000/10/26 21:40:09
@@ -82,17 +82,27 @@
  * will, in turn, call the umap version of mount. 
  */
 
-const struct mntopt mopts[] = {
+static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	{ NULL }
 };
 
 int	main __P((int, char *[]));
-void	usage __P((void));
+static void	usage __P((void));
 
+#ifndef MOUNT_NOMAIN
 int
 main(argc, argv)
 	int argc;
+	char **argv;
+{
+	return mount_umap(argc, argv);
+}
+#endif
+
+int
+mount_umap(argc, argv)
+	int argc;
 	char *argv[];
 {
 	static char not[] = "; not mounted.";
@@ -234,7 +244,7 @@
 	exit(0);
 }
 
-void
+static void
 usage()
 {
 	(void)fprintf(stderr,
Index: mount_union/mount_union.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/mount_union/mount_union.c,v
retrieving revision 1.6
diff -u -r1.6 mount_union.c
--- mount_union/mount_union.c	1999/06/25 19:28:38	1.6
+++ mount_union/mount_union.c	2000/10/26 21:40:09
@@ -63,18 +63,28 @@
 
 #include "mntopts.h"
 
-const struct mntopt mopts[] = {
+static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	{ NULL }
 };
 
 int	main __P((int, char *[]));
-int	subdir __P((const char *, const char *));
-void	usage __P((void));
+static int	subdir __P((const char *, const char *));
+static void	usage __P((void));
 
+#ifndef MOUNT_NOMAIN
 int
 main(argc, argv)
 	int argc;
+	char **argv;
+{
+	return mount_union(argc, argv);
+}
+#endif
+
+int
+mount_union(argc, argv)
+	int argc;
 	char *argv[];
 {
 	struct union_args args;
@@ -121,7 +131,7 @@
 	exit(0);
 }
 
-int
+static int
 subdir(p, dir)
 	const char *p;
 	const char *dir;
@@ -138,7 +148,7 @@
 	return (0);
 }
 
-void
+static void
 usage()
 {
 	(void)fprintf(stderr,
Index: Makefile
===================================================================
RCS file: /cvsroot/basesrc/sbin/Makefile,v
retrieving revision 1.68
diff -u -r1.68 Makefile
--- Makefile	2000/06/13 15:15:21	1.68
+++ Makefile	2000/10/26 21:48:03
@@ -11,24 +11,28 @@
 	ttyflags umount wsconsctl
 
 # support for various file systems
-SUBDIR+= mount_ados
-SUBDIR+= mount_cd9660
-SUBDIR+= mount_ext2fs	fsck_ext2fs
-SUBDIR+= mount_fdesc
-SUBDIR+= mount_filecore
-SUBDIR+= mount_ffs	newfs fsck_ffs fsdb dump restore clri tunefs
-SUBDIR+= mount_kernfs
-SUBDIR+= mount_lfs	newfs_lfs fsck_lfs dump_lfs
+# SUBDIR+= mount_ados
+# SUBDIR+= mount_cd9660
+# SUBDIR+= mount_ext2fs
+SUBDIR+= fsck_ext2fs
+# SUBDIR+= mount_fdesc
+# SUBDIR+= mount_filecore
+# SUBDIR+= mount_ffs
+SUBDIR+= newfs fsck_ffs fsdb dump restore clri tunefs
+# SUBDIR+= mount_kernfs
+# SUBDIR+= mount_lfs
+SUBDIR+= newfs_lfs fsck_lfs dump_lfs
 # mount_mfs -> newfs
-SUBDIR+= mount_msdos	newfs_msdos fsck_msdos
-SUBDIR+= mount_nfs
-SUBDIR+= mount_ntfs
-SUBDIR+= mount_null
-SUBDIR+= mount_overlay
+# SUBDIR+= mount_msdos
+SUBDIR+= newfs_msdos fsck_msdos
+# SUBDIR+= mount_nfs
+# SUBDIR+= mount_ntfs
+# SUBDIR+= mount_null
+# SUBDIR+= mount_overlay
 SUBDIR+= mount_portal
-SUBDIR+= mount_procfs
-SUBDIR+= mount_umap
-SUBDIR+= mount_union
+# SUBDIR+= mount_procfs
+# SUBDIR+= mount_umap
+# SUBDIR+= mount_union
 
 # IPv6
 SUBDIR+= ping6 rtsol
XXXXX
-- 
Jaromir Dolecek <jdolecek@NetBSD.org>      http://www.ics.muni.cz/~dolecek/
@@@@  Wanna a real operating system ? Go and get NetBSD, damn!  @@@@