From ada981b228eba1fdb31f9817c015e69a757e1cb3 Mon Sep 17 00:00:00 2001 From: Kirk McKusick Date: Wed, 27 Nov 2002 02:18:58 +0000 Subject: Create a new 32-bit fs_flags word in the superblock. Add code to move the old 8-bit fs_old_flags to the new location the first time that the filesystem is mounted by a new kernel. One of the unused flags in fs_old_flags is used to indicate that the flags have been moved. Leave the fs_old_flags word intact so that it will work properly if used on an old kernel. Change the fs_sblockloc superblock location field to be in units of bytes instead of in units of filesystem fragments. The old units did not work properly when the fragment size exceeeded the superblock size (8192). Update old fs_sblockloc values at the same time that the flags are moved. Suggested by: BOUWSMA Barry Sponsored by: DARPA & NAI Labs. --- sbin/newfs/mkfs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sbin/newfs/mkfs.c') diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index 2de9b43ffe9a..837f608d2855 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -149,6 +149,7 @@ mkfs(struct partition *pp, char *fsys) exit(38); } bzero(iobuf, iobufsize); + sblock.fs_old_flags = FS_FLAGS_UPDATED; sblock.fs_flags = 0; if (Uflag) sblock.fs_flags |= FS_DOSOFTDEP; @@ -243,7 +244,7 @@ mkfs(struct partition *pp, char *fsys) sblock.fs_size = fssize = dbtofsb(&sblock, fssize); if (Oflag == 1) { sblock.fs_magic = FS_UFS1_MAGIC; - sblock.fs_sblockloc = numfrags(&sblock, SBLOCK_UFS1); + sblock.fs_sblockloc = SBLOCK_UFS1; sblock.fs_nindir = sblock.fs_bsize / sizeof(ufs1_daddr_t); sblock.fs_inopb = sblock.fs_bsize / sizeof(struct ufs1_dinode); sblock.fs_maxsymlinklen = ((NDADDR + NIADDR) * @@ -263,15 +264,15 @@ mkfs(struct partition *pp, char *fsys) sblock.fs_old_nrpos = 1; } else { sblock.fs_magic = FS_UFS2_MAGIC; - sblock.fs_sblockloc = numfrags(&sblock, SBLOCK_UFS2); + sblock.fs_sblockloc = SBLOCK_UFS2; sblock.fs_nindir = sblock.fs_bsize / sizeof(ufs2_daddr_t); sblock.fs_inopb = sblock.fs_bsize / sizeof(struct ufs2_dinode); sblock.fs_maxsymlinklen = ((NDADDR + NIADDR) * sizeof(ufs2_daddr_t)); } sblock.fs_sblkno = - roundup(howmany(lfragtosize(&sblock, sblock.fs_sblockloc) + - SBLOCKSIZE, sblock.fs_fsize), sblock.fs_frag); + roundup(howmany(sblock.fs_sblockloc + SBLOCKSIZE, sblock.fs_fsize), + sblock.fs_frag); sblock.fs_cblkno = sblock.fs_sblkno + roundup(howmany(SBLOCKSIZE, sblock.fs_fsize), sblock.fs_frag); sblock.fs_iblkno = sblock.fs_cblkno + sblock.fs_frag; @@ -476,8 +477,7 @@ mkfs(struct partition *pp, char *fsys) sblock.fs_old_cstotal.cs_nifree = sblock.fs_cstotal.cs_nifree; sblock.fs_old_cstotal.cs_nffree = sblock.fs_cstotal.cs_nffree; } - wtfs(lfragtosize(&sblock, sblock.fs_sblockloc) / sectorsize, - SBLOCKSIZE, (char *)&sblock); + wtfs(sblock.fs_sblockloc / sectorsize, SBLOCKSIZE, (char *)&sblock); for (i = 0; i < sblock.fs_cssize; i += sblock.fs_bsize) wtfs(fsbtodb(&sblock, sblock.fs_csaddr + numfrags(&sblock, i)), sblock.fs_cssize - i < sblock.fs_bsize ? -- cgit v1.2.3