1 /*
2  * Copyright (c) 1992, 1993
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.3 (Berkeley) 02/18/94
13  */
14 
15 #ifndef lint
16 static char copyright[] =
17 "@(#) Copyright (c) 1992, 1993\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.3 (Berkeley) 02/18/94";
23 #endif /* not lint */
24 
25 #include <sys/param.h>
26 #define CD9660
27 #include <sys/mount.h>
28 
29 #include <errno.h>
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <string.h>
33 #include <unistd.h>
34 
35 #define DEFAULT_ROOTUID	-2
36 
37 void
38 usage()
39 {
40 
41 	fprintf(stderr,
42 		"usage: mount_cd9660 [-F fsoptions] [-norrip] [-gen] [-extattr] special node\n");
43 	exit(1);
44 }
45 
46 int
47 main(argc, argv)
48 	int argc;
49 	char **argv;
50 {
51 	char *dev;
52 	char *dir;
53 	struct iso_args args;
54 	int mntflags = 0, opts = 0;
55 
56 	argc--;
57 	argv++;
58 	while (argc > 2) {
59 		if (!strcmp("-F", argv[0])) {
60 			argc--; argv++;
61 			mntflags |= atoi(argv[0]);
62 			argc--; argv++;
63 		} else if (!strcmp(argv[0], "-norrip")) {
64 			opts |= ISOFSMNT_NORRIP;
65 			argc--; argv++;
66 		} else if (!strcmp(argv[0], "-gen")) {
67 			opts |= ISOFSMNT_GENS;
68 			argc--; argv++;
69 		} else if (!strcmp(argv[0], "-extattr")) {
70 			opts |= ISOFSMNT_EXTATT;
71 			argc--; argv++;
72 		} else if (!strcmp(argv[0], "-notrans")) {
73 			opts |= ISOFSMNT_NOTRANS;
74 			argc--; argv++;
75 		} else
76 			usage();
77 	}
78 
79 	dev = argv[0];
80 	dir = argv[1];
81 
82 	args.fspec = dev;
83 	args.export.ex_root = DEFAULT_ROOTUID;
84 	if (mntflags & MNT_RDONLY)
85 		args.export.ex_flags = MNT_EXRDONLY;
86 	else
87 		args.export.ex_flags = 0;
88 	args.flags = opts;
89 
90 	if (mount(MOUNT_CD9660, dir, mntflags, &args) < 0) {
91 		(void)fprintf(stderr, "mount_cd9660: %s\n", strerror(errno));
92 		exit(1);
93 	}
94 
95 	exit(0);
96 }
97