mount_procfs.c revision 1.5
11.2Spk/*
21.4Scgd * Copyright (c) 1990, 1992, 1993 Jan-Simon Pendry
31.5Smycroft * Copyright (c) 1992, 1993, 1994
41.4Scgd *	The Regents of the University of California.  All rights reserved.
51.4Scgd *
61.4Scgd * This code is derived from software contributed to Berkeley by
71.4Scgd * Jan-Simon Pendry.
81.2Spk *
91.2Spk * Redistribution and use in source and binary forms, with or without
101.2Spk * modification, are permitted provided that the following conditions
111.2Spk * are met:
121.2Spk * 1. Redistributions of source code must retain the above copyright
131.2Spk *    notice, this list of conditions and the following disclaimer.
141.2Spk * 2. Redistributions in binary form must reproduce the above copyright
151.2Spk *    notice, this list of conditions and the following disclaimer in the
161.2Spk *    documentation and/or other materials provided with the distribution.
171.2Spk * 3. All advertising materials mentioning features or use of this software
181.2Spk *    must display the following acknowledgement:
191.4Scgd *	This product includes software developed by the University of
201.4Scgd *	California, Berkeley and its contributors.
211.4Scgd * 4. Neither the name of the University nor the names of its contributors
221.4Scgd *    may be used to endorse or promote products derived from this software
231.4Scgd *    without specific prior written permission.
241.2Spk *
251.4Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
261.4Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
271.4Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
281.4Scgd * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
291.4Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
301.4Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
311.4Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
321.4Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
331.4Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
341.4Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
351.4Scgd * SUCH DAMAGE.
361.2Spk */
371.2Spk
381.5Smycroft#ifndef lint
391.5Smycroftchar copyright[] =
401.5Smycroft"@(#) Copyright (c) 1992, 1993, 1994\n\
411.5Smycroft	The Regents of the University of California.  All rights reserved.\n";
421.5Smycroft#endif /* not lint */
431.5Smycroft
441.5Smycroft#ifndef lint
451.5Smycroft/*static char sccsid[] = "from: @(#)mount_procfs.c	8.3 (Berkeley) 3/27/94";*/
461.5Smycroftstatic char *rcsid = "$Id: mount_procfs.c,v 1.5 1994/06/08 19:25:36 mycroft Exp $";
471.5Smycroft#endif /* not lint */
481.5Smycroft
491.4Scgd#include <sys/param.h>
501.4Scgd#include <sys/mount.h>
511.4Scgd
521.5Smycroft#include <err.h>
531.4Scgd#include <unistd.h>
541.1Spk#include <stdio.h>
551.4Scgd#include <stdlib.h>
561.4Scgd#include <string.h>
571.4Scgd
581.5Smycroft#include "mntopts.h"
591.5Smycroft
601.5Smycroftstruct mntopt mopts[] = {
611.5Smycroft	MOPT_STDOPTS,
621.5Smycroft	{ NULL }
631.5Smycroft};
641.5Smycroft
651.5Smycroftvoid	usage __P((void));
661.1Spk
671.1Spkint
681.4Scgdmain(argc, argv)
691.4Scgd	int argc;
701.4Scgd	char *argv[];
711.1Spk{
721.4Scgd	int ch, mntflags;
731.1Spk
741.4Scgd	mntflags = 0;
751.5Smycroft	while ((ch = getopt(argc, argv, "o:")) != EOF)
761.5Smycroft		switch (ch) {
771.5Smycroft		case 'o':
781.5Smycroft			getmntopts(optarg, mopts, &mntflags);
791.1Spk			break;
801.4Scgd		case '?':
811.1Spk		default:
821.4Scgd			usage();
831.1Spk		}
841.4Scgd	argc -= optind;
851.4Scgd	argv += optind;
861.1Spk
871.4Scgd	if (argc != 2)
881.4Scgd		usage();
891.1Spk
901.5Smycroft	if (mount(MOUNT_PROCFS, argv[1], mntflags, NULL))
911.5Smycroft		err(1, NULL);
921.4Scgd	exit(0);
931.4Scgd}
941.1Spk
951.4Scgdvoid
961.4Scgdusage()
971.4Scgd{
981.4Scgd	(void)fprintf(stderr,
991.5Smycroft		"usage: mount_procfs [-o options] /proc mount_point\n");
1001.4Scgd	exit(1);
1011.1Spk}
102