Skip to content

Commit

Permalink
bfs: check that filesystem fits on the blockdevice
Browse files Browse the repository at this point in the history
Since all sanity checks rely on the validity of s_start which gets only
checked to be smaller than s_end, we should also check if s_end is sane.
Now we also try to retrieve the last block of the filesystem, which is
computed by s_end.  If this fails, something is bogus.

Signed-off-by: Eric Sesterhenn <[email protected]>
Acked-by: Tigran Aivazian <[email protected]>

Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
SesterhennEric authored and torvalds committed Jan 6, 2009
1 parent e1f89ec commit 50682bb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions fs/bfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,18 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
- le32_to_cpu(bfs_sb->s_start)) >> BFS_BSIZE_BITS;
info->si_freei = 0;
info->si_lf_eblk = 0;

/* can we read the last block? */
bh = sb_bread(s, info->si_blocks - 1);
if (!bh) {
printf("Last block not available: %lu\n", info->si_blocks - 1);
iput(inode);
ret = -EIO;
kfree(info->si_imap);
goto out;
}
brelse(bh);

bh = NULL;
for (i = BFS_ROOT_INO; i <= info->si_lasti; i++) {
struct bfs_inode *di;
Expand Down

0 comments on commit 50682bb

Please sign in to comment.