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