mount_cd9660.c revision 1.4 1 /* $NetBSD: mount_cd9660.c,v 1.4 1997/09/15 04:27:38 lukem 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 (at) blitz.com). The Rock Ridge Extension
9 * Support code is derived from software contributed to Berkeley
10 * by Atsushi Murai (amurai (at) 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 #include <sys/cdefs.h>
42 #ifndef lint
43 __COPYRIGHT("@(#) 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 __RCSID("$NetBSD: mount_cd9660.c,v 1.4 1997/09/15 04:27:38 lukem 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 const struct mntopt mopts[] = {
68 MOPT_STDOPTS,
69 MOPT_UPDATE,
70 { NULL }
71 };
72
73 int main __P((int, char *[]));
74 void usage __P((void));
75
76 int
77 main(argc, argv)
78 int argc;
79 char **argv;
80 {
81 struct iso_args args;
82 int ch, mntflags, opts;
83 char *dev, *dir;
84
85 mntflags = opts = 0;
86 while ((ch = getopt(argc, argv, "ego:r")) != -1)
87 switch (ch) {
88 case 'e':
89 opts |= ISOFSMNT_EXTATT;
90 break;
91 case 'g':
92 opts |= ISOFSMNT_GENS;
93 break;
94 case 'o':
95 getmntopts(optarg, mopts, &mntflags);
96 break;
97 case 'r':
98 opts |= ISOFSMNT_NORRIP;
99 break;
100 case '?':
101 default:
102 usage();
103 }
104 argc -= optind;
105 argv += optind;
106
107 if (argc != 2)
108 usage();
109
110 dev = argv[0];
111 dir = argv[1];
112
113 #define DEFAULT_ROOTUID -2
114 args.fspec = dev;
115 args.export.ex_root = DEFAULT_ROOTUID;
116
117 if (mntflags & MNT_RDONLY)
118 args.export.ex_flags = MNT_EXRDONLY;
119 else
120 args.export.ex_flags = 0;
121 args.flags = opts;
122
123 if (mount(MOUNT_CD9660, dir, mntflags, &args) < 0)
124 err(1, "%s", "");
125 exit(0);
126 }
127
128 void
129 usage()
130 {
131 (void)fprintf(stderr,
132 "usage: mount_cd9660 [-egrt] [-o options] special node\n");
133 exit(1);
134 }
135