Module Name: src
Committed By: dholland
Date: Mon Sep 21 01:24:58 UTC 2015
Modified Files:
src/sbin/dump_lfs: lfs_inode.c
src/sbin/newfs_lfs: make_lfs.c
src/sys/ufs/lfs: lfs_accessors.h
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sbin/dump_lfs/lfs_inode.c
cvs rdiff -u -r1.56 -r1.57 src/sbin/newfs_lfs/make_lfs.c
cvs rdiff -u -r1.32 -r1.33 src/sys/ufs/lfs/lfs_accessors.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/dump_lfs/lfs_inode.c
diff -u src/sbin/dump_lfs/lfs_inode.c:1.26 src/sbin/dump_lfs/lfs_inode.c:1.27
--- src/sbin/dump_lfs/lfs_inode.c:1.26 Tue Sep 1 06:12:04 2015
+++ src/sbin/dump_lfs/lfs_inode.c Mon Sep 21 01:24:58 2015
@@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
#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 @@ lfs_bmap(struct lfs *fs, union lfs_dinod
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 @@ lfs_bmap(struct lfs *fs, union lfs_dinod
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 *
Index: src/sbin/newfs_lfs/make_lfs.c
diff -u src/sbin/newfs_lfs/make_lfs.c:1.56 src/sbin/newfs_lfs/make_lfs.c:1.57
--- src/sbin/newfs_lfs/make_lfs.c:1.56 Mon Sep 21 01:24:23 2015
+++ src/sbin/newfs_lfs/make_lfs.c Mon Sep 21 01:24:58 2015
@@ -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 @@ void pwarn(const char *, ...);
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 @@ make_lfs(int devfd, uint secsize, struct
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 @@ make_lfs(int devfd, uint secsize, struct
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);
Index: src/sys/ufs/lfs/lfs_accessors.h
diff -u src/sys/ufs/lfs/lfs_accessors.h:1.32 src/sys/ufs/lfs/lfs_accessors.h:1.33
--- src/sys/ufs/lfs/lfs_accessors.h:1.32 Mon Sep 21 01:24:39 2015
+++ src/sys/ufs/lfs/lfs_accessors.h Mon Sep 21 01:24:58 2015
@@ -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 @@ lfs_fi_setblock(STRUCT_LFS *fs, FINFO *f
* 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 @@ lfs_blocks_sub(STRUCT_LFS *fs, union lfs
* 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_blocks_sub(STRUCT_LFS *fs, union lfs
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)