mount_ptyfs.c revision 1.1
11.1Schristos/*	$NetBSD: mount_ptyfs.c,v 1.1 2004/11/11 01:42:17 christos Exp $	*/
21.1Schristos
31.1Schristos/*
41.1Schristos * Copyright (c) 1992, 1993, 1994
51.1Schristos *	The Regents of the University of California.  All rights reserved.
61.1Schristos *
71.1Schristos * This code is derived from software contributed to Berkeley by
81.1Schristos * Jan-Simon Pendry.
91.1Schristos *
101.1Schristos * Redistribution and use in source and binary forms, with or without
111.1Schristos * modification, are permitted provided that the following conditions
121.1Schristos * are met:
131.1Schristos * 1. Redistributions of source code must retain the above copyright
141.1Schristos *    notice, this list of conditions and the following disclaimer.
151.1Schristos * 2. Redistributions in binary form must reproduce the above copyright
161.1Schristos *    notice, this list of conditions and the following disclaimer in the
171.1Schristos *    documentation and/or other materials provided with the distribution.
181.1Schristos * 3. Neither the name of the University nor the names of its contributors
191.1Schristos *    may be used to endorse or promote products derived from this software
201.1Schristos *    without specific prior written permission.
211.1Schristos *
221.1Schristos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
231.1Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
241.1Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
251.1Schristos * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
261.1Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
271.1Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
281.1Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
291.1Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
301.1Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
311.1Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
321.1Schristos * SUCH DAMAGE.
331.1Schristos */
341.1Schristos
351.1Schristos/*
361.1Schristos * Copyright (c) 1990, 1992 Jan-Simon Pendry
371.1Schristos *
381.1Schristos * This code is derived from software contributed to Berkeley by
391.1Schristos * Jan-Simon Pendry.
401.1Schristos *
411.1Schristos * Redistribution and use in source and binary forms, with or without
421.1Schristos * modification, are permitted provided that the following conditions
431.1Schristos * are met:
441.1Schristos * 1. Redistributions of source code must retain the above copyright
451.1Schristos *    notice, this list of conditions and the following disclaimer.
461.1Schristos * 2. Redistributions in binary form must reproduce the above copyright
471.1Schristos *    notice, this list of conditions and the following disclaimer in the
481.1Schristos *    documentation and/or other materials provided with the distribution.
491.1Schristos * 3. All advertising materials mentioning features or use of this software
501.1Schristos *    must display the following acknowledgement:
511.1Schristos *	This product includes software developed by the University of
521.1Schristos *	California, Berkeley and its contributors.
531.1Schristos * 4. Neither the name of the University nor the names of its contributors
541.1Schristos *    may be used to endorse or promote products derived from this software
551.1Schristos *    without specific prior written permission.
561.1Schristos *
571.1Schristos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
581.1Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
591.1Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
601.1Schristos * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
611.1Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
621.1Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
631.1Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
641.1Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
651.1Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
661.1Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
671.1Schristos * SUCH DAMAGE.
681.1Schristos */
691.1Schristos
701.1Schristos#include <sys/cdefs.h>
711.1Schristos#ifndef lint
721.1Schristos__COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\n\
731.1Schristos	The Regents of the University of California.  All rights reserved.\n");
741.1Schristos#endif /* not lint */
751.1Schristos
761.1Schristos#ifndef lint
771.1Schristos#if 0
781.1Schristosstatic char sccsid[] = "@(#)mount_ptyfs.c	8.3 (Berkeley) 5/4/95";
791.1Schristos#else
801.1Schristos__RCSID("$NetBSD: mount_ptyfs.c,v 1.1 2004/11/11 01:42:17 christos Exp $");
811.1Schristos#endif
821.1Schristos#endif /* not lint */
831.1Schristos
841.1Schristos#include <sys/param.h>
851.1Schristos#include <sys/mount.h>
861.1Schristos
871.1Schristos#include <err.h>
881.1Schristos#include <unistd.h>
891.1Schristos#include <stdio.h>
901.1Schristos#include <stdlib.h>
911.1Schristos#include <string.h>
921.1Schristos
931.1Schristos#include <mntopts.h>
941.1Schristos
951.1Schristosstatic const struct mntopt mopts[] = {
961.1Schristos	MOPT_STDOPTS,
971.1Schristos	MOPT_GETARGS,
981.1Schristos	{ NULL }
991.1Schristos};
1001.1Schristos
1011.1Schristosint	main(int, char *[]);
1021.1Schristosint	mount_ptyfs(int argc, char **argv);
1031.1Schristosstatic void	usage(void);
1041.1Schristos
1051.1Schristos#ifndef MOUNT_NOMAIN
1061.1Schristosint
1071.1Schristosmain(int argc, char *argv[])
1081.1Schristos{
1091.1Schristos	return mount_ptyfs(argc, argv);
1101.1Schristos}
1111.1Schristos#endif
1121.1Schristos
1131.1Schristosint
1141.1Schristosmount_ptyfs(int argc, char *argv[])
1151.1Schristos{
1161.1Schristos	int ch, mntflags = 0;
1171.1Schristos
1181.1Schristos	setprogname(argv[0]);
1191.1Schristos
1201.1Schristos	while ((ch = getopt(argc, argv, "o:")) != -1)
1211.1Schristos		switch (ch) {
1221.1Schristos		case 'o':
1231.1Schristos			getmntopts(optarg, mopts, &mntflags, 0);
1241.1Schristos			break;
1251.1Schristos		case '?':
1261.1Schristos		default:
1271.1Schristos			usage();
1281.1Schristos		}
1291.1Schristos	argc -= optind;
1301.1Schristos	argv += optind;
1311.1Schristos
1321.1Schristos	if (argc != 2)
1331.1Schristos		usage();
1341.1Schristos
1351.1Schristos	if (mount(MOUNT_PTYFS, argv[1], mntflags, NULL))
1361.1Schristos		err(1, "ptyfs on %s", argv[1]);
1371.1Schristos	exit(0);
1381.1Schristos}
1391.1Schristos
1401.1Schristosstatic void
1411.1Schristosusage(void)
1421.1Schristos{
1431.1Schristos	(void)fprintf(stderr,
1441.1Schristos	    "Usage: %s [-o options] ptyfs mountpoint\n", getprogname());
1451.1Schristos	exit(1);
1461.1Schristos}
147