Date: Mon, 26 Feb 2018 00:34:56 +0000 (UTC) From: Kirk McKusick <mckusick@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329997 - head/sys/ufs/ffs Message-ID: <201802260034.w1Q0YuGP042254@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mckusick Date: Mon Feb 26 00:34:56 2018 New Revision: 329997 URL: https://svnweb.freebsd.org/changeset/base/329997 Log: Use a more straight-forward approach to relaxing the location restraints when validating one of the backup superblocks. Modified: head/sys/ufs/ffs/ffs_subr.c Modified: head/sys/ufs/ffs/ffs_subr.c ============================================================================== --- head/sys/ufs/ffs/ffs_subr.c Mon Feb 26 00:04:21 2018 (r329996) +++ head/sys/ufs/ffs/ffs_subr.c Mon Feb 26 00:34:56 2018 (r329997) @@ -140,7 +140,7 @@ ffs_load_inode(struct buf *bp, struct inode *ip, struc * the superblock and its associated data. */ static off_t sblock_try[] = SBLOCKSEARCH; -static int readsuper(void *, struct fs **, off_t, +static int readsuper(void *, struct fs **, off_t, int, int (*)(void *, off_t, void **, int)); /* @@ -174,11 +174,12 @@ ffs_sbget(void *devfd, struct fs **fsp, off_t altsbloc *fsp = NULL; if (altsblock != -1) { - if ((error = readsuper(devfd, fsp, -altsblock, readfunc)) != 0) + if ((error = readsuper(devfd, fsp, altsblock, 1, + readfunc)) != 0) return (error); } else { for (i = 0; sblock_try[i] != -1; i++) { - if ((error = readsuper(devfd, fsp, sblock_try[i], + if ((error = readsuper(devfd, fsp, sblock_try[i], 0, readfunc)) == 0) break; if (error == ENOENT) @@ -238,17 +239,12 @@ ffs_sbget(void *devfd, struct fs **fsp, off_t altsbloc * Return zero on success or an errno on failure. */ static int -readsuper(void *devfd, struct fs **fsp, off_t sblockloc, +readsuper(void *devfd, struct fs **fsp, off_t sblockloc, int isaltsblk, int (*readfunc)(void *devfd, off_t loc, void **bufp, int size)) { struct fs *fs; - int error, altblk; + int error; - altblk = 0; - if (sblockloc < 0) { - altblk = 1; - sblockloc = - sblockloc; - } error = (*readfunc)(devfd, sblockloc, (void **)fsp, SBLOCKSIZE); if (*fsp != NULL) (*fsp)->fs_csp = NULL; /* Not yet any summary information */ @@ -257,9 +253,9 @@ readsuper(void *devfd, struct fs **fsp, off_t sblocklo fs = *fsp; if (fs->fs_magic == FS_BAD_MAGIC) return (EINVAL); - if (((fs->fs_magic == FS_UFS1_MAGIC && (altblk || + if (((fs->fs_magic == FS_UFS1_MAGIC && (isaltsblk || sblockloc <= SBLOCK_UFS1)) || - (fs->fs_magic == FS_UFS2_MAGIC && (altblk || + (fs->fs_magic == FS_UFS2_MAGIC && (isaltsblk || sblockloc == fs->fs_sblockloc))) && fs->fs_ncg >= 1 && fs->fs_bsize >= MINBSIZE &&
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802260034.w1Q0YuGP042254>