mount_procfs.c revision 1.9
11.9Slukem/* $NetBSD: mount_procfs.c,v 1.9 1997/09/16 12:32:04 lukem 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.9Slukem__RCSID("$NetBSD: mount_procfs.c,v 1.9 1997/09/16 12:32:04 lukem 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.7Sjtcconst struct mntopt mopts[] = { 661.5Smycroft MOPT_STDOPTS, 671.5Smycroft { NULL } 681.5Smycroft}; 691.5Smycroft 701.8Slukemint main __P((int, char *[])); 711.5Smycroftvoid usage __P((void)); 721.1Spk 731.1Spkint 741.4Scgdmain(argc, argv) 751.4Scgd int argc; 761.4Scgd char *argv[]; 771.1Spk{ 781.4Scgd int ch, mntflags; 791.1Spk 801.4Scgd mntflags = 0; 811.8Slukem while ((ch = getopt(argc, argv, "o:")) != -1) 821.5Smycroft switch (ch) { 831.5Smycroft case 'o': 841.9Slukem getmntopts(optarg, mopts, &mntflags, 0); 851.1Spk break; 861.4Scgd case '?': 871.1Spk default: 881.4Scgd usage(); 891.1Spk } 901.4Scgd argc -= optind; 911.4Scgd argv += optind; 921.1Spk 931.4Scgd if (argc != 2) 941.4Scgd usage(); 951.1Spk 961.5Smycroft if (mount(MOUNT_PROCFS, argv[1], mntflags, NULL)) 971.8Slukem err(1, "%s", ""); 981.4Scgd exit(0); 991.4Scgd} 1001.1Spk 1011.4Scgdvoid 1021.4Scgdusage() 1031.4Scgd{ 1041.4Scgd (void)fprintf(stderr, 1051.5Smycroft "usage: mount_procfs [-o options] /proc mount_point\n"); 1061.4Scgd exit(1); 1071.1Spk} 108