Dump keeps a bitmap of the state of various inodes, which is sized
to match the number of inodes on the disk. If we find a directory entry with a crazy inode number in it, don't look beyond the end of the bitmap to find that inode's state. Instead skip that directory entry and print a warning. Reviewed by: iedowse MFC after: 3 weeks
This commit is contained in:
parent
be9a006308
commit
3c9d3ce137
@ -74,10 +74,10 @@ union dinode {
|
|||||||
#define HASSUBDIRS 0x2
|
#define HASSUBDIRS 0x2
|
||||||
|
|
||||||
static int dirindir(ino_t ino, ufs2_daddr_t blkno, int level, long *size,
|
static int dirindir(ino_t ino, ufs2_daddr_t blkno, int level, long *size,
|
||||||
long *tapesize, int nodump);
|
long *tapesize, int nodump, ino_t maxino);
|
||||||
static void dmpindir(ino_t ino, ufs2_daddr_t blk, int level, off_t *size);
|
static void dmpindir(ino_t ino, ufs2_daddr_t blk, int level, off_t *size);
|
||||||
static int searchdir(ino_t ino, ufs2_daddr_t blkno, long size, long filesize,
|
static int searchdir(ino_t ino, ufs2_daddr_t blkno, long size, long filesize,
|
||||||
long *tapesize, int nodump);
|
long *tapesize, int nodump, ino_t maxino);
|
||||||
static long blockest(union dinode *dp);
|
static long blockest(union dinode *dp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -190,6 +190,11 @@ mapfiles(ino_t maxino, long *tapesize)
|
|||||||
(dp = getino(ino, &mode)) == NULL ||
|
(dp = getino(ino, &mode)) == NULL ||
|
||||||
(mode & IFMT) == 0)
|
(mode & IFMT) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
if (ino >= maxino) {
|
||||||
|
msg("Skipping inode %d >= maxino %d\n",
|
||||||
|
ino, maxino);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Everything must go in usedinomap so that a check
|
* Everything must go in usedinomap so that a check
|
||||||
* for "in dumpdirmap but not in usedinomap" to detect
|
* for "in dumpdirmap but not in usedinomap" to detect
|
||||||
@ -277,7 +282,7 @@ mapdirs(ino_t maxino, long *tapesize)
|
|||||||
if (DIP(&di, di_db[i]) != 0)
|
if (DIP(&di, di_db[i]) != 0)
|
||||||
ret |= searchdir(ino, DIP(&di, di_db[i]),
|
ret |= searchdir(ino, DIP(&di, di_db[i]),
|
||||||
(long)sblksize(sblock, DIP(&di, di_size),
|
(long)sblksize(sblock, DIP(&di, di_size),
|
||||||
i), filesize, tapesize, nodump);
|
i), filesize, tapesize, nodump, maxino);
|
||||||
if (ret & HASDUMPEDFILE)
|
if (ret & HASDUMPEDFILE)
|
||||||
filesize = 0;
|
filesize = 0;
|
||||||
else
|
else
|
||||||
@ -287,7 +292,7 @@ mapdirs(ino_t maxino, long *tapesize)
|
|||||||
if (DIP(&di, di_ib[i]) == 0)
|
if (DIP(&di, di_ib[i]) == 0)
|
||||||
continue;
|
continue;
|
||||||
ret |= dirindir(ino, DIP(&di, di_ib[i]), i, &filesize,
|
ret |= dirindir(ino, DIP(&di, di_ib[i]), i, &filesize,
|
||||||
tapesize, nodump);
|
tapesize, nodump, maxino);
|
||||||
}
|
}
|
||||||
if (ret & HASDUMPEDFILE) {
|
if (ret & HASDUMPEDFILE) {
|
||||||
SETINO(ino, dumpinomap);
|
SETINO(ino, dumpinomap);
|
||||||
@ -320,7 +325,8 @@ dirindir(
|
|||||||
int ind_level,
|
int ind_level,
|
||||||
long *filesize,
|
long *filesize,
|
||||||
long *tapesize,
|
long *tapesize,
|
||||||
int nodump)
|
int nodump,
|
||||||
|
ino_t maxino)
|
||||||
{
|
{
|
||||||
union {
|
union {
|
||||||
ufs1_daddr_t ufs1[MAXBSIZE / sizeof(ufs1_daddr_t)];
|
ufs1_daddr_t ufs1[MAXBSIZE / sizeof(ufs1_daddr_t)];
|
||||||
@ -338,7 +344,7 @@ dirindir(
|
|||||||
blkno = idblk.ufs2[i];
|
blkno = idblk.ufs2[i];
|
||||||
if (blkno != 0)
|
if (blkno != 0)
|
||||||
ret |= searchdir(ino, blkno, sblock->fs_bsize,
|
ret |= searchdir(ino, blkno, sblock->fs_bsize,
|
||||||
*filesize, tapesize, nodump);
|
*filesize, tapesize, nodump, maxino);
|
||||||
if (ret & HASDUMPEDFILE)
|
if (ret & HASDUMPEDFILE)
|
||||||
*filesize = 0;
|
*filesize = 0;
|
||||||
else
|
else
|
||||||
@ -354,7 +360,7 @@ dirindir(
|
|||||||
blkno = idblk.ufs2[i];
|
blkno = idblk.ufs2[i];
|
||||||
if (blkno != 0)
|
if (blkno != 0)
|
||||||
ret |= dirindir(ino, blkno, ind_level, filesize,
|
ret |= dirindir(ino, blkno, ind_level, filesize,
|
||||||
tapesize, nodump);
|
tapesize, nodump, maxino);
|
||||||
}
|
}
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
@ -371,7 +377,8 @@ searchdir(
|
|||||||
long size,
|
long size,
|
||||||
long filesize,
|
long filesize,
|
||||||
long *tapesize,
|
long *tapesize,
|
||||||
int nodump)
|
int nodump,
|
||||||
|
ino_t maxino)
|
||||||
{
|
{
|
||||||
int mode;
|
int mode;
|
||||||
struct direct *dp;
|
struct direct *dp;
|
||||||
@ -393,6 +400,11 @@ searchdir(
|
|||||||
loc += dp->d_reclen;
|
loc += dp->d_reclen;
|
||||||
if (dp->d_ino == 0)
|
if (dp->d_ino == 0)
|
||||||
continue;
|
continue;
|
||||||
|
if (dp->d_ino >= maxino) {
|
||||||
|
msg("corrupted directory entry, d_ino %d >= %d\n",
|
||||||
|
dp->d_ino, maxino);
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (dp->d_name[0] == '.') {
|
if (dp->d_name[0] == '.') {
|
||||||
if (dp->d_name[1] == '\0')
|
if (dp->d_name[1] == '\0')
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user