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@blitz.com).  The Rock Ridge Extension
7  * Support code is derived from software contributed to Berkeley
8  * by Atsushi Murai (amurai@spec.co.jp).
9  *
10  * %sccs.include.redist.c%
11  *
12  *      @(#)mount_cd9660.c	8.4 (Berkeley) 03/27/94
13  */
14 
15 #ifndef lint
16 static char copyright[] =
17 "@(#) Copyright (c) 1992, 1993, 1994\n\
18         The Regents of the University of California.  All rights reserved.\n";
19 #endif /* not lint */
20 
21 #ifndef lint
22 static char sccsid[] = "@(#)mount_cd9660.c	8.4 (Berkeley) 03/27/94";
23 #endif /* not lint */
24 
25 #include <sys/param.h>
26 #define CD9660
27 #include <sys/mount.h>
28 
29 #include <err.h>
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <string.h>
33 #include <unistd.h>
34 
35 #include "mntopts.h"
36 
37 struct mntopt mopts[] = {
38 	MOPT_STDOPTS,
39 	MOPT_UPDATE,
40 	{ NULL }
41 };
42 
43 void	usage __P((void));
44 
45 int
46 main(argc, argv)
47 	int argc;
48 	char **argv;
49 {
50 	struct iso_args args;
51 	int ch, mntflags, opts;
52 	char *dev, *dir, *options;
53 
54 	options = NULL;
55 	mntflags = opts = 0;
56 	while ((ch = getopt(argc, argv, "ego:r")) != EOF)
57 		switch (ch) {
58 		case 'e':
59 			opts |= ISOFSMNT_EXTATT;
60 			break;
61 		case 'g':
62 			opts |= ISOFSMNT_GENS;
63 			break;
64 		case 'o':
65 			getmntopts(options, mopts, &mntflags);
66 			break;
67 		case 'r':
68 			opts |= ISOFSMNT_NORRIP;
69 			break;
70 		case '?':
71 		default:
72 			usage();
73 		}
74 	argc -= optind;
75 	argv += optind;
76 
77 	if (argc != 2)
78 		usage();
79 
80 	dev = argv[0];
81 	dir = argv[1];
82 
83 #define DEFAULT_ROOTUID	-2
84 	args.fspec = dev;
85 	args.export.ex_root = DEFAULT_ROOTUID;
86 
87 	if (mntflags & MNT_RDONLY)
88 		args.export.ex_flags = MNT_EXRDONLY;
89 	else
90 		args.export.ex_flags = 0;
91 	args.flags = opts;
92 
93 	if (mount(MOUNT_CD9660, dir, mntflags, &args) < 0)
94 		err(1, NULL);
95 	exit(0);
96 }
97 
98 void
99 usage()
100 {
101 	(void)fprintf(stderr,
102 		"usage: mount_cd9660 [-egrt] [-o options] special node\n");
103 	exit(1);
104 }
105