Relax the location restraints when validating one of the
backup superblocks.
This commit is contained in:
parent
82c85a42b4
commit
4cbd996a84
@ -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 altsuperblock,
|
||||
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 sblockloc,
|
||||
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 sblockloc,
|
||||
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 &&
|
||||
|
Loading…
x
Reference in New Issue
Block a user