1 /* $NetBSD: mount_cd9660.c,v 1.30 2009/01/03 23:09:41 christos Exp $ */
4 * Copyright (c) 1992, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley
8 * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
9 * Support code is derived from software contributed to Berkeley
10 * by Atsushi Murai (amurai@spec.co.jp).
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
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. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * @(#)mount_cd9660.c 8.7 (Berkeley) 5/1/95
39 #include <sys/cdefs.h>
41 __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\
42 The Regents of the University of California. All rights reserved.");
47 static char sccsid
[] = "@(#)mount_cd9660.c 8.7 (Berkeley) 5/1/95";
49 __RCSID("$NetBSD: mount_cd9660.c,v 1.30 2009/01/03 23:09:41 christos Exp $");
53 #include <sys/param.h>
54 #include <sys/mount.h>
63 #include <isofs/cd9660/cd9660_mount.h>
67 #include "mountprog.h"
68 #include "mount_cd9660.h"
70 static const struct mntopt mopts
[] = {
74 { "extatt", 0, ISOFSMNT_EXTATT
, 1 },
75 { "gens", 0, ISOFSMNT_GENS
, 1 },
76 { "maplcase", 1, ISOFSMNT_NOCASETRANS
, 1 },
77 { "casetrans", 1, ISOFSMNT_NOCASETRANS
, 1 },
78 { "nrr", 0, ISOFSMNT_NORRIP
, 1 },
79 { "rrip", 1, ISOFSMNT_NORRIP
, 1 },
80 { "joliet", 1, ISOFSMNT_NOJOLIET
, 1 },
81 { "rrcaseins", 0, ISOFSMNT_RRCASEINS
, 1 },
85 static void usage(void);
89 main(int argc
, char **argv
)
93 return mount_cd9660(argc
, argv
);
98 mount_cd9660_parseargs(int argc
, char **argv
,
99 struct iso_args
*args
, int *mntflags
,
100 char *canon_dev
, char *canon_dir
)
106 memset(args
, 0, sizeof(*args
));
107 *mntflags
= opts
= 0;
108 optind
= optreset
= 1;
109 while ((ch
= getopt(argc
, argv
, "egijo:r")) != -1)
112 /* obsolete, retained for compatibility only, use
114 opts
|= ISOFSMNT_EXTATT
;
117 /* obsolete, retained for compatibility only, use
119 opts
|= ISOFSMNT_GENS
;
122 /* obsolete, retained fo compatibility only, use
124 opts
|= ISOFSMNT_NOJOLIET
;
127 mp
= getmntopts(optarg
, mopts
, mntflags
, &opts
);
129 err(1, "getmntopts");
133 /* obsolete, retained for compatibility only, use
135 opts
|= ISOFSMNT_NORRIP
;
151 pathadj(dev
, canon_dev
);
152 pathadj(dir
, canon_dir
);
154 #define DEFAULT_ROOTUID -2
156 * ISO 9660 filesystems are not writable.
158 if ((*mntflags
& MNT_GETARGS
) == 0)
159 *mntflags
|= MNT_RDONLY
;
160 args
->fspec
= canon_dev
;
165 mount_cd9660(int argc
, char **argv
)
167 struct iso_args args
;
168 char canon_dev
[MAXPATHLEN
], canon_dir
[MAXPATHLEN
];
171 mount_cd9660_parseargs(argc
, argv
, &args
, &mntflags
,
172 canon_dev
, canon_dir
);
174 if (mount(MOUNT_CD9660
, canon_dir
, mntflags
, &args
, sizeof args
) == -1)
175 err(1, "%s on %s", canon_dev
, canon_dir
);
176 if (mntflags
& MNT_GETARGS
) {
178 (void)snprintb(buf
, sizeof(buf
), ISOFSMNT_BITS
, args
.flags
);
188 (void)fprintf(stderr
,
189 "usage: %s [-o options] special node\n", getprogname());