From owner-svn-src-head@freebsd.org Sat Feb 24 03:33:47 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 97808F0FF63; Sat, 24 Feb 2018 03:33:47 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 45E8A6A1D0; Sat, 24 Feb 2018 03:33:47 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 268681FF17; Sat, 24 Feb 2018 03:33:47 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1O3Xk9o067443; Sat, 24 Feb 2018 03:33:46 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1O3Xkic067442; Sat, 24 Feb 2018 03:33:46 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201802240333.w1O3Xkic067442@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Sat, 24 Feb 2018 03:33:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329896 - head/sys/ufs/ffs X-SVN-Group: head X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: head/sys/ufs/ffs X-SVN-Commit-Revision: 329896 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Feb 2018 03:33:47 -0000 Author: mckusick Date: Sat Feb 24 03:33:46 2018 New Revision: 329896 URL: https://svnweb.freebsd.org/changeset/base/329896 Log: Relax 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 Sat Feb 24 02:57:24 2018 (r329895) +++ head/sys/ufs/ffs/ffs_subr.c Sat Feb 24 03:33:46 2018 (r329896) @@ -162,28 +162,28 @@ static int readsuper(void *, struct fs **, off_t, * The administrator must complete newfs before using this volume. */ int -ffs_sbget(void *devfd, struct fs **fsp, off_t altsuperblock, +ffs_sbget(void *devfd, struct fs **fsp, off_t altsblock, struct malloc_type *filltype, int (*readfunc)(void *devfd, off_t loc, void **bufp, int size)) { struct fs *fs; - int i, ret, size, blks; + int i, error, size, blks; uint8_t *space; int32_t *lp; char *buf; *fsp = NULL; - if (altsuperblock != -1) { - if ((ret = readsuper(devfd, fsp, altsuperblock, readfunc)) != 0) - return (ret); + if (altsblock != -1) { + if ((error = readsuper(devfd, fsp, -altsblock, readfunc)) != 0) + return (error); } else { for (i = 0; sblock_try[i] != -1; i++) { - if ((ret = readsuper(devfd, fsp, sblock_try[i], + if ((error = readsuper(devfd, fsp, sblock_try[i], readfunc)) == 0) break; - if (ret == ENOENT) + if (error == ENOENT) continue; - return (ret); + return (error); } if (sblock_try[i] == -1) return (ENOENT); @@ -209,13 +209,13 @@ ffs_sbget(void *devfd, struct fs **fsp, off_t altsuper if (i + fs->fs_frag > blks) size = (blks - i) * fs->fs_fsize; buf = NULL; - ret = (*readfunc)(devfd, + error = (*readfunc)(devfd, dbtob(fsbtodb(fs, fs->fs_csaddr + i)), (void **)&buf, size); - if (ret) { + if (error) { UFS_FREE(buf, filltype); UFS_FREE(fs->fs_csp, filltype); fs->fs_csp = NULL; - return (ret); + return (error); } memcpy(space, buf, size); UFS_FREE(buf, filltype); @@ -242,8 +242,13 @@ readsuper(void *devfd, struct fs **fsp, off_t sblocklo int (*readfunc)(void *devfd, off_t loc, void **bufp, int size)) { struct fs *fs; - int error; + int error, altblk; + 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 */ @@ -252,9 +257,10 @@ 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 && sblockloc <= SBLOCK_UFS1) || - (fs->fs_magic == FS_UFS2_MAGIC && - sblockloc == fs->fs_sblockloc)) && + if (((fs->fs_magic == FS_UFS1_MAGIC && (altblk || + sblockloc <= SBLOCK_UFS1)) || + (fs->fs_magic == FS_UFS2_MAGIC && (altblk || + sblockloc == fs->fs_sblockloc))) && fs->fs_ncg >= 1 && fs->fs_bsize >= MINBSIZE && fs->fs_bsize <= MAXBSIZE &&