Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x68k/stand/boot_ufs Support UFS2 format for FFS.
details: https://anonhg.NetBSD.org/src/rev/a696177a9090
branches: trunk
changeset: 545463:a696177a9090
user: itohy <itohy%NetBSD.org@localhost>
date: Wed Apr 09 12:57:13 2003 +0000
description:
Support UFS2 format for FFS.
diffstat:
sys/arch/x68k/stand/boot_ufs/Makefile | 4 +-
sys/arch/x68k/stand/boot_ufs/bootmain.c | 4 +-
sys/arch/x68k/stand/boot_ufs/readufs.c | 142 +++++++++++++++++++---------
sys/arch/x68k/stand/boot_ufs/readufs.h | 70 ++++++++++++-
sys/arch/x68k/stand/boot_ufs/readufs_ffs.c | 95 +++++++++++++-----
sys/arch/x68k/stand/boot_ufs/readufs_lfs.c | 49 ++++++---
6 files changed, 261 insertions(+), 103 deletions(-)
diffs (truncated from 763 to 300 lines):
diff -r 6b40757c0162 -r a696177a9090 sys/arch/x68k/stand/boot_ufs/Makefile
--- a/sys/arch/x68k/stand/boot_ufs/Makefile Wed Apr 09 12:55:50 2003 +0000
+++ b/sys/arch/x68k/stand/boot_ufs/Makefile Wed Apr 09 12:57:13 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.12 2003/02/02 07:10:54 isaki Exp $
+# $NetBSD: Makefile,v 1.13 2003/04/09 12:57:13 itohy Exp $
NOMAN= # defined
@@ -40,7 +40,7 @@
CPPFLAGS+= -DBOOT=\"$(BOOT)\" -DBOOT_VERS=\"$(VERSION)\"
CPPFLAGS+= -DSCSI_ADHOC_BOOTPART
#CPPFLAGS+= -DBOOT_DEBUG
-CPPFLAGS+= -DUSE_FFS -DUSE_LFS -D__daddr_t=int32_t
+CPPFLAGS+= -DUSE_FFS -DUSE_LFS -DUSE_UFS1 -DUSE_UFS2 -D__daddr_t=int32_t
CPPFLAGS+= -I${COMMONDIR} -I${LIBIOCS}
AFLAGS= ${CFLAGS:M-[ID]*}
.if ${OBJECT_FMT} == "ELF"
diff -r 6b40757c0162 -r a696177a9090 sys/arch/x68k/stand/boot_ufs/bootmain.c
--- a/sys/arch/x68k/stand/boot_ufs/bootmain.c Wed Apr 09 12:55:50 2003 +0000
+++ b/sys/arch/x68k/stand/boot_ufs/bootmain.c Wed Apr 09 12:57:13 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bootmain.c,v 1.4 2001/11/24 16:22:54 minoura Exp $ */
+/* $NetBSD: bootmain.c,v 1.5 2003/04/09 12:57:14 itohy Exp $ */
/*-
* Copyright (c) 1993, 1994 Takumi Nakamura.
@@ -214,7 +214,7 @@
unsigned int addr;
struct exec *header;
{
- struct dinode dinode;
+ union ufs_dinode dinode;
/* look-up the file */
if (ino == 0 || ufs_get_inode(ino, &dinode)) {
diff -r 6b40757c0162 -r a696177a9090 sys/arch/x68k/stand/boot_ufs/readufs.c
--- a/sys/arch/x68k/stand/boot_ufs/readufs.c Wed Apr 09 12:55:50 2003 +0000
+++ b/sys/arch/x68k/stand/boot_ufs/readufs.c Wed Apr 09 12:57:13 2003 +0000
@@ -1,19 +1,16 @@
-/* from Id: readufs.c,v 1.7 2002/01/26 15:55:51 itohy Exp */
+/* $NetBSD: readufs.c,v 1.4 2003/04/09 12:57:14 itohy Exp $ */
+/* from Id: readufs.c,v 1.8 2003/04/08 09:19:32 itohy Exp */
/*
* Read UFS (FFS / LFS)
*
- * Written by ITOH, Yasufumi (itohy%netbsd.org@localhost).
+ * Written in 1999, 2002, 2003 by ITOH Yasufumi (itohy%netbsd.org@localhost).
* Public domain.
*
* Intended to be used for boot programs (first stage).
* DON'T ADD ANY FANCY FEATURE. THIS SHALL BE COMPACT.
*/
-#include <sys/types.h>
-#include <sys/param.h>
-#include <ufs/ufs/dinode.h>
-
#include "readufs.h"
#define fs ufs_info
@@ -36,8 +33,10 @@
daddr_t blkpos;
size_t bytelen;
{
+
if (pread(fd, buf, bytelen, (off_t)dbtob(blkpos)) != (ssize_t) bytelen)
- err(1, "pread: buf %p, blk %u, len %u", buf, blkpos, bytelen);
+ err(1, "pread: buf %p, blk %d, len %u",
+ buf, (int) blkpos, bytelen);
}
#endif
@@ -65,7 +64,7 @@
} else {
#ifdef DEBUG_WITH_STDIO
printf("raw_read_queue: read: buf %p, blk %d, len %d\n",
- rq_buf, rq_start, rq_len);
+ rq_buf, (int) rq_start, rq_len);
#endif
RAW_READ(rq_buf, rq_start, rq_len);
}
@@ -77,7 +76,7 @@
#define RAW_READ_QUEUE_INIT() (rq_len = 0)
#define RAW_READ_QUEUE_FLUSH() \
- raw_read_queue((void *) 0, (u_int32_t) 0, (size_t) 0)
+ raw_read_queue((void *) 0, (daddr_t) 0, (size_t) 0)
/*
@@ -86,21 +85,29 @@
*/
size_t
ufs_read(di, buf, off, count)
- struct dinode *di;
+ union ufs_dinode *di;
void *buf;
unsigned off; /* position in block */
size_t count;
{
- size_t bsize = fs.bsize;
+ struct ufs_info *ufsinfo = &fs;
+ size_t bsize = ufsinfo->bsize;
caddr_t b = buf;
int i;
- size_t nread;
+ size_t disize, nread;
+ daddr_t pos;
+#if defined(USE_UFS1) && defined(USE_UFS2)
+ enum ufs_ufstype uver = ufsinfo->ufstype;
+#endif
#ifdef DEBUG_WITH_STDIO
printf("ufs_read: off: %d, count %u\n", off, count);
#endif
- if ((size_t) di->di_size < count + off * bsize)
- count = (size_t) di->di_size - off * bsize;
+
+ disize = DI_SIZE(di);
+
+ if (disize < count + off * bsize)
+ count = disize - off * bsize;
/* FS block size alignment. */
nread = count;
@@ -110,23 +117,40 @@
/* Read direct blocks. */
for ( ; off < NDADDR && count > 0; off++) {
+#if defined(USE_UFS1) && defined(USE_UFS2)
+ if (uver == UFSTYPE_UFS1)
+ pos = di->di1.di_db[off];
+ else
+ pos = di->di2.di_db[off];
+#else
+ pos = di->di_thisver.di_db[off];
+#endif
#if 0
printf("ufs_read: read: blk: %d\n",
- di->di_db[off] << fs.fsbtodb);
+ (int) pos << ufsinfo->fsbtodb);
#endif
- raw_read_queue(b, di->di_db[off] << fs.fsbtodb, bsize);
+ raw_read_queue(b, pos << ufsinfo->fsbtodb, bsize);
b += bsize;
count -= bsize;
}
off -= NDADDR;
/* Read indirect blocks. */
- for (i = 0; i < NIADDR && count > 0; i++)
- count = ufs_read_indirect(di->di_ib[i], i, &b, &off, count);
+ for (i = 0; i < NIADDR && count > 0; i++) {
+#if defined(USE_UFS1) && defined(USE_UFS2)
+ if (uver == UFSTYPE_UFS1)
+ pos = di->di1.di_ib[i];
+ else
+ pos = di->di2.di_ib[i];
+#else
+ pos = di->di_thisver.di_ib[i];
+#endif
+ count = ufs_read_indirect(pos, i, &b, &off, count);
+ }
RAW_READ_QUEUE_FLUSH();
- return (size_t) nread;
+ return nread;
}
static int
@@ -137,9 +161,16 @@
unsigned *poff; /* position in block */
size_t count;
{
- size_t bsize = fs.bsize;
- /* XXX ondisk32 */
- int32_t *idbuf = alloca(bsize);
+ struct ufs_info *ufsinfo = &fs;
+ size_t bsize = ufsinfo->bsize;
+ void *idbuf = alloca(bsize);
+#ifdef USE_UFS1
+ int32_t *idbuf1 = idbuf;
+#endif
+#ifdef USE_UFS2
+ int64_t *idbuf2 = idbuf;
+#endif
+ daddr_t pos;
unsigned off = *poff;
unsigned b;
@@ -151,8 +182,8 @@
int i;
for (i = level; i > 0; i--)
- subindirsize *= fs.nindir;
- indirsize = subindirsize * fs.nindir;
+ subindirsize *= ufsinfo->nindir;
+ indirsize = subindirsize * ufsinfo->nindir;
if (off >= indirsize) {
/* no need to read any data */
*poff = off - indirsize;
@@ -166,17 +197,30 @@
b = 0;
/* read the indirect block */
- RAW_READ(idbuf, blk << fs.fsbtodb, bsize);
+ RAW_READ(idbuf, blk << ufsinfo->fsbtodb, bsize);
- for ( ; b < fs.nindir && count > 0; b++) {
+ for ( ; b < ufsinfo->nindir && count > 0; b++) {
+#if defined(USE_UFS1) && defined(USE_UFS2)
+ if (ufsinfo->ufstype == UFSTYPE_UFS1)
+#endif
+#ifdef USE_UFS1
+ pos = idbuf1[b];
+#endif
+#if defined(USE_UFS1) && defined(USE_UFS2)
+ else
+#endif
+#ifdef USE_UFS2
+ pos = idbuf2[b];
+#endif
+
if (level)
- count = ufs_read_indirect(idbuf[b], level - 1, buf, &off, count);
+ count = ufs_read_indirect(pos, level - 1, buf, &off, count);
else {
#if 0
printf("ufs_read: read: blk: %d\n",
- idbuf[b] << fs.fsbtodb);
+ (int) pos << ufsinfo->fsbtodb);
#endif
- raw_read_queue(*buf, idbuf[b] << fs.fsbtodb, bsize);
+ raw_read_queue(*buf, pos << ufsinfo->fsbtodb, bsize);
*buf += bsize;
count -= bsize;
}
@@ -193,23 +237,26 @@
ino_t dirino;
const char *fn;
{
- struct dinode dirdi;
+ union ufs_dinode dirdi;
struct direct *pdir;
char *p, *endp;
+ size_t disize;
if (ufs_get_inode(dirino, &dirdi))
return 0;
- if ((dirdi.di_mode & IFMT) != IFDIR)
+ if ((dirdi.di_common.di_mode & IFMT) != IFDIR)
return 0; /* Not a directory */
+ disize = DI_SIZE(&dirdi);
+
#if 0
- p = alloca(((size_t) dirdi.di_size + fs.bsize - 1) & ~(fs.bsize - 1));
+ p = alloca((disize + fs.bsize - 1) & ~(fs.bsize - 1));
#else /* simplify calculation to reduce code size */
- p = alloca((size_t) dirdi.di_size + fs.bsize);
+ p = alloca(disize + fs.bsize);
#endif
- ufs_read(&dirdi, p, 0, (size_t) dirdi.di_size);
- endp = p + dirdi.di_size;
+ ufs_read(&dirdi, p, 0, disize);
+ endp = p + disize;
for ( ; pdir = (void *) p, p < endp; p += pdir->d_reclen) {
if (pdir->d_ino && !strcmp(fn, pdir->d_name))
return pdir->d_ino;
@@ -247,12 +294,13 @@
ino_t dirino;
const char *fn;
{
- size_t cnt;
- struct dinode dinode;
+ size_t cnt, disize;
+ union ufs_dinode dinode;
if (ufs_fn_inode(dirino, fn, &dinode))
return (unsigned) 0;
- cnt = ufs_read(&dinode, buf, 0, (size_t) dinode.di_size);
+ disize = DI_SIZE(&dinode);
+ cnt = ufs_read(&dinode, buf, 0, disize);
return cnt;
}
@@ -276,16 +324,18 @@
ufs_list_dir(dirino)
ino_t dirino;
{
- struct dinode dirdi;
+ union ufs_dinode dirdi;
struct direct *pdir;
char *p, *endp;
+ size_t disize;
Home |
Main Index |
Thread Index |
Old Index