Cleanup changes to Andreas' symlink patch. Remove use of EXT2_LINK_DIR

Also cleaned up the symlink handling code to make it a bit more
compact and to test for a bad symlink block earlier.
bitmap-optimize
Theodore Ts'o 2001-08-04 20:39:39 -04:00
parent 67052a8aee
commit d007cb4cbb
5 changed files with 30 additions and 24 deletions

View File

@ -1,3 +1,18 @@
2001-08-04 Theodore Tso <tytso@valinux.com>
* problem.c (PR_2_SYMLINK_SIZE): Change description to make it
more clear (and remove %s expansion). Also add missing
periods to the end of a number of problem descriptions.
* pass2.c (e2fsck_process_bad_inode): Remove unneeded problem
context string set now that the problem description for
PR_2_SYMLINK_SIZE has been changed.
* pass1.c (e2fsck_pass1_check_symlink): Consolidate some checks,
and check the validity of the symlink block here (so that
we detect this case here instead of later). Also use
sizeof(inode->i_block) instead EXT2_LINK_DIR.
2001-07-30 Theodore Tso <tytso@valinux.com>
* unix.c (check_mount): Remove the code which tested for the root

View File

@ -152,35 +152,31 @@ int e2fsck_pass1_check_device_inode(struct ext2_inode *inode)
*/
int e2fsck_pass1_check_symlink(ext2_filsys fs, struct ext2_inode *inode)
{
if (inode->i_size_high || inode->i_size == 0)
return 0;
int i;
if (inode->i_flags & (EXT2_IMMUTABLE_FL |EXT2_APPEND_FL |EXT2_INDEX_FL))
if ((inode->i_size_high || inode->i_size == 0) ||
(inode->i_flags & (EXT2_IMMUTABLE_FL | EXT2_APPEND_FL |
EXT2_INDEX_FL)))
return 0;
if (inode->i_blocks) {
int i;
if (inode->i_blocks > fs->blocksize >> 9)
if ((inode->i_size > fs->blocksize) ||
(inode->i_blocks != fs->blocksize >> 9) ||
(inode->i_block[0] < fs->super->s_first_data_block) ||
(inode->i_block[0] >= fs->super->s_blocks_count))
return 0;
for (i = 1; i < EXT2_N_BLOCKS; i++)
if (inode->i_block[i])
return 0;
if (inode->i_size > fs->blocksize)
return 0;
/* Defer check of i_size until block number validated */
} else {
if (inode->i_size > EXT2_LINK_DIR - 1)
if (inode->i_size > sizeof(inode->i_block) - 1)
return 0;
if (inode->i_size !=
strnlen((char *)inode->i_block, EXT2_LINK_DIR))
strnlen((char *)inode->i_block, sizeof(inode->i_block)))
return 0;
}
return 1;
}
@ -1261,8 +1257,6 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
pctx->num = pb.num_blocks;
if (fix_problem(ctx, PR_1_BAD_I_BLOCKS, pctx)) {
inode->i_blocks = pb.num_blocks;
if (LINUX_S_ISLNK(inode->i_mode))
mark_inode_bad(ctx, ino);
e2fsck_write_inode(ctx, ino, inode, "check_blocks");
}
pctx->num = 0;

View File

@ -700,7 +700,6 @@ extern int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir,
problem = PR_2_BAD_SOCKET;
else if (LINUX_S_ISLNK(inode.i_mode)
&& !e2fsck_pass1_check_symlink(fs, &inode)) {
pctx.str = inode.i_blocks ? "" : "fast ";
problem = PR_2_SYMLINK_SIZE;
}

View File

@ -913,22 +913,22 @@ static const struct e2fsck_problem problem_table[] = {
/* Directory filetype incorrect */
{ PR_2_BAD_FILETYPE,
N_("@E has an incorrect filetype (was %dt, should be %N)\n"),
N_("@E has an incorrect filetype (was %dt, should be %N).\n"),
PROMPT_FIX, 0 },
/* Directory filetype set on filesystem */
{ PR_2_CLEAR_FILETYPE,
N_("@E has filetype set\n"),
N_("@E has filetype set.\n"),
PROMPT_CLEAR, PR_PREEN_OK },
/* Directory filename is null */
{ PR_2_NULL_NAME,
N_("@E has a zero-length name\n"),
N_("@E has a zero-length name.\n"),
PROMPT_CLEAR, 0 },
/* Invalid fast symlink size */
{ PR_2_SYMLINK_SIZE,
N_("@i %i (%Q) is a %ssymlink with a bad size (%Is)\n"),
N_("Symlink %Q (@i #%i) has an invalid size (%Is).\n"),
PROMPT_CLEAR, 0 },
/* i_file_acl (extended attribute block) is bad */
@ -970,7 +970,7 @@ static const struct e2fsck_problem problem_table[] = {
/* Bad or non-existent /lost+found. Cannot reconnect */
{ PR_3_NO_LPF,
N_("Bad or non-existent /@l. Cannot reconnect\n"),
N_("Bad or non-existent /@l. Cannot reconnect.\n"),
PROMPT_NONE, 0 },
/* Could not expand /lost+found */

View File

@ -169,8 +169,6 @@ struct ext2_group_desc
#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
#define EXT2_LINK_DIR (EXT2_N_BLOCKS * 4)
/*
* Inode flags
*/