git: b679303544b3 - main - fsck_ffs: garbage collect calcsb

From: Ryan Libby <rlibby_at_FreeBSD.org>
Date: Wed, 15 Oct 2025 07:25:26 UTC
The branch main has been updated by rlibby:

URL: https://cgit.FreeBSD.org/src/commit/?id=b679303544b37b980a3128af9248ee97b0bca5e8

commit b679303544b37b980a3128af9248ee97b0bca5e8
Author:     Ryan Libby <rlibby@FreeBSD.org>
AuthorDate: 2025-10-15 04:03:57 +0000
Commit:     Ryan Libby <rlibby@FreeBSD.org>
CommitDate: 2025-10-15 04:03:57 +0000

    fsck_ffs: garbage collect calcsb
    
    calcsb is unused since the logic moved to sbsearch / ffs_sbsearch in
    e68866164212 ("Move the ability to search for alternate UFS superblocks
    from fsck_ffs(8) into ffs_sbsearch() to allow use by other parts of the
    system.")
    
    Reviewed by:    mckusick
    Differential Revision:  https://reviews.freebsd.org/D53038
---
 sbin/fsck_ffs/setup.c | 47 -----------------------------------------------
 1 file changed, 47 deletions(-)

diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c
index f10f02d159c3..41b4a5336350 100644
--- a/sbin/fsck_ffs/setup.c
+++ b/sbin/fsck_ffs/setup.c
@@ -58,7 +58,6 @@ char *copybuf;			       /* buffer to copy snapshot blocks */
 static int sbhashfailed;
 #define POWEROF2(num)	(((num) & ((num) - 1)) == 0)
 
-static int calcsb(char *dev, int devfd, struct fs *fs);
 static void saverecovery(int readfd, int writefd);
 static int chkrecovery(int devfd);
 static int getlbnblkno(struct inodesc *);
@@ -500,52 +499,6 @@ sblock_init(void)
 	dev_bsize = secsize = DEV_BSIZE;
 }
 
-/*
- * Calculate a prototype superblock based on information in the boot area.
- * When done the cgsblock macro can be calculated and the fs_ncg field
- * can be used. Do NOT attempt to use other macros without verifying that
- * their needed information is available!
- */
-static int
-calcsb(char *dev, int devfd, struct fs *fs)
-{
-	struct fsrecovery *fsr;
-	char *fsrbuf;
-	u_int secsize;
-
-	/*
-	 * We need fragments-per-group and the partition-size.
-	 *
-	 * Newfs stores these details at the end of the boot block area
-	 * at the start of the filesystem partition. If they have been
-	 * overwritten by a boot block, we fail. But usually they are
-	 * there and we can use them.
-	 */
-	if (ioctl(devfd, DIOCGSECTORSIZE, &secsize) == -1)
-		return (0);
-	fsrbuf = Balloc(secsize);
-	if (fsrbuf == NULL)
-		errx(EEXIT, "calcsb: cannot allocate recovery buffer");
-	if (blread(devfd, fsrbuf,
-	    (SBLOCK_UFS2 - secsize) / dev_bsize, secsize) != 0) {
-		free(fsrbuf);
-		return (0);
-	}
-	fsr = (struct fsrecovery *)&fsrbuf[secsize - sizeof *fsr];
-	if (fsr->fsr_magic != FS_UFS2_MAGIC) {
-		free(fsrbuf);
-		return (0);
-	}
-	memset(fs, 0, sizeof(struct fs));
-	fs->fs_fpg = fsr->fsr_fpg;
-	fs->fs_fsbtodb = fsr->fsr_fsbtodb;
-	fs->fs_sblkno = fsr->fsr_sblkno;
-	fs->fs_magic = fsr->fsr_magic;
-	fs->fs_ncg = fsr->fsr_ncg;
-	free(fsrbuf);
-	return (1);
-}
-
 /*
  * Check to see if recovery information exists.
  * Return 1 if it exists or cannot be created.