Commit Graph

75 Commits (f6341e9c70eb4e0ded51ca96aeaa79a72222c069)

Author SHA1 Message Date
Kalpak Shah 575307cc63 e2fsck: Fix salvage_directory when the last entry's rec_len is too big
Recently, one of our customers found this message in pass2 of e2fsck
  while doing some regression testing:

  "Entry '4, 0x695a, 0x81ff, 0x0040, 0x8320, 0xa192, 0x0021' in ??? (136554) has
  rec_len of 14200, should be 26908."

  Both the displayed rec_len and the "should be" value are bogus. The
  reason is that salvage_directory sets a offset beyond blocksize
  leading to bogus messages.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-10 07:28:35 -04:00
Theodore Ts'o d5b753ee4d Remove unused variable in e2fsck/pass2.c:check_dir_block()
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-18 22:11:31 -04:00
Bryn M. Reeves 3f4c46e3f9 Correct byteswapping for fast symlinks with xattrs
Fix a problem byte-swapping fast symlinks inodes that contain extended
attributes.

Addresses Red Hat Bugzilla: #232663
Addresses LTC Bugzilla: #27634

Signed-off-by: "Bryn M. Reeves" <breeves@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-14 14:00:31 -04:00
Theodore Ts'o e94bc63164 Improve I/O error messages in e2fsck
Add better ehandler_operation() markers so it is clearer what e2fsck was
doing when an I/O error is reported.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-14 09:29:02 -04:00
Theodore Ts'o 34b9f79639 Enable e2fsck to use the tdb library for the inode count abstraction
If e2fsck.conf configures a scratch_files directory which is available,
and the number of directories exceeds scratch_files.numdirs_threshold,
then try to use the tdb library to store the inode count abstraction.
This allows us to check very large filesystems without needing as much
physical memory.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-06 18:43:11 -04:00
Theodore Ts'o 28db82a84a Rework e2fsck's dirinfo abstraction to be more friendly for databases
Change the iterator abstraction and replace e2fsck_get_dir_info() with
e2fsck_dir_info_{set,get}_{parent,dotdot} so that we can support an
on-disk dirinfo implementation.  This allows e2fsck to check very large
filesystems on systems with smaller amounts of memory and/or address
space.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-04 22:33:31 -04:00
Theodore Ts'o 642935c082 Fix misc. gcc -Wall complaints in the misc and e2fsck directories
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-14 23:38:17 -05:00
Theodore Ts'o f77704e416 Add directory hashed signed/unsigned hint to superblock
The e2fsprogs and kernel implementation of directory hash tree has a
bug which causes the implementation to be dependent on whether
characters are signed or unsigned.  Platforms such as the PowerPC,
Arm, and S/390 have signed characters by default, which means that
hash directories on those systems are incompatible with hash
directories on other systems, such as the x86.

To fix this we add a new flags field to the superblock, and define two
new bits in that field to indicate whether or not the directory should
be signed or unsigned.  If the bits are not set, e2fsck and fixed
kernels will set them to the signed/unsigned value of the currently
running platform, and then respect those bits when calculating the
directory hash.  This allows compatibility with current filesystems,
as well as allowing cross-architectural compatibility.

Addresses Debian Bug: #389772

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-11 22:32:35 -05:00
Theodore Ts'o 5d17119d14 On-disk format definition for huge files
- EXT4_FEATURE_RO_COMPAT_HUGE_FILE (0x0008) - change i_blocks to be
  in units of s_blocksize units instead of 512-byte sectors, use
  l_i_frag and l_i_fsize as i_blocks_hi (could also be part of 64BIT).

E2fsck and debugfs changed to support i_blocks_hi instead of l_i_frag and
l_i_fsize.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-11 06:32:03 -05:00
Theodore Ts'o 977ac8731b Fix potential e2fsck -n crash
Don't core dump if there is a corrupt htree interior node.  If the block
number is larger than the number of blocks in the directory, don't write
past the end of malloc'ed memory.

Addresses SourceForge Bug: #1512778

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-10-21 23:27:03 -04:00
Takashi Sato 8deb80a5d1 Fix format statements to make e2fsprogs programs 32-bit clean
Change the format string(%d, %ld) for a block number and inode number
to %u or %lu.

