* grub-core/fs/nilfs2.c (grub_nilfs2_load_sb): Handle grub_disk_read
errors.
This commit is contained in:
parent
671404469c
commit
b17540cbd9
2 changed files with 21 additions and 10 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2010-08-28 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/fs/nilfs2.c (grub_nilfs2_load_sb): Handle grub_disk_read
|
||||||
|
errors.
|
||||||
|
|
||||||
2010-08-27 Vladimir Serbinenko <phcoder@gmail.com>
|
2010-08-27 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
Handle USB pendrives exposed as floppies.
|
Handle USB pendrives exposed as floppies.
|
||||||
|
|
|
@ -718,10 +718,13 @@ grub_nilfs2_load_sb (struct grub_nilfs2_data *data)
|
||||||
grub_uint64_t partition_size;
|
grub_uint64_t partition_size;
|
||||||
int valid[2];
|
int valid[2];
|
||||||
int swp = 0;
|
int swp = 0;
|
||||||
|
grub_err_t err;
|
||||||
|
|
||||||
/* Read first super block. */
|
/* Read first super block. */
|
||||||
grub_disk_read (disk, NILFS_1ST_SUPER_BLOCK, 0,
|
err = grub_disk_read (disk, NILFS_1ST_SUPER_BLOCK, 0,
|
||||||
sizeof (struct grub_nilfs2_super_block), &data->sblock);
|
sizeof (struct grub_nilfs2_super_block), &data->sblock);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
/* Make sure if 1st super block is valid. */
|
/* Make sure if 1st super block is valid. */
|
||||||
valid[0] = grub_nilfs2_valid_sb (&data->sblock);
|
valid[0] = grub_nilfs2_valid_sb (&data->sblock);
|
||||||
|
|
||||||
|
@ -729,17 +732,21 @@ grub_nilfs2_load_sb (struct grub_nilfs2_data *data)
|
||||||
if (partition_size != GRUB_DISK_SIZE_UNKNOWN)
|
if (partition_size != GRUB_DISK_SIZE_UNKNOWN)
|
||||||
{
|
{
|
||||||
/* Read second super block. */
|
/* Read second super block. */
|
||||||
grub_disk_read (disk, NILFS_2ND_SUPER_BLOCK (partition_size), 0,
|
err = grub_disk_read (disk, NILFS_2ND_SUPER_BLOCK (partition_size), 0,
|
||||||
sizeof (struct grub_nilfs2_super_block), &sb2);
|
sizeof (struct grub_nilfs2_super_block), &sb2);
|
||||||
/* Make sure if 2nd super block is valid. */
|
if (err)
|
||||||
valid[1] = grub_nilfs2_valid_sb (&sb2);
|
{
|
||||||
|
valid[1] = 0;
|
||||||
|
grub_errno = GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/* Make sure if 2nd super block is valid. */
|
||||||
|
valid[1] = grub_nilfs2_valid_sb (&sb2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* 2nd super block may not exist, so it's invalid. */
|
/* 2nd super block may not exist, so it's invalid. */
|
||||||
valid[1] = 0;
|
valid[1] = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!valid[0] && !valid[1])
|
if (!valid[0] && !valid[1])
|
||||||
return grub_error (GRUB_ERR_BAD_FS, "not a nilfs2 filesystem");
|
return grub_error (GRUB_ERR_BAD_FS, "not a nilfs2 filesystem");
|
||||||
|
|
||||||
|
@ -752,8 +759,7 @@ grub_nilfs2_load_sb (struct grub_nilfs2_data *data)
|
||||||
grub_memcpy (&data->sblock, &sb2,
|
grub_memcpy (&data->sblock, &sb2,
|
||||||
sizeof (struct grub_nilfs2_super_block));
|
sizeof (struct grub_nilfs2_super_block));
|
||||||
|
|
||||||
grub_errno = GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
return grub_errno;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct grub_nilfs2_data *
|
static struct grub_nilfs2_data *
|
||||||
|
|
Loading…
Add table
Reference in a new issue