aboutsummaryrefslogtreecommitdiff
path: root/sbin/fsck_ffs/fsutil.c
diff options
context:
space:
mode:
authorKirk McKusick <mckusick@FreeBSD.org>2018-01-26 00:58:32 +0000
committerKirk McKusick <mckusick@FreeBSD.org>2018-01-26 00:58:32 +0000
commitdffce2150eeac1c7f424324a5cade7a97b308979 (patch)
tree3de8c223a1cb007078f3bb3e3c062127eb1b80a8 /sbin/fsck_ffs/fsutil.c
parenta99028fc70be602db425c092b70dd0221e253bb3 (diff)
downloadsrc-dffce2150eeac1c7f424324a5cade7a97b308979.tar.gz
src-dffce2150eeac1c7f424324a5cade7a97b308979.zip
Refactoring of reading and writing of the UFS/FFS superblock.
Specifically reading is done if ffs_sbget() and writing is done in ffs_sbput(). These functions are exported to libufs via the sbget() and sbput() functions which then used in the various filesystem utilities. This work is in preparation for adding subperblock check hashes. No functional change intended. Reviewed by: kib
Notes
Notes: svn path=/head/; revision=328426
Diffstat (limited to 'sbin/fsck_ffs/fsutil.c')
-rw-r--r--sbin/fsck_ffs/fsutil.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c
index 69c92d7f35c9..d4a5f81bbfa7 100644
--- a/sbin/fsck_ffs/fsutil.c
+++ b/sbin/fsck_ffs/fsutil.c
@@ -348,7 +348,6 @@ getblk(struct bufarea *bp, ufs2_daddr_t blk, long size)
void
flush(int fd, struct bufarea *bp)
{
- int i, j;
if (!bp->b_dirty)
return;
@@ -370,14 +369,8 @@ flush(int fd, struct bufarea *bp)
if (bp != &sblk)
pfatal("BUFFER %p DOES NOT MATCH SBLK %p\n",
bp, &sblk);
- blwrite(fd, bp->b_un.b_buf, bp->b_bno, bp->b_size);
- for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize,
- j++) {
- blwrite(fswritefd, (char *)sblock.fs_csp + i,
- fsbtodb(&sblock,
- sblock.fs_csaddr + j * sblock.fs_frag),
- MIN(sblock.fs_cssize - i, sblock.fs_bsize));
- }
+ if (sbput(fd, (struct fs *)bp->b_un.b_buf, 0) == 0)
+ fsmodified = 1;
break;
case BT_CYLGRP:
if (cgput(&disk, (struct cg *)bp->b_un.b_buf) == 0)
@@ -439,6 +432,8 @@ ckfini(int markclean)
if (havesb && cursnapshot == 0 && sblock.fs_magic == FS_UFS2_MAGIC &&
sblk.b_bno != sblock.fs_sblockloc / dev_bsize &&
!preen && reply("UPDATE STANDARD SUPERBLOCK")) {
+ /* Change the write destination to standard superblock */
+ sblock.fs_sblockactualloc = sblock.fs_sblockloc;
sblk.b_bno = sblock.fs_sblockloc / dev_bsize;
sbdirty();
flush(fswritefd, &sblk);