/* $NetBSD: cd9660.c,v 1.5 1997/06/26 19:11:33 drochner Exp $ */
/*
* Copyright (C) 1996 Wolfgang Solfrank.
* Copyright (C) 1996 TooLs GmbH.
* 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
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by TooLs GmbH.
* 4. The name of TooLs GmbH may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
*/
__FBSDID("$FreeBSD$");
/*
* Stand-alone ISO9660 file reading package.
*
* Note: This doesn't support Rock Ridge extensions, extended attributes,
* blocksizes other than 2048 bytes, multi-extent files, etc.
*/
#include <string.h>
#include "stand.h"
typedef struct {
static int cd9660_close(struct open_file *f);
int *lenskip);
static char *rrip_lookup_name(struct open_file *f,
int lenskip);
"cd9660",
};
struct file {
};
struct ptable_ent {
};
static ISO_SUSP_HEADER *
{
char *p, *end;
int error;
/* Names of even length have a padding byte after the name. */
p++;
while (p + 3 < end) {
sh = (ISO_SUSP_HEADER *)p;
return (sh);
return (NULL);
/* Bail if it fails. */
return (NULL);
} else {
/* Ignore this record and skip to the next. */
/* Avoid infinite loops with corrupted file systems */
return (NULL);
}
}
return (NULL);
}
static char *
{
ISO_RRIP_ALTNAME *p;
return (NULL);
if (p == NULL)
return (NULL);
switch (*p->flags) {
case ISO_SUSP_CFLAG_CURRENT:
*len = 1;
return (".");
case ISO_SUSP_CFLAG_PARENT:
*len = 2;
return ("..");
case 0:
return ((char *)p + 5);
default:
/*
* We don't handle hostnames or continued names as they are
* too hard, so just bail and use the default name.
*/
return (NULL);
}
}
static int
{
char *p;
/* First, see if we can find a SP field. */
return (0);
sp = (ISO_SUSP_PRESENT *)p;
return (0);
return (0);
return (0);
/*
* Now look for an ER field. If RRIP is present, then there must
* be at least one of these. It would be more pedantic to walk
* through the list of fields looking for a Rock Ridge ER field.
*/
return (0);
return (1);
}
static int
{
char *cp;
int i, icase;
if (use_rrip)
else
icase = 1;
} else
icase = 0;
break;
continue;
continue;
return 0;
}
return 0;
/*
* Allow stripping of trailing dots and the version number.
* Note that this will find the first instead of the last version
* of a file.
*/
/* This is to prevent matching of numeric extensions */
return 0;
while (--i >= 0)
return 0;
}
return 1;
}
static int
{
void *buf;
/* First find the volume descriptor */
twiddle(1);
if (rc)
goto out;
if (read != ISO_DEFAULT_BLOCK_SIZE) {
goto out;
}
goto out;
goto out;
break;
}
goto out;
first = 1;
use_rrip = 0;
while (*path) {
off = 0;
boff = 0;
if ((off % ISO_DEFAULT_BLOCK_SIZE) == 0) {
twiddle(1);
if (rc)
goto out;
if (read != ISO_DEFAULT_BLOCK_SIZE) {
goto out;
}
boff++;
}
/* skip to next block, if any */
continue;
}
/* See if RRIP is in use. */
if (first)
first = 0;
break;
} else
first = 0;
dp = (struct iso_directory_record *)
/* If the new block has zero length, it is padding. */
/* Skip to next block, if any. */
continue;
}
}
goto out;
}
path++;
}
/* allocate file system specific data structure */
}
if (first) {
/* Check for Rock Ridge since we didn't in the loop above. */
twiddle(1);
if (rc)
goto out;
if (read != ISO_DEFAULT_BLOCK_SIZE) {
goto out;
}
}
if (use_rrip) {
}
return 0;
out:
if (fp)
return rc;
}
static int
{
return 0;
}
static int
{
int rc = 0;
twiddle(16);
if (rc)
return (rc);
if (read != ISO_DEFAULT_BLOCK_SIZE)
return (EIO);
}
return (rc);
}
static int
{
int rc = 0;
while (size) {
break;
if (rc)
break;
}
if (resid)
return (rc);
}
static int
{
int error = 0;
int lenskip;
return (ENOENT);
if (error)
return (error);
/* skip to next block, if any */
goto again;
}
lenskip = 0;
else
} else
if (namelen == 1) {
name = ".";
namelen = 2;
name = "..";
}
}
}
else
return (0);
}
static int
cd9660_write(struct open_file *f __unused, void *start __unused, size_t size __unused, size_t *resid __unused)
{
return EROFS;
}
static off_t
{
switch (where) {
case SEEK_SET:
break;
case SEEK_CUR:
break;
case SEEK_END:
break;
default:
return -1;
}
}
static int
{
/* only important stuff */
else
return 0;
}