2011-08-29 18:34:58 +04:00
|
|
|
/* $NetBSD: mount_cd9660.c,v 1.32 2011/08/29 14:35:00 joerg 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
|
2011-08-29 18:34:58 +04:00
|
|
|
__RCSID("$NetBSD: mount_cd9660.c,v 1.32 2011/08/29 14:35:00 joerg 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
|
|
|
|
2008-08-06 00:57:45 +04:00
|
|
|
#include "mountprog.h"
|
|
|
|
#include "mount_cd9660.h"
|
|
|
|
|
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 },
|
2009-01-03 23:11:04 +03:00
|
|
|
{ "casetrans", 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
|
|
|
};
|
|
|
|
|
2011-08-29 18:34:58 +04:00
|
|
|
__dead 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
|
|
|
{
|
2008-08-06 00:57:45 +04:00
|
|
|
|
|
|
|
setprogname(argv[0]);
|
2000-10-30 23:56:57 +03:00
|
|
|
return mount_cd9660(argc, argv);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-08-06 00:57:45 +04:00
|
|
|
void
|
|
|
|
mount_cd9660_parseargs(int argc, char **argv,
|
|
|
|
struct iso_args *args, int *mntflags,
|
|
|
|
char *canon_dev, char *canon_dir)
|
1994-06-08 22:57:30 +04:00
|
|
|
{
|
2008-08-06 00:57:45 +04:00
|
|
|
int ch, opts;
|
2006-03-22 00:11:41 +03:00
|
|
|
mntoptparse_t mp;
|
2008-08-06 00:57:45 +04:00
|
|
|
char *dev, *dir;
|
1994-06-08 22:57:30 +04:00
|
|
|
|
2008-08-06 00:57:45 +04:00
|
|
|
memset(args, 0, sizeof(*args));
|
2009-01-03 23:11:04 +03:00
|
|
|
*mntflags = opts = 0;
|
|
|
|
optind = optreset = 1;
|
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':
|
2008-08-06 00:57:45 +04:00
|
|
|
mp = getmntopts(optarg, mopts, mntflags, &opts);
|
2006-03-22 00:11:41 +03:00
|
|
|
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();
|
|
|
|
}
|
2009-01-04 02:09:41 +03:00
|
|
|
|
1994-06-08 22:57:30 +04:00
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
|
|
|
|
if (argc != 2)
|
|
|
|
usage();
|
|
|
|
|
|
|
|
dev = argv[0];
|
|
|
|
dir = argv[1];
|
|
|
|
|
2008-08-06 00:57:45 +04:00
|
|
|
pathadj(dev, canon_dev);
|
|
|
|
pathadj(dir, canon_dir);
|
2005-01-31 08:19:18 +03:00
|
|
|
|
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
|
|
|
*/
|
2009-01-04 02:09:41 +03:00
|
|
|
if ((*mntflags & MNT_GETARGS) == 0)
|
|
|
|
*mntflags |= MNT_RDONLY;
|
2009-10-08 00:42:09 +04:00
|
|
|
args->fspec = canon_dev;
|
2008-08-06 00:57:45 +04:00
|
|
|
args->flags = opts;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
mount_cd9660(int argc, char **argv)
|
|
|
|
{
|
|
|
|
struct iso_args args;
|
|
|
|
char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
|
|
|
|
int mntflags;
|
1994-06-08 22:57:30 +04:00
|
|
|
|
2008-08-06 00:57:45 +04:00
|
|
|
mount_cd9660_parseargs(argc, argv, &args, &mntflags,
|
|
|
|
canon_dev, canon_dir);
|
|
|
|
|
|
|
|
if (mount(MOUNT_CD9660, canon_dir, mntflags, &args, sizeof args) == -1)
|
|
|
|
err(1, "%s on %s", canon_dev, canon_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);
|
|
|
|
}
|
2008-08-06 00:57:45 +04:00
|
|
|
|
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,
|
2008-08-06 00:57:45 +04:00
|
|
|
"usage: %s [-o options] special node\n", getprogname());
|
1994-06-08 22:57:30 +04:00
|
|
|
exit(1);
|
|
|
|
}
|