Apparently some of the i386 boot blocks are so close to full that adding

single lines to ufsread.c spills them over. Duplicate a whole bunch of
code to get file sizes into boot1.efi/boot1.c rather than modifying
ufsread.c.
This commit is contained in:
Nathan Whitehorn 2014-04-13 14:50:52 +00:00
parent 985e53cfcb
commit 5e1254e13b
3 changed files with 85 additions and 3 deletions

View File

@ -55,6 +55,8 @@ boot1.efi: loader.sym
CFLAGS+= -I${.CURDIR}/../../common
boot1.o: ${.CURDIR}/../../common/ufsread.c
.endif # ${COMPILER_TYPE} != "gcc"
.include <bsd.prog.mk>

View File

@ -169,6 +169,88 @@ dskread(void *buf, u_int64_t lba, int nblk)
#include "ufsread.c"
static ssize_t
fsstat(ufs_ino_t inode)
{
#ifndef UFS2_ONLY
static struct ufs1_dinode dp1;
ufs1_daddr_t addr1;
#endif
#ifndef UFS1_ONLY
static struct ufs2_dinode dp2;
#endif
static struct fs fs;
static ufs_ino_t inomap;
char *blkbuf;
void *indbuf;
size_t n, nb, size, off, vboff;
ufs_lbn_t lbn;
ufs2_daddr_t addr2, vbaddr;
static ufs2_daddr_t blkmap, indmap;
u_int u;
blkbuf = dmadat->blkbuf;
indbuf = dmadat->indbuf;
if (!dsk_meta) {
inomap = 0;
for (n = 0; sblock_try[n] != -1; n++) {
if (dskread(dmadat->sbbuf, sblock_try[n] / DEV_BSIZE,
SBLOCKSIZE / DEV_BSIZE))
return -1;
memcpy(&fs, dmadat->sbbuf, sizeof(struct fs));
if ((
#if defined(UFS1_ONLY)
fs.fs_magic == FS_UFS1_MAGIC
#elif defined(UFS2_ONLY)
(fs.fs_magic == FS_UFS2_MAGIC &&
fs.fs_sblockloc == sblock_try[n])
#else
fs.fs_magic == FS_UFS1_MAGIC ||
(fs.fs_magic == FS_UFS2_MAGIC &&
fs.fs_sblockloc == sblock_try[n])
#endif
) &&
fs.fs_bsize <= MAXBSIZE &&
fs.fs_bsize >= sizeof(struct fs))
break;
}
if (sblock_try[n] == -1) {
printf("Not ufs\n");
return -1;
}
dsk_meta++;
} else
memcpy(&fs, dmadat->sbbuf, sizeof(struct fs));
if (!inode)
return 0;
if (inomap != inode) {
n = IPERVBLK(&fs);
if (dskread(blkbuf, INO_TO_VBA(&fs, n, inode), DBPERVBLK))
return -1;
n = INO_TO_VBO(n, inode);
#if defined(UFS1_ONLY)
memcpy(&dp1, (struct ufs1_dinode *)blkbuf + n,
sizeof(struct ufs1_dinode));
#elif defined(UFS2_ONLY)
memcpy(&dp2, (struct ufs2_dinode *)blkbuf + n,
sizeof(struct ufs2_dinode));
#else
if (fs.fs_magic == FS_UFS1_MAGIC)
memcpy(&dp1, (struct ufs1_dinode *)blkbuf + n,
sizeof(struct ufs1_dinode));
else
memcpy(&dp2, (struct ufs2_dinode *)blkbuf + n,
sizeof(struct ufs2_dinode));
#endif
inomap = inode;
fs_off = 0;
blkmap = indmap = 0;
}
size = DIP(di_size);
n = size - fs_off;
return (n);
}
static struct dmadat __dmadat;
static int
@ -203,7 +285,7 @@ load(const char *fname)
return;
}
bufsize = fsread(ino, NULL, -1);
bufsize = fsstat(ino);
status = systab->BootServices->AllocatePool(EfiLoaderData,
bufsize, &buffer);
fsread(ino, buffer, bufsize);

View File

@ -245,8 +245,6 @@ fsread(ufs_ino_t inode, void *buf, size_t nbyte)
s = buf;
size = DIP(di_size);
n = size - fs_off;
if (buf == NULL && nbyte == -1)
return n;
if (nbyte > n)
nbyte = n;
nb = nbyte;