2008-07-20 05:20:21 +04:00
|
|
|
/* $NetBSD: mount_cd9660.c,v 1.27 2008/07/20 01:20:22 lukem Exp $ */
|
1995-03-18 17:54:19 +03:00
|
|
|
|
1994-06-08 22:57:30 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1992, 1993, 1994
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley
|
|
|
|
* by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
|
|
|
|
* Support code is derived from software contributed to Berkeley
|
|
|
|
* by Atsushi Murai (amurai@spec.co.jp).
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-08-07 14:04:22 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1994-06-08 22:57:30 +04:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
1997-09-16 16:25:36 +04:00
|
|
|
*
|
|
|
|
* @(#)mount_cd9660.c 8.7 (Berkeley) 5/1/95
|
1994-06-08 22:57:30 +04:00
|
|
|
*/
|
|
|
|
|
1997-09-15 08:27:38 +04:00
|
|
|
#include <sys/cdefs.h>
|
1994-06-08 22:57:30 +04:00
|
|
|
#ifndef lint
|
2008-07-20 05:20:21 +04:00
|
|
|
__COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\
|
|
|
|
The Regents of the University of California. All rights reserved.");
|
1994-06-08 22:57:30 +04:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#ifndef lint
|
1995-03-18 17:54:19 +03:00
|
|
|
#if 0
|
1997-09-16 16:25:36 +04:00
|
|
|
static char sccsid[] = "@(#)mount_cd9660.c 8.7 (Berkeley) 5/1/95";
|
1995-03-18 17:54:19 +03:00
|
|
|
#else
|
2008-07-20 05:20:21 +04:00
|
|
|
__RCSID("$NetBSD: mount_cd9660.c,v 1.27 2008/07/20 01:20:22 lukem Exp $");
|
1995-03-18 17:54:19 +03:00
|
|
|
#endif
|
1994-06-08 22:57:30 +04:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
|
|
|
|
#include <err.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
2002-09-21 22:43:31 +04:00
|
|
|
#include <util.h>
|
1994-06-08 22:57:30 +04:00
|
|
|
|
1998-03-01 05:20:01 +03:00
|
|
|
#include <isofs/cd9660/cd9660_mount.h>
|
|
|
|
|
2003-03-22 14:15:45 +03:00
|
|
|
#include <mntopts.h>
|
1994-06-08 22:57:30 +04:00
|
|
|
|
2000-10-30 23:56:57 +03:00
|
|
|
static const struct mntopt mopts[] = {
|
1994-06-08 22:57:30 +04:00
|
|
|
MOPT_STDOPTS,
|
|
|
|
MOPT_UPDATE,
|
2002-09-21 22:43:31 +04:00
|
|
|
MOPT_GETARGS,
|
2000-07-15 17:54:45 +04:00
|
|
|
{ "extatt", 0, ISOFSMNT_EXTATT, 1 },
|
|
|
|
{ "gens", 0, ISOFSMNT_GENS, 1 },
|
2000-05-27 20:32:08 +04:00
|
|
|
{ "maplcase", 1, ISOFSMNT_NOCASETRANS, 1 },
|
2000-07-15 17:54:45 +04:00
|
|
|
{ "nrr", 0, ISOFSMNT_NORRIP, 1 },
|
|
|
|
{ "rrip", 1, ISOFSMNT_NORRIP, 1 },
|
|
|
|
{ "joliet", 1, ISOFSMNT_NOJOLIET, 1 },
|
2000-07-16 01:40:42 +04:00
|
|
|
{ "rrcaseins", 0, ISOFSMNT_RRCASEINS, 1 },
|
2006-10-16 07:37:42 +04:00
|
|
|
MOPT_NULL,
|
1994-06-08 22:57:30 +04:00
|
|
|
};
|
|
|
|
|
2005-02-05 17:47:18 +03:00
|
|
|
int mount_cd9660(int argc, char **argv);
|
|
|
|
static void usage(void);
|
1994-06-08 22:57:30 +04:00
|
|
|
|
2000-10-30 23:56:57 +03:00
|
|
|
#ifndef MOUNT_NOMAIN
|
1994-06-08 22:57:30 +04:00
|
|
|
int
|
2005-02-05 17:47:18 +03:00
|
|
|
main(int argc, char **argv)
|
2000-10-30 23:56:57 +03:00
|
|
|
{
|
|
|
|
return mount_cd9660(argc, argv);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int
|
2005-02-05 17:47:18 +03:00
|
|
|
mount_cd9660(int argc, char **argv)
|
1994-06-08 22:57:30 +04:00
|
|
|
{
|
|
|
|
struct iso_args args;
|
|
|
|
int ch, mntflags, opts;
|
2006-03-22 00:11:41 +03:00
|
|
|
mntoptparse_t mp;
|
2005-01-31 08:19:18 +03:00
|
|
|
char *dev, *dir, canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
|
1994-06-08 22:57:30 +04:00
|
|
|
|
|
|
|
mntflags = opts = 0;
|
2000-05-27 20:32:08 +04:00
|
|
|
while ((ch = getopt(argc, argv, "egijo:r")) != -1)
|
1994-06-08 22:57:30 +04:00
|
|
|
switch (ch) {
|
|
|
|
case 'e':
|
2000-07-15 17:54:45 +04:00
|
|
|
/* obsolete, retained for compatibility only, use
|
|
|
|
* -o extatt */
|
1994-06-08 22:57:30 +04:00
|
|
|
opts |= ISOFSMNT_EXTATT;
|
|
|
|
break;
|
|
|
|
case 'g':
|
2000-07-15 17:54:45 +04:00
|
|
|
/* obsolete, retained for compatibility only, use
|
|
|
|
* -o gens */
|
1994-06-08 22:57:30 +04:00
|
|
|
opts |= ISOFSMNT_GENS;
|
|
|
|
break;
|
1999-07-13 15:12:49 +04:00
|
|
|
case 'j':
|
2000-07-15 17:54:45 +04:00
|
|
|
/* obsolete, retained fo compatibility only, use
|
|
|
|
* -o nojoliet */
|
1999-07-13 15:12:49 +04:00
|
|
|
opts |= ISOFSMNT_NOJOLIET;
|
|
|
|
break;
|
1994-06-08 22:57:30 +04:00
|
|
|
case 'o':
|
2006-03-22 00:11:41 +03:00
|
|
|
mp = getmntopts(optarg, mopts, &mntflags, &opts);
|
|
|
|
if (mp == NULL)
|
|
|
|
err(1, "getmntopts");
|
|
|
|
freemntopts(mp);
|
1994-06-08 22:57:30 +04:00
|
|
|
break;
|
|
|
|
case 'r':
|
2000-07-15 17:54:45 +04:00
|
|
|
/* obsolete, retained for compatibility only, use
|
|
|
|
* -o norrip */
|
1994-06-08 22:57:30 +04:00
|
|
|
opts |= ISOFSMNT_NORRIP;
|
|
|
|
break;
|
|
|
|
case '?':
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
|
|
|
|
if (argc != 2)
|
|
|
|
usage();
|
|
|
|
|
|
|
|
dev = argv[0];
|
|
|
|
dir = argv[1];
|
|
|
|
|
2005-01-31 08:19:18 +03:00
|
|
|
if (realpath(dev, canon_dev) == NULL) /* Check device path */
|
|
|
|
err(1, "realpath %s", dev);
|
|
|
|
if (strncmp(dev, canon_dev, MAXPATHLEN)) {
|
|
|
|
warnx("\"%s\" is a relative path.", dev);
|
|
|
|
dev = canon_dev;
|
|
|
|
warnx("using \"%s\" instead.", dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (realpath(dir, canon_dir) == NULL) /* Check mounton path */
|
|
|
|
err(1, "realpath %s", dir);
|
|
|
|
if (strncmp(dir, canon_dir, MAXPATHLEN)) {
|
|
|
|
warnx("\"%s\" is a relative path.", dir);
|
|
|
|
dir = canon_dir;
|
|
|
|
warnx("using \"%s\" instead.", dir);
|
|
|
|
}
|
|
|
|
|
1994-06-08 22:57:30 +04:00
|
|
|
#define DEFAULT_ROOTUID -2
|
1997-09-16 16:25:36 +04:00
|
|
|
/*
|
2003-01-06 23:30:28 +03:00
|
|
|
* ISO 9660 filesystems are not writable.
|
1997-09-16 16:25:36 +04:00
|
|
|
*/
|
|
|
|
mntflags |= MNT_RDONLY;
|
1994-06-08 22:57:30 +04:00
|
|
|
args.fspec = dev;
|
|
|
|
args.flags = opts;
|
|
|
|
|
2007-07-16 21:06:52 +04:00
|
|
|
if (mount(MOUNT_CD9660, dir, mntflags, &args, sizeof args) == -1)
|
1999-06-25 23:28:35 +04:00
|
|
|
err(1, "%s on %s", dev, dir);
|
2002-09-21 22:43:31 +04:00
|
|
|
if (mntflags & MNT_GETARGS) {
|
|
|
|
char buf[2048];
|
|
|
|
(void)snprintb(buf, sizeof(buf), ISOFSMNT_BITS, args.flags);
|
|
|
|
printf("%s\n", buf);
|
|
|
|
}
|
1994-06-08 22:57:30 +04:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2000-10-30 23:56:57 +03:00
|
|
|
static void
|
2005-02-05 17:47:18 +03:00
|
|
|
usage(void)
|
1994-06-08 22:57:30 +04:00
|
|
|
{
|
|
|
|
(void)fprintf(stderr,
|
2000-07-15 17:54:45 +04:00
|
|
|
"usage: mount_cd9660 [-o options] special node\n");
|
1994-06-08 22:57:30 +04:00
|
|
|
exit(1);
|
|
|
|
}
|