Signed-off-by: Takashi Sato <sho@tnes.nec.co.jp>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-18 21:43:46 -05:00
Theodore Ts'o f76344fb6f [BUGFIX]: E2fsck will segfault on disconnected inode with extended attribute(s)
This was actually caused by two bugs.  The first bug is that if the
inode has been fully fixed up, the code will attempt to remove the
inode from the inode_bad_map without checking to see if this bitmap is
present.  Since it is cleared at the end of pass 2, if
e2fsck_process_bad_inode is called in pass 4 (as it is for
disconnected inodes), this would result in a core dump.

The first bug was mostly hidden by a second bug, which caused
e2fsck_process_bad_inode() to consider all inodes without an extended
attribute to be not fixed.

Note: This bug was introduced in e2fsprogs 1.36.

(Addresses Debian Bug: #316736)
2005-07-04 12:53:36 -05:00
Theodore Ts'o 1f3ad14a5a Use a centrally stored current time for "now" which
can be overridden using the E2FSCK_TIME environment 
variable, for better reproducibility for regression tests.
2005-04-14 14:07:53 -04:00
Theodore Ts'o 33db8f80f2 Remove support for --enable-clear-htree; this was
only needed during the early development of the htree patch.
2005-02-05 10:28:15 -05:00
Theodore Ts'o a894eb4795 pass2.c (e2fsck_process_bad_inode): Fix a corner case involving
big-endian systems, long symlinks and i_file_acl set when
	it shouldn't be.  Without this bugfix, f_clear_xattr will
	fail on big-endian machines.
2005-01-28 12:27:35 -05:00
Theodore Ts'o 7e0282c5f2 Fixed missing not_fixed branch in e2fsck so that if the frag size field in
the inode is not fixed, the inode_bad_map bitmap won't be cleared.  Thanks to
Stephen Tweedie for pointing this out.
2005-01-27 21:40:53 -05:00
Theodore Ts'o 6c313fd473 Fix e2fsck to not delete symlinks that contain an extended attribute after
the ext_attr feature flag has been cleared.  (Addresses Red Hat Bugzilla 
#146284)
2005-01-27 14:28:41 -05:00
Theodore Ts'o 1ba7a2f2b6 Fix a byte swap bugs, including one which caused e2fsck to
incorrectly treat as valid symlinks created with SE Linux 
(Debian bug #228723) as well as failing the f_journal test case on 
big endian systems due to the backup journal blocks not being swapped.
2004-01-30 01:48:06 -05:00
Matthias Andree b969b1b8a5 Fix more compiler warnings. 2003-12-28 13:04:35 +01:00
Theodore Ts'o 544349270e Fix gcc -Wall nitpicks 2003-12-07 01:28:50 -05:00
Theodore Ts'o c4e3d3f374 ext2fs_getmem(), ext2fs_free_mem(), and ext2fs_resize_mem()
all now take a 'void *' instead of a 'void **' in order to 
avoid pointer aliasing problems with GCC 3.x.
2003-08-01 09:41:07 -04:00
Theodore Ts'o 48e6e81362 Fixx gcc -Wall nitpicks. 2003-07-06 00:36:48 -04:00
Theodore Ts'o 520ead378e Fix gcc -Wall warnings. 2003-04-19 13:48:27 -04:00
Theodore Ts'o 0926668d3a e2fsck/pass2.c (check_dir_block): Check for duplicate filenames within
a single directory block (because this is the easy case;
	we don't currently check for duplicates that span
	directory blocks, for now.  Eventually for htree
	directories we can do this by searching for all directory
	blocks that have a hash overflow, and then searching the
	adjacent blocks to find all other potential duplicates.)
2003-03-14 22:19:10 -05:00
Theodore Ts'o f364093b19 Update debugfs and e2fsck to use the blkid library. 2003-03-01 19:47:44 -05:00
Theodore Ts'o e34bf43aff pass2.c (strnlen): Provide strnlen if libc doesn't. 2002-12-18 18:28:10 -05:00
Theodore Ts'o 0c897a9012 Add german translation to the language catalog
Fix internationalization of "pass 2" in e2fsck.

Update po files.
2002-11-09 12:01:18 -05:00
Theodore Ts'o 8132d840c8 Fix endian problems in the htree code for e2fsck and debugfs.
When byte-swapping a filesystem on a PPC architecture, byte-swap
the bitmaps since the historical big-endian ext2 variant had
byte-swapped bitmaps, and the ext2fs library assumes this.  Otherwise
the regression test suite will fail...
2002-10-02 22:07:17 -04:00
Theodore Ts'o ad4fa46604 Avoid counting directory entries during a directory salvage.
Add additional checks to HTREE directories.  We now check the count
and limit fields in the htree header, as well as assuring that the
hash table in each interior node is in ascending order.  We also
check to make sure all leaf nodes are have the expected depth in 
the tree.

Updated test cases to deal with all of the above.
2002-09-30 11:19:19 -04:00
Theodore Ts'o e8254bfd3b pass2.c (check_dir_block): Do a more paranoid check when trying
to determine whether or not a directory entry is a
	completely empty leaf block or leaf node.  Otherwise
	e2fsck might get confused into thinking that a valid dxdir
	was corrupted.
2002-09-29 19:30:28 -04:00
Theodore Ts'o e70ae99e07 Add a more sophisticated algorithm to e2fsck to salvage corrupted
directories.

Speed up e2fsck slightly by only updating the master superblock;
there is no point to update the backup superblocks.

Fix a small bug in the rehashing code which could leave the indexed
flag set even after the directory was compressed instead of indexed.
(Not fatal, since the kernel will deal with this, but technically
it filesystem isn't consistent, and the filesystem will be marked
as being in error when the kernel comes across the directory.  It
should also never happen in real life, since directories that small
will never be indexed, but better safe than sorry.)

Also change the threshold of when directories are indexed, so that
directories of size 2 blocks will be indexed.  Otherwise they will
never be indexed by the kernel when they grow.
2002-09-28 09:16:28 -04:00
Theodore Ts'o ea1959f015 Fix a bug which caused e2fsck to fail to correctly check filesystems
using a non-zero hash version (i.e., half MD4 or TEA hash).

The hash version wasn't getting copied into dx_dir->hashversion and
this caused the kernel to treat all directories if they were using the 
legacy hash, which was Bad.
2002-08-31 02:32:41 -04:00
Theodore Ts'o 0684a4f33b Overhaul extended attribute handling. Should now be correct with
respect to the latest V2 bestbits ACL code.
2002-08-17 10:19:44 -04:00
Theodore Ts'o 4cae04529e Add SIGINT and SIGTERM handling to fsck and e2fsck. For e2fsck,
make sure we gracefully clean up and only exit at safe points.
For fsck, we pass the SIGINT/SIGTERM signal to the child processes,
so they can do their own cleanup.
2002-07-21 14:14:03 -04:00
Theodore Ts'o b7a00563b2 Add support to e2fsck to reindex directories to use hash trees. 2002-07-20 00:28:07 -04:00
Theodore Ts'o 62acaa1de1 pass2.c (e2fsck_pass2): Use dx_dir->numblocks instead of
dx_dir->ino to indicate that a bad inode was cleared.
2002-07-15 16:54:42 -04:00
Theodore Ts'o 503f9e7f6e Add support for the half-MD4 HTREE hash.
Add HTREE root node tests.
2002-06-26 16:52:10 -04:00
Theodore Ts'o 8fdc9985c1 Add initial support for htree directories. 2002-06-25 23:26:34 -04:00
Theodore Ts'o bcf9c5d401 Fix up Andreas' changeset. Avoid use of dynamic automatic arrays,
and check for EXT2_INDEX_FL for special devices, and consider them to
be invalid if they are set.
2002-05-21 09:14:17 -04:00
Andreas Dilger b94a052a25 Add more complete tests for symlinks: nul termination of long links and length
Improve the f_badsymlinks test case for these new tests.
2002-05-18 13:16:30 -06:00
Theodore Ts'o a474269147 pass1.c, pass2.c, problem.c, problem.h: Fix bug introduced by
Andreas's symlink code; check_blocks() was unconditionally testing
	inode_bad_map without checking to see if it existed first.  Fixed
	problem a different way; we now no longer check inode_bad_map at all,
	since the file might not get deleted in pass 2 anyway.  We move the
	large file feature reconciliation code to to e2fsck_pass2(), and in
	deallocate_inode() in pass2.c, we decrement the large files counter if
	we're about to delete a large file.
2001-08-09 04:14:04 -04:00
Theodore Ts'o d007cb4cbb 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.
2001-08-04 20:39:39 -04:00
Andreas Dilger 67052a8aee Add extra checks for bad symlinks, including zero length symlinks,
too long i_size for slow and fast symlinks, i_size_high set, multiple
blocks for slow symlinks.
2001-08-04 00:51:18 -06:00
Theodore Ts'o 342d847db3 Add initial support for extended attribute blocks 2001-07-02 11:54:09 -04:00
Theodore Ts'o fdbdea09b8 ChangeLog, pass1.c, pass2.c, problem.c, problem.h:
pass1.c (mark_inode_bad): Replace alloc_bad_map with a function which
  	sets the bit in the bad inode bitmap.
  	(e2fsck_pass1): Check for fast symlinks with an invalid size, and set
  	the bad inode map in that case.
  pass2.c (e2fsck_process_bad_inode): Check for fast symlinks with an
  	invalid size and prompt the user if the inode should be cleared.
  problem.h, problem.c (PR_2_SYMLINK_SIZE): Added new problem code.
2001-06-02 04:26:26 +00:00
Theodore Ts'o b9852cd87b ChangeLog, pass2.c:
pass2.c (check_dir_block): Ignore EXT2_ET_DIR_CORRUPTED errors from
  	ext2fs_read_dir_block().
2001-05-05 05:14:59 +00:00
Theodore Ts'o 4035f40bc4 ChangeLog, pass2.c:
pass2.c: Minor whitespace cleanups, from Andreas Dilger.
2001-01-12 20:25:50 +00:00
Theodore Ts'o 86c627ec11 Many files:
dirinfo.c, e2fsck.h, emptydir.c, iscan.c, jfs_user.h, journal.c,
  	message.c, pass1.c, pass1b.c, pass2.c, pass3.c, pass4.c, pass5.c,
  	problem.h, scantest.c, super.c, swapfs.c: Change ino_t to ext2_ino_t.
2001-01-11 15:12:14 +00:00
Theodore Ts'o 133a56dc9d ChangeLog, message.c, pass1b.c, pass2.c, pass3.c, problem.c, problem.h:
pass1b.c: Change routines to use PR_1B_BLOCK_ITERATE when reporting
  	problems rather than using com_err directly.
  problem.c, problem.h (PR_1B_BLOCK_ITERATE): Add new problem code.
  message.c (expand_percent_expression): Add safety check.  If ctx->str
  	is NULL, print "NULL" instead of dereferencing the null pointer.
  pass1b.c, pass2.c, pass3.c: Change calls to ext2fs_block_iterate to
  	ext2fs_block_iterate2, to support 64-bit filesizes and to speed things
  	up slightly by avoiding the use of the ext2fs_block_iterate's
  	compatibility shim layer.
version.h:
  Update for WIP release.
2000-11-17 05:40:49 +00:00
Theodore Ts'o 1917875fcd Many files:
unix.c (main): If compression is enabled on the filesystem, print a
  	warning message (for now).
  message.c: Add new compression shortcut: @c == compress
  problem.c, problem.h (PR_1_COMPR_SET): Add new error code.
  pass1.c (check_blocks): If the inode has EXT2_COMPRBLK_FL flag set,
  	check to see if the filesystem supports compression.  If it does pass
  	this information down to process_block() so it can treat the
  	compressed block flag words correctly.  If not, offer to clear the
  	flag, since it shouldn't be set.
  	(process_block): If an inode has the compressed inode flag set, allow
  	EXT2FS_COMPRESSED_BLKADDR.
  pass1b.c (process_pass1b_block, delete_file_block, clone_file_block):
  pass2.c (deallocate_inode_block): Use HOLE_BLKADDR to check to see if
  	the block can be skipped.
ChangeLog, Makefile.in:
  Makefile.in: Exclude the internationalization files from being
  	distributed.
ChangeLog, configure, configure.in:
  configure.in: Add support for --enable-compression.  This is
  	experimental code only for now, which is why it's under --enable test.
  	Once it's stable, it will always be compiled in.
TODO:
  Commit additional TODO items.
2000-02-11 15:55:07 +00:00