Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/newfs_ext2fs Add a bit of swapping for values in CG des...
details: https://anonhg.NetBSD.org/src/rev/5226972f717b
branches: trunk
changeset: 347610:5226972f717b
user: martin <martin%NetBSD.org@localhost>
date: Mon Sep 05 10:44:36 2016 +0000
description:
Add a bit of swapping for values in CG descriptors (used to be done
wholesale in e2fs_cgsave, but now common code keeps them in FS byte
order). Seems to fix newfs_ext2fs on big endian hosts.
diffstat:
sbin/newfs_ext2fs/mke2fs.c | 49 ++++++++++++++++++++++++---------------------
1 files changed, 26 insertions(+), 23 deletions(-)
diffs (131 lines):
diff -r 703f89e579ba -r 5226972f717b sbin/newfs_ext2fs/mke2fs.c
--- a/sbin/newfs_ext2fs/mke2fs.c Mon Sep 05 09:17:35 2016 +0000
+++ b/sbin/newfs_ext2fs/mke2fs.c Mon Sep 05 10:44:36 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mke2fs.c,v 1.24 2016/08/04 17:43:47 jdolecek Exp $ */
+/* $NetBSD: mke2fs.c,v 1.25 2016/09/05 10:44:36 martin Exp $ */
/*-
* Copyright (c) 2007 Izumi Tsutsui. All rights reserved.
@@ -100,7 +100,7 @@
#if 0
static char sccsid[] = "@(#)mkfs.c 8.11 (Berkeley) 5/3/95";
#else
-__RCSID("$NetBSD: mke2fs.c,v 1.24 2016/08/04 17:43:47 jdolecek Exp $");
+__RCSID("$NetBSD: mke2fs.c,v 1.25 2016/09/05 10:44:36 martin Exp $");
#endif
#endif /* not lint */
@@ -495,24 +495,27 @@
EXT2F_COMPAT_RESIZE) != 0)
boffset += sblock.e2fs.e2fs_reserved_ngdb;
}
- gd[cylno].ext2bgd_b_bitmap = boffset;
+ gd[cylno].ext2bgd_b_bitmap = h2fs32(boffset);
boffset += NBLOCK_BLOCK_BITMAP;
- gd[cylno].ext2bgd_i_bitmap = boffset;
+ gd[cylno].ext2bgd_i_bitmap = h2fs32(boffset);
boffset += NBLOCK_INODE_BITMAP;
- gd[cylno].ext2bgd_i_tables = boffset;
+ gd[cylno].ext2bgd_i_tables = h2fs32(boffset);
if (cylno == (ncg - 1))
- gd[cylno].ext2bgd_nbfree =
- blocks_lastcg - cgoverhead(cylno);
+ gd[cylno].ext2bgd_nbfree = h2fs16(
+ blocks_lastcg - cgoverhead(cylno));
else
- gd[cylno].ext2bgd_nbfree =
- sblock.e2fs.e2fs_bpg - cgoverhead(cylno);
- fbcount += gd[cylno].ext2bgd_nbfree;
- gd[cylno].ext2bgd_nifree = sblock.e2fs.e2fs_ipg;
+ gd[cylno].ext2bgd_nbfree = h2fs16(
+ sblock.e2fs.e2fs_bpg - cgoverhead(cylno));
+ fbcount += fs2h16(gd[cylno].ext2bgd_nbfree);
if (cylno == 0) {
/* take reserved inodes off nifree */
- gd[cylno].ext2bgd_nifree -= EXT2_RESERVED_INODES;
+ gd[cylno].ext2bgd_nifree = h2fs16(
+ sblock.e2fs.e2fs_ipg-EXT2_RESERVED_INODES);
+ } else {
+ gd[cylno].ext2bgd_nifree =
+ h2fs16(sblock.e2fs.e2fs_ipg);
}
- ficount += gd[cylno].ext2bgd_nifree;
+ ficount += fs2h16(gd[cylno].ext2bgd_nifree);
gd[cylno].ext2bgd_ndirs = 0;
}
sblock.e2fs.e2fs_fbcount = fbcount;
@@ -729,7 +732,7 @@
i = i * NBBY;
for (; i < cgoverhead(cylno); i++)
setbit(buf, i);
- wtfs(EXT2_FSBTODB(&sblock, gd[cylno].ext2bgd_b_bitmap),
+ wtfs(EXT2_FSBTODB(&sblock, fs2h32(gd[cylno].ext2bgd_b_bitmap)),
sblock.e2fs_bsize, buf);
/*
@@ -747,7 +750,7 @@
for (i = 1; i < EXT2_FIRSTINO; i++)
setbit(buf, EXT2_INO_INDEX(i));
}
- wtfs(EXT2_FSBTODB(&sblock, gd[cylno].ext2bgd_i_bitmap),
+ wtfs(EXT2_FSBTODB(&sblock, fs2h32(gd[cylno].ext2bgd_i_bitmap)),
sblock.e2fs_bsize, buf);
/*
@@ -764,7 +767,7 @@
/* h2fs32() just for consistency */
dp->e2di_gen = h2fs32(arc4random());
}
- wtfs(EXT2_FSBTODB(&sblock, gd[cylno].ext2bgd_i_tables + i),
+ wtfs(EXT2_FSBTODB(&sblock, fs2h32(gd[cylno].ext2bgd_i_tables) + i),
sblock.e2fs_bsize, buf);
}
}
@@ -1264,7 +1267,7 @@
bbp = malloc(sblock.e2fs_bsize);
if (bbp == NULL)
return 0;
- rdfs(EXT2_FSBTODB(&sblock, gd[0].ext2bgd_b_bitmap),
+ rdfs(EXT2_FSBTODB(&sblock, fs2h32(gd[0].ext2bgd_b_bitmap)),
sblock.e2fs_bsize, bbp);
/* XXX: kernel uses e2fs_fpg here */
@@ -1299,13 +1302,13 @@
errx(EXIT_FAILURE, "%s: inconsistent bitmap", __func__);
setbit(bbp, bno);
- wtfs(EXT2_FSBTODB(&sblock, gd[0].ext2bgd_b_bitmap),
+ wtfs(EXT2_FSBTODB(&sblock, fs2h32(gd[0].ext2bgd_b_bitmap)),
sblock.e2fs_bsize, bbp);
free(bbp);
/* XXX: modified group descriptors won't be written into backups */
- gd[0].ext2bgd_nbfree--;
+ gd[0].ext2bgd_nbfree = h2fs16(fs2h16(gd[0].ext2bgd_nbfree)-1);
if ((mode & EXT2_IFDIR) != 0)
- gd[0].ext2bgd_ndirs++;
+ gd[0].ext2bgd_ndirs = h2fs16(fs2h16(gd[0].ext2bgd_ndirs)+1);
sblock.e2fs.e2fs_fbcount--;
return sblock.e2fs.e2fs_first_dblock + bno;
@@ -1343,7 +1346,7 @@
__func__, (uint64_t)ino, c);
/* update inode bitmap */
- rdfs(EXT2_FSBTODB(&sblock, gd[0].ext2bgd_i_bitmap),
+ rdfs(EXT2_FSBTODB(&sblock, fs2h32(gd[0].ext2bgd_i_bitmap)),
sblock.e2fs_bsize, bp);
/* more sanity */
@@ -1351,9 +1354,9 @@
errx(EXIT_FAILURE, "%s: inode %" PRIu64
" already in use", __func__, (uint64_t)ino);
setbit(bp, EXT2_INO_INDEX(ino));
- wtfs(EXT2_FSBTODB(&sblock, gd[0].ext2bgd_i_bitmap),
+ wtfs(EXT2_FSBTODB(&sblock, fs2h32(gd[0].ext2bgd_i_bitmap)),
sblock.e2fs_bsize, bp);
- gd[c].ext2bgd_nifree--;
+ gd[c].ext2bgd_nifree = h2fs16(fs2h16(gd[c].ext2bgd_nifree)-1);
sblock.e2fs.e2fs_ficount--;
}
Home |
Main Index |
Thread Index |
Old Index