Initial import of a UDF file system implementation for NetBSD.
Add UDF file system mounter.
This commit is contained in:
parent
cff5e7ad2c
commit
c2f693f4f5
|
@ -0,0 +1,17 @@
|
|||
# $NetBSD: Makefile,v 1.1 2006/02/02 15:21:29 reinoud Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
WARNS= 4
|
||||
PROG= mount_udf
|
||||
SRCS= mount_udf.c fattr.c
|
||||
MAN= mount_udf.8
|
||||
|
||||
MOUNT= ${NETBSDSRCDIR}/sbin/mount
|
||||
CPPFLAGS+= -I${MOUNT} -I${NETBSDSRCDIR}/sys
|
||||
.PATH: ${MOUNT}
|
||||
|
||||
DPADD+=${LIBUTIL}
|
||||
LDADD+=-lutil
|
||||
|
||||
.include <bsd.prog.mk>
|
|
@ -0,0 +1,118 @@
|
|||
.\" $NetBSD: mount_udf.8,v 1.1 2006/02/02 15:21:29 reinoud Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2005 Reinoud Zandijk
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" 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.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed for the
|
||||
.\" NetBSD Project. See http://www.NetBSD.org/ for
|
||||
.\" information about NetBSD.
|
||||
.\" 4. The name of the author may not be used to endorse or promote products
|
||||
.\" derived from this software without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
.\"
|
||||
.\" <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
|
||||
.\"
|
||||
.Dd January 26, 2006
|
||||
.Dt MOUNT_UDF 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm mount_udf
|
||||
.Nd mount an UDF file system
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.\".Op Fl c
|
||||
.Op Fl g Ar gid
|
||||
.Op Fl o Ar options
|
||||
.Op Fl t Ar gmtoff
|
||||
.Op Fl u Ar uid
|
||||
.Pa special
|
||||
.Pa node
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
command attaches the UDF file system residing on the specified
|
||||
.Pa special
|
||||
device node on the location indicated with
|
||||
.Pa node .
|
||||
.Pp
|
||||
Anonymous files stored on the UDF disc will be represented and saved in the
|
||||
specified uid:gid pair. If unspecified it will default to nobody:nobody. Both
|
||||
uid and gid can be either specified with their names as with their numerical
|
||||
equivalents.
|
||||
.Bl -tag -width XXXoptions
|
||||
.\" -c flag specifies closure of CD/DVD session after dismount (writing)
|
||||
.It Fl g Ar gid
|
||||
Set the group of anonymous files on the file system. The default group is the
|
||||
nobody group.
|
||||
.It Fl o Ar options
|
||||
Use the specified mount
|
||||
.Ar options
|
||||
as specified in
|
||||
.Xr mount 8 .
|
||||
.It Fl s Ar session
|
||||
Select the session
|
||||
.Ar session
|
||||
to be mounted instead of the default last one. Positive
|
||||
.Ar session
|
||||
values indicate an absolute session number. Negative
|
||||
.Ar session
|
||||
values are relative to the last lession found on the disc.
|
||||
Note that this option only makes sense when mounting sequential recordable
|
||||
media like CD-R and DVD*R.
|
||||
.It Fl t Ar gmtoff
|
||||
Set the time zone offset (in seconds) from UTC to
|
||||
.Ar gmtoff .
|
||||
with positive values indicating east of the Prime Meridian.
|
||||
If not set, the user's current time zone will be used.
|
||||
.It Fl u Ar uid
|
||||
Set the owner of anonymous files on the file system. The default owner is the
|
||||
user nobody.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr mount 2 ,
|
||||
.Xr unmount 8 ,
|
||||
.Xr fstab 5 ,
|
||||
.Xr mount 8 .
|
||||
.Sh NOTES
|
||||
UDF is a file system defined by the OSTA standardisation group and is tailored
|
||||
for data interchange on optical discs (like CDs and DVDs) between different
|
||||
operating systems. Its also more and more common on other media like Compact
|
||||
Flash (CF) cards.
|
||||
.Pp
|
||||
Currently only read access is supported to all media types that CD/DVD type
|
||||
drives can recognize including DVD-RAM and BlueRay drives. Write access is
|
||||
planned and in preparation.
|
||||
.Pp
|
||||
Implemented and tested media types are CD-ROM, CD-R, CD-RW, CD-MRW, DVD-ROM,
|
||||
DVD*R, DVD*RW, DVD+MRW but the same code can also read DVD-RAM, HD-DVD and
|
||||
BluRay discs. Discs created and written by UDFclient, Nero's InCD and Roxio's
|
||||
DirectCD/Drag2Disc read fine. Both open and closed media are supported so
|
||||
there is no need to close discs or close sessions.
|
||||
.Pp
|
||||
Support for harddisc partitions and optionally for files (like using vnd) is
|
||||
not implemented yet.
|
||||
.Pp
|
||||
All current UDF versions upto version 2.60 are supported.
|
||||
.Sh BUGS
|
||||
Due to lack of test media version 2.50 and 2.60 are prepared though not
|
||||
implemented and tested yet.
|
|
@ -0,0 +1,229 @@
|
|||
/* $NetBSD $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Reinoud Zandijk
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed for the
|
||||
* NetBSD Project. See http://www.NetBSD.org/ for
|
||||
* information about NetBSD.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: mount_udf.c,v 1.1 2006/02/02 15:21:29 reinoud Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
/* main includes; strip me! */
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <util.h>
|
||||
#include <assert.h>
|
||||
#include <pwd.h>
|
||||
#include <errno.h>
|
||||
#include <grp.h>
|
||||
|
||||
|
||||
/* mount specific options */
|
||||
#include <fs/udf/udf_mount.h>
|
||||
#include <mntopts.h>
|
||||
#include <fattr.h>
|
||||
|
||||
|
||||
/* options to pass on to the `mount' call */
|
||||
static const struct mntopt mopts[] = {
|
||||
MOPT_STDOPTS, /* `normal' options */
|
||||
MOPT_ASYNC, /* default */
|
||||
MOPT_UPDATE, /* not yet supported */
|
||||
MOPT_GETARGS, /* printing */
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
||||
/* prototypes */
|
||||
int main(int, char *[]);
|
||||
int mount_udf(int argc, char **argv);
|
||||
static void usage(void);
|
||||
|
||||
|
||||
/* code */
|
||||
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "usage: %s [-g gid] [-o options] [-s session] "
|
||||
"[-t gmtoff] [-u uid] special node\n", getprogname());
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
/* copied from mount_msdos; is it nessisary still? */
|
||||
#ifndef MOUNT_NOMAIN
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
return mount_udf(argc, argv);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* main routine */
|
||||
int
|
||||
mount_udf(int argc, char **argv)
|
||||
{
|
||||
struct udf_args args;
|
||||
struct tm *tm;
|
||||
struct passwd *passwd;
|
||||
struct group *group;
|
||||
time_t now;
|
||||
uid_t anon_uid, nobody_uid;
|
||||
gid_t anon_gid, nobody_gid;
|
||||
char *dev, *dir;
|
||||
int ch, mntflags, set_gmtoff;
|
||||
uint32_t sector_size;
|
||||
|
||||
/* set program name for error messages */
|
||||
setprogname(argv[0]);
|
||||
|
||||
/* initialise */
|
||||
memset(&args, 0, sizeof(args));
|
||||
args.version = UDFMNT_VERSION;
|
||||
|
||||
set_gmtoff = mntflags = 0;
|
||||
sector_size = 0;
|
||||
|
||||
/* get nobody */
|
||||
anon_uid = anon_gid = (uid_t)0; /* shutup gcc */
|
||||
passwd = getpwnam("nobody");
|
||||
group = getgrnam("nobody");
|
||||
|
||||
if (passwd && group) {
|
||||
anon_uid = passwd->pw_uid;
|
||||
anon_gid = group->gr_gid;
|
||||
} else {
|
||||
errx(EXIT_FAILURE, "mount_udf: failed to get nobody:nobody\n");
|
||||
};
|
||||
|
||||
nobody_uid = anon_uid;
|
||||
nobody_gid = anon_gid;
|
||||
|
||||
/* NEVER EVER allow nobody_uid:nobody_gid to be 0:0 */
|
||||
assert(nobody_uid != 0);
|
||||
assert(nobody_gid != 0);
|
||||
|
||||
while ((ch = getopt(argc, argv, "cg:o:s:t:u:")) != -1) {
|
||||
switch (ch) {
|
||||
#ifdef notyet
|
||||
case 'c' :
|
||||
args.udfmflags |= UDFMNT_CLOSESESSION;
|
||||
break;
|
||||
#endif
|
||||
case 'g' :
|
||||
/* convert groupname or numeric equiv. */
|
||||
group = getgrnam(optarg);
|
||||
if (group == NULL)
|
||||
group = getgrgid((gid_t) atoi(optarg));
|
||||
if (group == NULL)
|
||||
usage();
|
||||
|
||||
anon_gid = group->gr_gid;
|
||||
break;
|
||||
case 'u' :
|
||||
/* convert username or numeric equiv. */
|
||||
passwd = getpwnam(optarg);
|
||||
if (passwd == NULL)
|
||||
passwd = getpwuid((uid_t) atoi(optarg));
|
||||
if (passwd == NULL)
|
||||
usage();
|
||||
|
||||
anon_uid = passwd->pw_uid;
|
||||
break;
|
||||
case 'o' :
|
||||
/* process generic mount options */
|
||||
getmntopts(optarg, mopts, &mntflags, 0);
|
||||
break;
|
||||
case 's' :
|
||||
args.sessionnr = atoi(optarg);
|
||||
break;
|
||||
case 't' :
|
||||
args.gmtoff = atoi(optarg);
|
||||
set_gmtoff = 1;
|
||||
break;
|
||||
default :
|
||||
usage();
|
||||
};
|
||||
};
|
||||
|
||||
if (optind + 2 != argc)
|
||||
usage();
|
||||
|
||||
if (!set_gmtoff) {
|
||||
/* use user's time zone as default */
|
||||
time(&now);
|
||||
tm = localtime(&now);
|
||||
args.gmtoff = tm->tm_gmtoff;
|
||||
}
|
||||
|
||||
/* get device and directory specifier */
|
||||
dev = argv[optind];
|
||||
dir = argv[optind + 1];
|
||||
args.fspec = dev;
|
||||
args.anon_uid = anon_uid;
|
||||
args.anon_gid = anon_gid;
|
||||
args.nobody_uid = nobody_uid;
|
||||
args.nobody_gid = nobody_gid;
|
||||
args.sector_size = sector_size; /* invalid */
|
||||
|
||||
/* mount it! :) */
|
||||
if (mount(MOUNT_UDF, dir, mntflags, &args) < 0)
|
||||
err(1, "%s on %s", dev, dir);
|
||||
|
||||
if (mntflags & MNT_GETARGS) {
|
||||
char buf[1024];
|
||||
|
||||
snprintb(buf, sizeof(buf), UDFMNT_BITS, args.udfmflags);
|
||||
printf("gmtoffset=%d, sessionnr=%d, flags=%s\n",
|
||||
args.gmtoff, args.sessionnr, buf
|
||||
);
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
Loading…
Reference in New Issue