makefs: Cast daddr_t to off_t before multiplication
Apparently some large-file systems out there, such as my powerpc64le Linux box, define daddr_t as a 32-bit type, which is sad and stymies cross-building disk images. Cast daddr_t to off_t before doing arithmetic that overflows. Reviewed by: arichardson, jrtc27, imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D27458
This commit is contained in:
parent
df4e978765
commit
7ef082733b
@ -70,7 +70,7 @@ bread(struct m_vnode *vp, daddr_t blkno, int size, struct ucred *u1 __unused,
|
|||||||
printf("%s: blkno %lld size %d\n", __func__, (long long)blkno,
|
printf("%s: blkno %lld size %d\n", __func__, (long long)blkno,
|
||||||
size);
|
size);
|
||||||
*bpp = getblk(vp, blkno, size, 0, 0, 0);
|
*bpp = getblk(vp, blkno, size, 0, 0, 0);
|
||||||
offset = (*bpp)->b_blkno * fs->sectorsize + fs->offset;
|
offset = (off_t)(*bpp)->b_blkno * fs->sectorsize + fs->offset;
|
||||||
if (debug & DEBUG_BUF_BREAD)
|
if (debug & DEBUG_BUF_BREAD)
|
||||||
printf("%s: blkno %lld offset %lld bcount %ld\n", __func__,
|
printf("%s: blkno %lld offset %lld bcount %ld\n", __func__,
|
||||||
(long long)(*bpp)->b_blkno, (long long) offset,
|
(long long)(*bpp)->b_blkno, (long long) offset,
|
||||||
@ -130,7 +130,7 @@ bwrite(struct m_buf *bp)
|
|||||||
fsinfo_t *fs = bp->b_fs;
|
fsinfo_t *fs = bp->b_fs;
|
||||||
|
|
||||||
assert (bp != NULL);
|
assert (bp != NULL);
|
||||||
offset = bp->b_blkno * fs->sectorsize + fs->offset;
|
offset = (off_t)bp->b_blkno * fs->sectorsize + fs->offset;
|
||||||
if (debug & DEBUG_BUF_BWRITE)
|
if (debug & DEBUG_BUF_BWRITE)
|
||||||
printf("bwrite: blkno %lld offset %lld bcount %ld\n",
|
printf("bwrite: blkno %lld offset %lld bcount %ld\n",
|
||||||
(long long)bp->b_blkno, (long long) offset,
|
(long long)bp->b_blkno, (long long) offset,
|
||||||
|
@ -794,7 +794,7 @@ ffs_rdfs(daddr_t bno, int size, void *bf, const fsinfo_t *fsopts)
|
|||||||
int n;
|
int n;
|
||||||
off_t offset;
|
off_t offset;
|
||||||
|
|
||||||
offset = bno * fsopts->sectorsize + fsopts->offset;
|
offset = (off_t)bno * fsopts->sectorsize + fsopts->offset;
|
||||||
if (lseek(fsopts->fd, offset, SEEK_SET) < 0)
|
if (lseek(fsopts->fd, offset, SEEK_SET) < 0)
|
||||||
err(1, "%s: seek error for sector %lld", __func__,
|
err(1, "%s: seek error for sector %lld", __func__,
|
||||||
(long long)bno);
|
(long long)bno);
|
||||||
@ -818,7 +818,7 @@ ffs_wtfs(daddr_t bno, int size, void *bf, const fsinfo_t *fsopts)
|
|||||||
int n;
|
int n;
|
||||||
off_t offset;
|
off_t offset;
|
||||||
|
|
||||||
offset = bno * fsopts->sectorsize + fsopts->offset;
|
offset = (off_t)bno * fsopts->sectorsize + fsopts->offset;
|
||||||
if (lseek(fsopts->fd, offset, SEEK_SET) < 0)
|
if (lseek(fsopts->fd, offset, SEEK_SET) < 0)
|
||||||
err(1, "%s: seek error for sector %lld", __func__,
|
err(1, "%s: seek error for sector %lld", __func__,
|
||||||
(long long)bno);
|
(long long)bno);
|
||||||
|
Loading…
Reference in New Issue
Block a user