xref: /netbsd-src/sbin/mount_cd9660/mount_cd9660.c (revision 9573504567626934c7ee01c7dce0c4bb1dfe7403)
1 /*	$NetBSD: mount_cd9660.c,v 1.2 1995/03/18 14:57:15 cgd Exp $	*/
2 
3 /*
4  * Copyright (c) 1992, 1993, 1994
5  *      The Regents of the University of California.  All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley
8  * by Pace Willisson (pace@blitz.com).  The Rock Ridge Extension
9  * Support code is derived from software contributed to Berkeley
10  * by Atsushi Murai (amurai@spec.co.jp).
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  * 3. All advertising materials mentioning features or use of this software
21  *    must display the following acknowledgement:
22  *	This product includes software developed by the University of
23  *	California, Berkeley and its contributors.
24  * 4. Neither the name of the University nor the names of its contributors
25  *    may be used to endorse or promote products derived from this software
26  *    without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38  * SUCH DAMAGE.
39  */
40 
41 #ifndef lint
42 static char copyright[] =
43 "@(#) Copyright (c) 1992, 1993, 1994\n\
44         The Regents of the University of California.  All rights reserved.\n";
45 #endif /* not lint */
46 
47 #ifndef lint
48 #if 0
49 static char sccsid[] = "@(#)mount_cd9660.c	8.4 (Berkeley) 3/27/94";
50 #else
51 static char rcsid[] = "$NetBSD: mount_cd9660.c,v 1.2 1995/03/18 14:57:15 cgd Exp $";
52 #endif
53 #endif /* not lint */
54 
55 #include <sys/param.h>
56 #define CD9660
57 #include <sys/mount.h>
58 
59 #include <err.h>
60 #include <stdlib.h>
61 #include <stdio.h>
62 #include <string.h>
63 #include <unistd.h>
64 
65 #include "mntopts.h"
66 
67 struct mntopt mopts[] = {
68 	MOPT_STDOPTS,
69 	MOPT_UPDATE,
70 	{ NULL }
71 };
72 
73 void	usage __P((void));
74 
75 int
76 main(argc, argv)
77 	int argc;
78 	char **argv;
79 {
80 	struct iso_args args;
81 	int ch, mntflags, opts;
82 	char *dev, *dir;
83 
84 	mntflags = opts = 0;
85 	while ((ch = getopt(argc, argv, "ego:r")) != EOF)
86 		switch (ch) {
87 		case 'e':
88 			opts |= ISOFSMNT_EXTATT;
89 			break;
90 		case 'g':
91 			opts |= ISOFSMNT_GENS;
92 			break;
93 		case 'o':
94 			getmntopts(optarg, mopts, &mntflags);
95 			break;
96 		case 'r':
97 			opts |= ISOFSMNT_NORRIP;
98 			break;
99 		case '?':
100 		default:
101 			usage();
102 		}
103 	argc -= optind;
104 	argv += optind;
105 
106 	if (argc != 2)
107 		usage();
108 
109 	dev = argv[0];
110 	dir = argv[1];
111 
112 #define DEFAULT_ROOTUID	-2
113 	args.fspec = dev;
114 	args.export.ex_root = DEFAULT_ROOTUID;
115 
116 	if (mntflags & MNT_RDONLY)
117 		args.export.ex_flags = MNT_EXRDONLY;
118 	else
119 		args.export.ex_flags = 0;
120 	args.flags = opts;
121 
122 	if (mount(MOUNT_CD9660, dir, mntflags, &args) < 0)
123 		err(1, NULL);
124 	exit(0);
125 }
126 
127 void
128 usage()
129 {
130 	(void)fprintf(stderr,
131 		"usage: mount_cd9660 [-egrt] [-o options] special node\n");
132 	exit(1);
133 }
134