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 &&
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to