summaryrefslogtreecommitdiffstats
path: root/sys/boot/common
diff options
context:
space:
mode:
authorsmh <smh@FreeBSD.org>2016-01-28 16:52:02 +0000
committersmh <smh@FreeBSD.org>2016-01-28 16:52:02 +0000
commit7cf27587c4119bcb0ff4c5f60930a61fc32683f2 (patch)
treef22fb47fb8da3036fafeae36c25ca7dbf64f7dee /sys/boot/common
parentee931520cdd5e9ef403c108aaf33f3b98f3ff222 (diff)
downloadFreeBSD-src-7cf27587c4119bcb0ff4c5f60930a61fc32683f2.zip
FreeBSD-src-7cf27587c4119bcb0ff4c5f60930a61fc32683f2.tar.gz
MFC r281060, r294060, r294291, r294493, r294284:
MFC r281060: Remove an unnecessary space in a printf call MFC r294060: Modularise EFI boot loader MFC r294291 (by andrew): Reset the filesystem cache MFC r294493: Fix EFI UFS caching MFC r294284 (by emaste): boot1: correct typo in error message Sponsored by: Multiplay
Diffstat (limited to 'sys/boot/common')
-rw-r--r--sys/boot/common/ufsread.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/sys/boot/common/ufsread.c b/sys/boot/common/ufsread.c
index 08ab697..6f499f9 100644
--- a/sys/boot/common/ufsread.c
+++ b/sys/boot/common/ufsread.c
@@ -165,7 +165,7 @@ static int sblock_try[] = SBLOCKSEARCH;
#endif
static ssize_t
-fsread(ufs_ino_t inode, void *buf, size_t nbyte)
+fsread_size(ufs_ino_t inode, void *buf, size_t nbyte, size_t *fsizep)
{
#ifndef UFS2_ONLY
static struct ufs1_dinode dp1;
@@ -185,6 +185,10 @@ fsread(ufs_ino_t inode, void *buf, size_t nbyte)
static ufs2_daddr_t blkmap, indmap;
u_int u;
+ /* Basic parameter validation. */
+ if ((buf == NULL && nbyte != 0) || dmadat == NULL)
+ return (-1);
+
blkbuf = dmadat->blkbuf;
indbuf = dmadat->indbuf;
@@ -231,18 +235,18 @@ fsread(ufs_ino_t inode, void *buf, size_t nbyte)
return -1;
n = INO_TO_VBO(n, inode);
#if defined(UFS1_ONLY)
- memcpy(&dp1, (struct ufs1_dinode *)blkbuf + n,
- sizeof(struct ufs1_dinode));
+ memcpy(&dp1, (struct ufs1_dinode *)(void *)blkbuf + n,
+ sizeof(dp1));
#elif defined(UFS2_ONLY)
- memcpy(&dp2, (struct ufs2_dinode *)blkbuf + n,
- sizeof(struct ufs2_dinode));
+ memcpy(&dp2, (struct ufs2_dinode *)(void *)blkbuf + n,
+ sizeof(dp2));
#else
if (fs.fs_magic == FS_UFS1_MAGIC)
memcpy(&dp1, (struct ufs1_dinode *)(void *)blkbuf + n,
- sizeof(struct ufs1_dinode));
+ sizeof(dp1));
else
memcpy(&dp2, (struct ufs2_dinode *)(void *)blkbuf + n,
- sizeof(struct ufs2_dinode));
+ sizeof(dp2));
#endif
inomap = inode;
fs_off = 0;
@@ -306,5 +310,17 @@ fsread(ufs_ino_t inode, void *buf, size_t nbyte)
fs_off += n;
nb -= n;
}
+
+ if (fsizep != NULL)
+ *fsizep = size;
+
return nbyte;
}
+
+static ssize_t
+fsread(ufs_ino_t inode, void *buf, size_t nbyte)
+{
+
+ return fsread_size(inode, buf, nbyte, NULL);
+}
+
OpenPOWER on IntegriCloud