mount_procfs.c revision 1.12
11.12Sfvdl/* $NetBSD: mount_procfs.c,v 1.12 2001/01/17 00:09:54 fvdl 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.12Sfvdl__RCSID("$NetBSD: mount_procfs.c,v 1.12 2001/01/17 00:09:54 fvdl 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.12Sfvdl#include <miscfs/procfs/procfs.h> 641.12Sfvdl 651.5Smycroft#include "mntopts.h" 661.5Smycroft 671.11Sjdolecekstatic const struct mntopt mopts[] = { 681.5Smycroft MOPT_STDOPTS, 691.12Sfvdl { "linux", 0, PROCFSMNT_LINUXCOMPAT, 1}, 701.5Smycroft { NULL } 711.5Smycroft}; 721.5Smycroft 731.8Slukemint main __P((int, char *[])); 741.11Sjdolecekint mount_procfs __P((int argc, char **argv)); 751.11Sjdolecekstatic void usage __P((void)); 761.1Spk 771.11Sjdolecek#ifndef MOUNT_NOMAIN 781.1Spkint 791.4Scgdmain(argc, argv) 801.4Scgd int argc; 811.11Sjdolecek char **argv; 821.11Sjdolecek{ 831.11Sjdolecek return mount_procfs(argc, argv); 841.11Sjdolecek} 851.11Sjdolecek#endif 861.11Sjdolecek 871.11Sjdolecekint 881.11Sjdolecekmount_procfs(argc, argv) 891.11Sjdolecek int argc; 901.4Scgd char *argv[]; 911.1Spk{ 921.12Sfvdl int ch, mntflags, altflags; 931.12Sfvdl struct procfs_args args; 941.1Spk 951.12Sfvdl mntflags = altflags = 0; 961.8Slukem while ((ch = getopt(argc, argv, "o:")) != -1) 971.5Smycroft switch (ch) { 981.5Smycroft case 'o': 991.12Sfvdl getmntopts(optarg, mopts, &mntflags, &altflags); 1001.1Spk break; 1011.4Scgd case '?': 1021.1Spk default: 1031.4Scgd usage(); 1041.1Spk } 1051.4Scgd argc -= optind; 1061.4Scgd argv += optind; 1071.1Spk 1081.4Scgd if (argc != 2) 1091.4Scgd usage(); 1101.1Spk 1111.12Sfvdl args.version = PROCFS_ARGSVERSION; 1121.12Sfvdl args.flags = altflags; 1131.12Sfvdl 1141.12Sfvdl if (mount(MOUNT_PROCFS, argv[1], mntflags, &args)) 1151.10Sperseant err(1, "procfs on %s", argv[1]); 1161.4Scgd exit(0); 1171.4Scgd} 1181.1Spk 1191.11Sjdolecekstatic void 1201.4Scgdusage() 1211.4Scgd{ 1221.4Scgd (void)fprintf(stderr, 1231.5Smycroft "usage: mount_procfs [-o options] /proc mount_point\n"); 1241.4Scgd exit(1); 1251.1Spk} 126