mount_procfs.c revision 1.11
11.11Sjdolecek/*	$NetBSD: mount_procfs.c,v 1.11 2000/10/30 20:57:01 jdolecek Exp $	*/
21.6Scgd
31.2Spk/*
41.4Scgd * Copyright (c) 1990, 1992, 1993 Jan-Simon Pendry
51.5Smycroft * Copyright (c) 1992, 1993, 1994
61.4Scgd *	The Regents of the University of California.  All rights reserved.
71.4Scgd *
81.4Scgd * This code is derived from software contributed to Berkeley by
91.4Scgd * Jan-Simon Pendry.
101.2Spk *
111.2Spk * Redistribution and use in source and binary forms, with or without
121.2Spk * modification, are permitted provided that the following conditions
131.2Spk * are met:
141.2Spk * 1. Redistributions of source code must retain the above copyright
151.2Spk *    notice, this list of conditions and the following disclaimer.
161.2Spk * 2. Redistributions in binary form must reproduce the above copyright
171.2Spk *    notice, this list of conditions and the following disclaimer in the
181.2Spk *    documentation and/or other materials provided with the distribution.
191.2Spk * 3. All advertising materials mentioning features or use of this software
201.2Spk *    must display the following acknowledgement:
211.4Scgd *	This product includes software developed by the University of
221.4Scgd *	California, Berkeley and its contributors.
231.4Scgd * 4. Neither the name of the University nor the names of its contributors
241.4Scgd *    may be used to endorse or promote products derived from this software
251.4Scgd *    without specific prior written permission.
261.2Spk *
271.4Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
281.4Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
291.4Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
301.4Scgd * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
311.4Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
321.4Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
331.4Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
341.4Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
351.4Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
361.4Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
371.4Scgd * SUCH DAMAGE.
381.2Spk */
391.2Spk
401.8Slukem#include <sys/cdefs.h>
411.5Smycroft#ifndef lint
421.8Slukem__COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\n\
431.8Slukem	The Regents of the University of California.  All rights reserved.\n");
441.5Smycroft#endif /* not lint */
451.5Smycroft
461.5Smycroft#ifndef lint
471.6Scgd#if 0
481.9Slukemstatic char sccsid[] = "@(#)mount_procfs.c	8.4 (Berkeley) 4/26/95";
491.6Scgd#else
501.11Sjdolecek__RCSID("$NetBSD: mount_procfs.c,v 1.11 2000/10/30 20:57:01 jdolecek Exp $");
511.6Scgd#endif
521.5Smycroft#endif /* not lint */
531.5Smycroft
541.4Scgd#include <sys/param.h>
551.4Scgd#include <sys/mount.h>
561.4Scgd
571.5Smycroft#include <err.h>
581.4Scgd#include <unistd.h>
591.1Spk#include <stdio.h>
601.4Scgd#include <stdlib.h>
611.4Scgd#include <string.h>
621.4Scgd
631.5Smycroft#include "mntopts.h"
641.5Smycroft
651.11Sjdolecekstatic const struct mntopt mopts[] = {
661.5Smycroft	MOPT_STDOPTS,
671.5Smycroft	{ NULL }
681.5Smycroft};
691.5Smycroft
701.8Slukemint	main __P((int, char *[]));
711.11Sjdolecekint	mount_procfs __P((int argc, char **argv));
721.11Sjdolecekstatic void	usage __P((void));
731.1Spk
741.11Sjdolecek#ifndef MOUNT_NOMAIN
751.1Spkint
761.4Scgdmain(argc, argv)
771.4Scgd	int argc;
781.11Sjdolecek	char **argv;
791.11Sjdolecek{
801.11Sjdolecek	return mount_procfs(argc, argv);
811.11Sjdolecek}
821.11Sjdolecek#endif
831.11Sjdolecek
841.11Sjdolecekint
851.11Sjdolecekmount_procfs(argc, argv)
861.11Sjdolecek	int argc;
871.4Scgd	char *argv[];
881.1Spk{
891.4Scgd	int ch, mntflags;
901.1Spk
911.4Scgd	mntflags = 0;
921.8Slukem	while ((ch = getopt(argc, argv, "o:")) != -1)
931.5Smycroft		switch (ch) {
941.5Smycroft		case 'o':
951.9Slukem			getmntopts(optarg, mopts, &mntflags, 0);
961.1Spk			break;
971.4Scgd		case '?':
981.1Spk		default:
991.4Scgd			usage();
1001.1Spk		}
1011.4Scgd	argc -= optind;
1021.4Scgd	argv += optind;
1031.1Spk
1041.4Scgd	if (argc != 2)
1051.4Scgd		usage();
1061.1Spk
1071.5Smycroft	if (mount(MOUNT_PROCFS, argv[1], mntflags, NULL))
1081.10Sperseant		err(1, "procfs on %s", argv[1]);
1091.4Scgd	exit(0);
1101.4Scgd}
1111.1Spk
1121.11Sjdolecekstatic void
1131.4Scgdusage()
1141.4Scgd{
1151.4Scgd	(void)fprintf(stderr,
1161.5Smycroft		"usage: mount_procfs [-o options] /proc mount_point\n");
1171.4Scgd	exit(1);
1181.1Spk}
119