summaryrefslogtreecommitdiff
path: root/e2fsck
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2001-08-04 20:39:39 -0400
committerTheodore Ts'o <tytso@mit.edu>2001-08-04 20:39:39 -0400
commitd007cb4cbb4b8b190ffd9a597f0e88ea365926c5 (patch)
treefd668a3db0b55ea036489a9248f03f377737f221 /e2fsck
parent67052a8aeeca8cd80d1dd33c2792f917573accc8 (diff)
downloade2fsprogs-d007cb4cbb4b8b190ffd9a597f0e88ea365926c5.tar.gz
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.
Diffstat (limited to 'e2fsck')
-rw-r--r--e2fsck/ChangeLog15
-rw-r--r--e2fsck/pass1.c26
-rw-r--r--e2fsck/pass2.c1
-rw-r--r--e2fsck/problem.c10
4 files changed, 30 insertions, 22 deletions
diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog
index 9b7f0af2..d2c422d3 100644
--- a/e2fsck/ChangeLog
+++ b/e2fsck/ChangeLog
@@ -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
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index a8188ff7..ebed95d2 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -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;
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index 0d27d96c..7575b81c 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -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;
}
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index ebfaab47..34f4e9d4 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -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 */