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.7 (Berkeley) 05/01/95
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.7 (Berkeley) 05/01/95";
23 #endif /* not lint */
24 
25 #include <sys/param.h>
26 #include <sys/mount.h>
27 #include <sys/../isofs/cd9660/cd9660_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;
53 
54 	mntflags = opts = 0;
55 	while ((ch = getopt(argc, argv, "ego:r")) != EOF)
56 		switch (ch) {
57 		case 'e':
58 			opts |= ISOFSMNT_EXTATT;
59 			break;
60 		case 'g':
61 			opts |= ISOFSMNT_GENS;
62 			break;
63 		case 'o':
64 			getmntopts(optarg, mopts, &mntflags, 0);
65 			break;
66 		case 'r':
67 			opts |= ISOFSMNT_NORRIP;
68 			break;
69 		case '?':
70 		default:
71 			usage();
72 		}
73 	argc -= optind;
74 	argv += optind;
75 
76 	if (argc != 2)
77 		usage();
78 
79 	dev = argv[0];
80 	dir = argv[1];
81 
82 #define DEFAULT_ROOTUID	-2
83 	/*
84 	 * ISO 9660 filesystems are not writeable.
85 	 */
86 	mntflags |= MNT_RDONLY;
87 	args.export.ex_flags = MNT_EXRDONLY;
88 	args.fspec = dev;
89 	args.export.ex_root = DEFAULT_ROOTUID;
90 	args.flags = opts;
91 
92 	if (mount("cd9660", dir, mntflags, &args) < 0)
93 		err(1, NULL);
94 	exit(0);
95 }
96 
97 void
98 usage()
99 {
100 	(void)fprintf(stderr,
101 		"usage: mount_cd9660 [-egrt] [-o options] special node\n");
102 	exit(1);
103 }
104