Use a more straight-forward approach to relaxing the location
restraints when validating one of the backup superblocks.
This commit is contained in:
parent
16e39c48a3
commit
528833fae1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329997
@ -140,7 +140,7 @@ ffs_load_inode(struct buf *bp, struct inode *ip, struct fs *fs, ino_t ino)
|
|||||||
* the superblock and its associated data.
|
* the superblock and its associated data.
|
||||||
*/
|
*/
|
||||||
static off_t sblock_try[] = SBLOCKSEARCH;
|
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));
|
int (*)(void *, off_t, void **, int));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -174,11 +174,12 @@ ffs_sbget(void *devfd, struct fs **fsp, off_t altsblock,
|
|||||||
|
|
||||||
*fsp = NULL;
|
*fsp = NULL;
|
||||||
if (altsblock != -1) {
|
if (altsblock != -1) {
|
||||||
if ((error = readsuper(devfd, fsp, -altsblock, readfunc)) != 0)
|
if ((error = readsuper(devfd, fsp, altsblock, 1,
|
||||||
|
readfunc)) != 0)
|
||||||
return (error);
|
return (error);
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; sblock_try[i] != -1; i++) {
|
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)
|
readfunc)) == 0)
|
||||||
break;
|
break;
|
||||||
if (error == ENOENT)
|
if (error == ENOENT)
|
||||||
@ -238,17 +239,12 @@ ffs_sbget(void *devfd, struct fs **fsp, off_t altsblock,
|
|||||||
* Return zero on success or an errno on failure.
|
* Return zero on success or an errno on failure.
|
||||||
*/
|
*/
|
||||||
static int
|
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))
|
int (*readfunc)(void *devfd, off_t loc, void **bufp, int size))
|
||||||
{
|
{
|
||||||
struct fs *fs;
|
struct fs *fs;
|
||||||
int error, altblk;
|
int error;
|
||||||
|
|
||||||
altblk = 0;
|
|
||||||
if (sblockloc < 0) {
|
|
||||||
altblk = 1;
|
|
||||||
sblockloc = - sblockloc;
|
|
||||||
}
|
|
||||||
error = (*readfunc)(devfd, sblockloc, (void **)fsp, SBLOCKSIZE);
|
error = (*readfunc)(devfd, sblockloc, (void **)fsp, SBLOCKSIZE);
|
||||||
if (*fsp != NULL)
|
if (*fsp != NULL)
|
||||||
(*fsp)->fs_csp = NULL; /* Not yet any summary information */
|
(*fsp)->fs_csp = NULL; /* Not yet any summary information */
|
||||||
@ -257,9 +253,9 @@ readsuper(void *devfd, struct fs **fsp, off_t sblockloc,
|
|||||||
fs = *fsp;
|
fs = *fsp;
|
||||||
if (fs->fs_magic == FS_BAD_MAGIC)
|
if (fs->fs_magic == FS_BAD_MAGIC)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
if (((fs->fs_magic == FS_UFS1_MAGIC && (altblk ||
|
if (((fs->fs_magic == FS_UFS1_MAGIC && (isaltsblk ||
|
||||||
sblockloc <= SBLOCK_UFS1)) ||
|
sblockloc <= SBLOCK_UFS1)) ||
|
||||||
(fs->fs_magic == FS_UFS2_MAGIC && (altblk ||
|
(fs->fs_magic == FS_UFS2_MAGIC && (isaltsblk ||
|
||||||
sblockloc == fs->fs_sblockloc))) &&
|
sblockloc == fs->fs_sblockloc))) &&
|
||||||
fs->fs_ncg >= 1 &&
|
fs->fs_ncg >= 1 &&
|
||||||
fs->fs_bsize >= MINBSIZE &&
|
fs->fs_bsize >= MINBSIZE &&
|
||||||
|
Loading…
Reference in New Issue
Block a user