svn commit: r264414 - in head/sys/boot: amd64/boot1.efi common
Nathan Whitehorn
nwhitehorn at FreeBSD.org
Sun Apr 13 14:50:53 UTC 2014
Author: nwhitehorn
Date: Sun Apr 13 14:50:52 2014
New Revision: 264414
URL: http://svnweb.freebsd.org/changeset/base/264414
Log:
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.
Modified:
head/sys/boot/amd64/boot1.efi/Makefile
head/sys/boot/amd64/boot1.efi/boot1.c
head/sys/boot/common/ufsread.c
Modified: head/sys/boot/amd64/boot1.efi/Makefile
==============================================================================
--- head/sys/boot/amd64/boot1.efi/Makefile Sun Apr 13 11:59:42 2014 (r264413)
+++ head/sys/boot/amd64/boot1.efi/Makefile Sun Apr 13 14:50:52 2014 (r264414)
@@ -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>
Modified: head/sys/boot/amd64/boot1.efi/boot1.c
==============================================================================
--- head/sys/boot/amd64/boot1.efi/boot1.c Sun Apr 13 11:59:42 2014 (r264413)
+++ head/sys/boot/amd64/boot1.efi/boot1.c Sun Apr 13 14:50:52 2014 (r264414)
@@ -169,6 +169,88 @@ dskread(void *buf, u_int64_t lba, int nb
#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);
Modified: head/sys/boot/common/ufsread.c
==============================================================================
--- head/sys/boot/common/ufsread.c Sun Apr 13 11:59:42 2014 (r264413)
+++ head/sys/boot/common/ufsread.c Sun Apr 13 14:50:52 2014 (r264414)
@@ -245,8 +245,6 @@ fsread(ufs_ino_t inode, void *buf, size_
s = buf;
size = DIP(di_size);
n = size - fs_off;
- if (buf == NULL && nbyte == -1)
- return n;
if (nbyte > n)
nbyte = n;
nb = nbyte;
More information about the svn-src-all
mailing list