Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Fix some assorted 32-bit assumptions not yet otherwise handled.
details: https://anonhg.NetBSD.org/src/rev/ce1cd835b63c
branches: trunk
changeset: 340630:ce1cd835b63c
user: dholland <dholland%NetBSD.org@localhost>
date: Mon Sep 21 01:24:58 2015 +0000
description:
Fix some assorted 32-bit assumptions not yet otherwise handled.
Also apply patch to fix the overt problem in PR 50246: newfs was
calculating ifpb wrong for volumes with non-default block sizes.
diffstat:
sbin/dump_lfs/lfs_inode.c | 10 ++++------
sbin/newfs_lfs/make_lfs.c | 17 +++++++----------
sys/ufs/lfs/lfs_accessors.h | 9 ++++++---
3 files changed, 17 insertions(+), 19 deletions(-)
diffs (136 lines):
diff -r 054cc4419380 -r ce1cd835b63c sbin/dump_lfs/lfs_inode.c
--- a/sbin/dump_lfs/lfs_inode.c Mon Sep 21 01:24:39 2015 +0000
+++ b/sbin/dump_lfs/lfs_inode.c Mon Sep 21 01:24:58 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_inode.c,v 1.26 2015/09/01 06:12:04 dholland Exp $ */
+/* $NetBSD: lfs_inode.c,v 1.27 2015/09/21 01:24:58 dholland Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/1/95";
#else
-__RCSID("$NetBSD: lfs_inode.c,v 1.26 2015/09/01 06:12:04 dholland Exp $");
+__RCSID("$NetBSD: lfs_inode.c,v 1.27 2015/09/21 01:24:58 dholland Exp $");
#endif
#endif /* not lint */
@@ -239,8 +239,7 @@
return UNASSIGNED;
/* printf("lbn %d: parent is the triple\n", -lbn); */
bread(LFS_FSBTODB(sblock, up), bp, lfs_sb_getbsize(sblock));
- /* XXX ondisk32 */
- return (daddr_t)((int32_t *)bp)[off];
+ return lfs_iblock_get(fs, bp, off);
} else /* residue == 0 */ {
/* Single indirect. Two cases. */
if(lbn < BASE_TINDIR) {
@@ -272,8 +271,7 @@
if(up == UNASSIGNED || up == LFS_UNUSED_DADDR)
return UNASSIGNED;
bread(LFS_FSBTODB(sblock, up), bp, lfs_sb_getbsize(sblock));
- /* XXX ondisk32 */
- return (daddr_t)((int32_t *)bp)[off];
+ return lfs_iblock_get(fs, bp, off);
}
static IFILE *
diff -r 054cc4419380 -r ce1cd835b63c sbin/newfs_lfs/make_lfs.c
--- a/sbin/newfs_lfs/make_lfs.c Mon Sep 21 01:24:39 2015 +0000
+++ b/sbin/newfs_lfs/make_lfs.c Mon Sep 21 01:24:58 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: make_lfs.c,v 1.56 2015/09/21 01:24:23 dholland Exp $ */
+/* $NetBSD: make_lfs.c,v 1.57 2015/09/21 01:24:58 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
#if 0
static char sccsid[] = "@(#)lfs.c 8.5 (Berkeley) 5/24/95";
#else
-__RCSID("$NetBSD: make_lfs.c,v 1.56 2015/09/21 01:24:23 dholland Exp $");
+__RCSID("$NetBSD: make_lfs.c,v 1.57 2015/09/21 01:24:58 dholland Exp $");
#endif
#endif /* not lint */
@@ -268,19 +268,17 @@
static void make_dinode(ino_t, union lfs_dinode *, int, struct lfs *);
static void make_dir(struct lfs *, void *,
const struct dirproto *, unsigned);
-static uint64_t maxfilesize(int);
/*
* calculate the maximum file size allowed with the specified block shift.
*/
static uint64_t
-maxfilesize(int bshift)
+maxfilesize(struct lfs *fs, int bshift)
{
uint64_t nptr; /* number of block pointers per block */
uint64_t maxblock;
- /* XXX ondisk32 */
- nptr = (1 << bshift) / sizeof(uint32_t);
+ nptr = (1 << bshift) / LFS_BLKPTRSIZE(fs);
maxblock = ULFS_NDADDR + nptr + nptr * nptr + nptr * nptr * nptr;
return maxblock << bshift;
@@ -522,9 +520,8 @@
lfs_sb_setfrag(fs, lfs_numfrags(fs, bsize));
lfs_sb_setfbmask(fs, lfs_sb_getfrag(fs) - 1);
lfs_sb_setfbshift(fs, lfs_log2(lfs_sb_getfrag(fs)));
- lfs_sb_setifpb(fs, bsize / sizeof(IFILE));
- /* XXX ondisk32 */
- lfs_sb_setnindir(fs, bsize / sizeof(int32_t));
+ lfs_sb_setifpb(fs, bsize / IFILE_ENTRYSIZE(fs));
+ lfs_sb_setnindir(fs, bsize / LFS_BLKPTRSIZE(fs));
}
if (lfs_sb_getversion(fs) == 1) {
@@ -597,7 +594,7 @@
lfs_sb_setnseg(fs, lfs_sb_getdsize(fs) / lfs_segtod(fs, 1));
lfs_sb_setnclean(fs, lfs_sb_getnseg(fs) - 1);
- lfs_sb_setmaxfilesize(fs, maxfilesize(lfs_sb_getbshift(fs)));
+ lfs_sb_setmaxfilesize(fs, maxfilesize(fs, lfs_sb_getbshift(fs)));
if (minfreeseg == 0)
lfs_sb_setminfreeseg(fs, lfs_sb_getnseg(fs) / DFL_MIN_FREE_SEGS);
diff -r 054cc4419380 -r ce1cd835b63c sys/ufs/lfs/lfs_accessors.h
--- a/sys/ufs/lfs/lfs_accessors.h Mon Sep 21 01:24:39 2015 +0000
+++ b/sys/ufs/lfs/lfs_accessors.h Mon Sep 21 01:24:58 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_accessors.h,v 1.32 2015/09/21 01:24:39 dholland Exp $ */
+/* $NetBSD: lfs_accessors.h,v 1.33 2015/09/21 01:24:58 dholland Exp $ */
/* from NetBSD: lfs.h,v 1.165 2015/07/24 06:59:32 dholland Exp */
/* from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp */
@@ -770,6 +770,9 @@
* Index file inode entries.
*/
+#define IFILE_ENTRYSIZE(fs) \
+ ((fs)->lfs_is64 ? sizeof(IFILE64) : sizeof(IFILE32))
+
/*
* LFSv1 compatibility code is not allowed to touch if_atime, since it
* may not be mapped!
@@ -1445,7 +1448,7 @@
* This approximates the old formula of E = C * M / D when D is close to T,
* but avoids falsely reporting "disk full" when the sample size (D) is small.
*/
-#define LFS_EST_CMETA(F) (int32_t)(( \
+#define LFS_EST_CMETA(F) (( \
(lfs_sb_getdmeta(F) * (int64_t)lfs_sb_getnclean(F)) / \
(lfs_sb_getnseg(F))))
@@ -1457,7 +1460,7 @@
lfs_sb_getbfree(F) - LFS_EST_CMETA(F) : 0)
/* Amount of non-meta space not available to mortal man */
-#define LFS_EST_RSVD(F) (int32_t)((LFS_EST_NONMETA(F) * \
+#define LFS_EST_RSVD(F) ((LFS_EST_NONMETA(F) * \
(u_int64_t)lfs_sb_getminfree(F)) / \
100)
Home |
Main Index |
Thread Index |
Old Index