Subject: Re: mount*(8) linked as one binary ?
To: Chris G. Demetriou <cgd@sibyte.com>
From: Jaromír Dolecek <dolecek@ibis.cz>
List: tech-userlevel
Date: 10/27/2000 23:59:19
Chris G. Demetriou wrote:
> right, but, for instance, somebody who wants an easy rebuild without
> this "feature" for whatever reason can't particularly easily do that.
> 
> I'm not sure it's a problem worth solving, but it's actually similar

Well, I'm probably going to not do anything with this. Adding
a special build variable disabling would be easy, but I don't
think it's worth it.
I'm appending current version of patch.

Jaromir

XXXXX
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/27 21:52:55
@@ -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
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/27 21:52:56
@@ -9,4 +9,46 @@
 # 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>";				\
+	  for p in ${MOUNT_PROGS}; do 				\
+		echo "int $$p __P((int argc, char **argv));";	\
+	  done;							\
+	  echo "void checkname(int, char **);";			\
+	  echo;							\
+	  echo "void checkname(int argc, char **argv) {"; 	\
+	  echo "  extern const char *__progname;";		\
+	  echo "if (strcmp(__progname, \"mount\") == 0) return;";	\
+	  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	Fri Oct 27 20:30:49 2000
+++ fattr.c	Sat Oct 28 00:52:58 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	Fri Oct 27 20:30:49 2000
+++ fattr.h	Sat Oct 28 00:52:58 2000
@@ -0,0 +1,38 @@
+/* $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.
+ *
+ * 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/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/27 21:52:59
@@ -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/27 21:52:59
@@ -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/27 21:52:59
@@ -55,20 +55,27 @@
 #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));
+int	mount_ados __P((int argc, char **argv));
+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 +149,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/27 21:52:59
@@ -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,24 @@
 };
 
 int	main __P((int, char *[]));
-void	usage __P((void));
+int	mount_cd9660 __P((int argc, char **argv));
+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 +157,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/27 21:52:59
@@ -61,8 +61,9 @@
 
 #include "mntopts.h"
 
-void	ext2fs_usage __P((void));
+static void	ext2fs_usage __P((void));
 int	main __P((int, char *[]));
+int	mount_ext2fs __P((int argc, char **argv));
 
 static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
@@ -75,11 +76,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 +144,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/27 21:52:59
@@ -62,17 +62,28 @@
 
 #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 *[]));
+int	mount_fdesc __P((int argc, char **argv));
 
+#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 +109,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/27 21:52:59
@@ -61,8 +61,9 @@
 
 #include "mntopts.h"
 
-void	ffs_usage __P((void));
+static void	ffs_usage __P((void));
 int	main __P((int, char *[]));
+int	mount_ffs __P((int argc, char **argv));
 
 static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
@@ -77,9 +78,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 +146,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/27 21:52:59
@@ -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}
 
 .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/27 21:52:59
@@ -62,23 +62,33 @@
 #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 *));
+int	mount_filecore __P((int argc, char **argv));
+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 +152,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/27 21:52:59
@@ -62,17 +62,28 @@
 
 #include "mntopts.h"
 
-const struct mntopt mopts[] = {
+static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	{ NULL }
 };
 
 int	main __P((int, char *[]));
-void	usage __P((void));
+int	mount_kernfs __P((int argc, char **argv));
+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 +109,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/27 21:53:01
@@ -62,22 +62,33 @@
 #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));
+int	mount_lfs __P((int argc, char **argv));
+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 +167,7 @@
 	exit(0);
 }
 
-void
+static void
 invoke_cleaner(name)
 	char *name;
 {
@@ -181,7 +192,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/27 21:53:01
@@ -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/27 21:53:01
@@ -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,25 @@
 	{ 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));
+int	mount_msdos __P((int argc, char **argv));
+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 +165,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/27 21:53:02
@@ -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,44 @@
 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 *));
+int	mount_nfs __P((int argc, char **argv));
+/* 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 +551,7 @@
 	exit(0);
 }
 
-int
+static int
 getnfsargs(spec, nfsargsp)
 	char *spec;
 	struct nfs_args *nfsargsp;
@@ -792,7 +803,7 @@
 /*
  * xdr routines for mount rpc's
  */
-int
+static int
 xdr_dir(xdrsp, dirp)
 	XDR *xdrsp;
 	char *dirp;
@@ -800,7 +811,7 @@
 	return (xdr_string(xdrsp, &dirp, RPCMNT_PATHLEN));
 }
 
-int
+static int
 xdr_fh(xdrsp, np)
 	XDR *xdrsp;
 	struct nfhret *np;
@@ -842,7 +853,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/27 21:53:02
@@ -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/27 21:53:02
@@ -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,25 @@
 #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 **));
+int mount_ntfs __P((int argc, char **argv));
 
+#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 +199,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/27 21:53:02
@@ -62,18 +62,29 @@
 
 #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));
+int	mount_null __P((int argc, char **argv));
+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 +121,7 @@
 	exit(0);
 }
 
-int
+static int
 subdir(p, dir)
 	const char *p;
 	const char *dir;
@@ -127,7 +138,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/27 21:53:03
@@ -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));
+int	mount_overlay __P((int argc, char **argv));
+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;
@@ -105,25 +115,8 @@
 		err(1, "%s on %s", target, argv[1]);
 	exit(0);
 }
-
-int
-subdir(p, dir)
-	const char *p;
-	const char *dir;
-{
-	int l;
-
-	l = strlen(dir);
-	if (l <= 1)
-		return (1);
-
-	if ((strncmp(p, dir, l) == 0) && (p[l] == '/' || p[l] == '\0'))
-		return (1);
-
-	return (0);
-}
 
-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/27 21:53:03
@@ -62,17 +62,28 @@
 
 #include "mntopts.h"
 
-const struct mntopt mopts[] = {
+static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	{ NULL }
 };
 
 int	main __P((int, char *[]));
-void	usage __P((void));
+int	mount_procfs __P((int argc, char **argv));
+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 +109,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/27 21:53:03
@@ -82,17 +82,28 @@
  * 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));
+int	mount_umap __P((int argc, char **argv));
+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 +245,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/27 21:53:04
@@ -63,18 +63,29 @@
 
 #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));
+int	mount_union __P((int argc, char **argv));
+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 +132,7 @@
 	exit(0);
 }
 
-int
+static int
 subdir(p, dir)
 	const char *p;
 	const char *dir;
@@ -138,7 +149,7 @@
 	return (0);
 }
 
-void
+static void
 usage()
 {
 	(void)fprintf(stderr,
XXXXX

Jaromir
-- 
Jaromir Dolecek <jdolecek@NetBSD.org>      http://www.ics.muni.cz/~dolecek/
@@@@  Wanna a real operating system ? Go and get NetBSD, damn!  @@@@