hsfs.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1991, 2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* The routines in this file are called only after the PROM
* version has been determined to be sunMON.
*
* Basic file system reading code for standalone I/O system.
* Simulates a primitive UNIX I/O system (read(), write(), open(), etc).
* Does not support writes.
*/
#include <sys/sysmacros.h>
#include <iob.h>
#include "hsfs_sig.h"
#define NULL 0
#define TRUE 1
#define FALSE 0
char *bootname = "/hsfsboot";
extern int (*printf_p)();
struct dirstuff {
int loc;
};
struct hs_direct {
struct direct hs_ufs_dir;
struct hs_direntry hs_dir;
};
/* These are the pools of buffers, iob's, etc. */
/* This is the fd for the file(s) */
static i_fd = 1;
/* May not need this... */
/*
* Non-local prototypes
*/
/*
* Local prototypes
*/
static int mountroot(void);
extern int prom_type; /* Determined in main() */
/*
* Exported functions
*/
static int
{
uint_t i;
int retval;
/* Set up the saio request */
return (0);
return (0);
return (0);
}
return (1);
}
static ino_t
{
char *q;
char c;
ino_t n;
return (0);
return (0);
while (*path) {
while (*path == '/')
path++;
q = path;
while (*q != '/' && *q != '\0')
q++;
c = *q;
*q = '\0';
if (c == '\0')
break;
return (0);
*q = c;
path = q;
continue;
} else {
return (0);
}
}
return ((ino_t)n);
}
static ino_t
{
register int len;
if (s == NULL || *s == '\0')
return (0);
return (0);
}
return (0);
}
continue;
continue;
}
}
return (0);
}
/*
* get next entry in a directory.
*/
static struct hs_direct *
{
int off;
for (;;) {
return (NULL);
}
if (off == 0) {
return (NULL);
}
}
continue;
}
return (&hsdep);
}
}
static int
{
#ifdef SPIN_IND
static int pos;
static char ind[] = "|/-\\";
static int blks_read;
#endif /* SPIN_IND */
if (diff <= 0)
return (-1);
/* which block (or frag) in the file do we read? */
return (-1);
#ifdef SPIN_IND
/*
* round and round she goes (though not on every block..
* - Even SunMON proms take some time to actually print stuff)
*/
if ((blks_read++ & 0x3) == 0)
#endif /* SPIN_IND */
return (0);
}
int
{
register i, j;
caddr_t n;
n = buf;
if ((i = count) <= 0)
return (0);
while (i > 0) {
return (0);
}
buf += j;
i -= j;
}
return (buf - n);
}
/*
* We use the token iob for reading the "super block".
*/
static int
{
char *bufp;
int err;
int i;
/* This really has to be done only once. */
if (root_ino == 0) {
/* make the prom open the device */
return (-1); /* if devopen fails, open fails */
/* now opening file system; read the superblock. */
return (-1);
/* Since RRIP is based on ISO9660, that's where we start */
return (-1);
return (-1);
return (-1);
/* Now we fill in the volume descriptor */
/* Make sure we have a valid logical block size */
(*printf_p)("%d invalid logical block size\n",
return (-1);
}
/* Since an HSFS root could be located anywhere on the media! */
}
}
/*
* Open a file. For the bootblock, we assume one file can be opened
* on a ufs filesystem. The underlying device is the one we rode in on.
*/
int
{
register struct hs_direntry *dirp;
register char *bufp;
int err;
/* Make sure we are set up */
mountroot();
return (-1);
}
return (0);
}
int
{
}
/*
* This version of seek() only performs absolute seeks (whence == 0).
*/
int
{
return (0);
}
/*
* Parse a directory entry.
*
*/
static uint_t
int offset, /* offset into dir blk for dir entry */
{
uint_t i;
uchar_t c;
int ret_code;
/* a zero length dir entry terminates the dir block */
return (0);
/* fill in some basic hsfs info */
/* we use lbn of data extent as an inode # equivalent */
if (IDE_REGULAR_FILE(c)) {
} else if (IDE_REGULAR_DIR(c)) {
} else {
(*printf_p)("pd(): file type=0x%x unknown.\n", c);
return (-1);
}
/*
* Massage hsfs name, recognizing special entries for . and ..
* else lopping off version junk.
*/
/* Some initial conditions */
/* Special Case: Current Directory */
/* Special Case: Parent Directory */
/* Other file name */
} else {
for (i = 0; i < nmlen; i++) {
if (c == ';')
break;
else if (c == ' ')
continue;
else
}
}
/* System Use Fields */
if (ce_len > 0) {
/* there is an SUA for this dir entry; go parse it */
if (ce_lbn) {
/*
* store away current position in dir,
* as we will be using the iobuf to reading SUA.
*/
do {
if (ret_code != ISO_SECTOR_SIZE) {
ce_len = 0;
ce_lbn = 0;
break;
}
} while (ce_lbn);
}
}
}
/*
* Parse the System Use Fields in this System Use Area.
* Return blk number of continuation/SUA, or 0 if no continuation/not a SUA.
*/
static uint_t
{
char *susp;
uint_t i;
/*
* A null entry, or an entry with zero length
* terminates the SUSP.
*/
break;
/*
* Compare current entry to all known signatures.
*/
for (i = 0; i < hsfs_num_sig; i++)
break;
switch (i) {
case SUSP_SP_IX:
/* SP signature: field tells us where SUA is */
if (CHECK_BYTES_OK(susp)) {
}
break;
case SUSP_CE_IX:
/*
* CE signature: continuation of SUSP.
* will want to return new lbn, len.
*/
break;
case SUSP_ST_IX:
/* ST signature: terminates SUSP */
return (ce_lbn);
case RRIP_RR_IX:
/* XXX do we want to break when we see a RR? */
break;
case RRIP_NM_IX:
/* NM signature: POSIX-style file name */
if (!RRIP_NAME_FLAGS(susp)) {
}
break;
case HSFS_NUM_SIG:
/* couldn't find a legit susp, terminate loop */
(*printf_p)("parse_susp(): Bad SUSP\n");
break;
default:
}
}
return (ce_lbn);
}