summaryrefslogtreecommitdiff
path: root/e2fsck
AgeCommit message (Collapse)AuthorFilesLines
2010-03-17e2fsck: Fix segmentation fault when checking a file systemTheodore Ts'o1-0/+1
If a corrupted file system causes us to want to delete an extent, and that causes us to want to release a block in e2fsck pass #1, it would be preferable if e2fsck didn't seg fault. This tends to get users craky, as users are wont to do. :-) Thanks to Dirk Reiners for reporting this bug: e2fsck crashes fixing a corrupted 3.5 TB filesystem: 0x0000000000432002 in ext2fs_unmark_generic_bitmap (bitmap=0x0, bitno=623386749) at gen_bitmap.c:183 183 if ((bitno < bitmap->start) || (bitno > bitmap->end)) { (gdb) bt bitno=623386749) at gen_bitmap.c:183 block=623386749) at ../../lib/ext2fs/bitops.h:319 inuse=-1) at alloc_stats.c:78 extent.c:1509 pb=0x7fffffffdfe0, start_block=0, ehandle=0x6dcf50) at pass1.c:1709 pb=0x7fffffffdfe0, start_block=0, ehandle=0x6dcf50) at pass1.c:1737 pctx=0x7fffffffe100, pb=0x7fffffffdfe0) at pass1.c:1842 block_buf=0x6c4330 "\373\212#") at pass1.c:1920 The source of the NULL bitmap is fs on stack frame 2: (gdb) up 2 inuse=-1) at alloc_stats.c:78 78 ext2fs_unmark_block_bitmap(fs->block_map, blk); Addresses-SourceForge-Bug: #2971800 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-03-15Merge branch 'maint' into nextTheodore Ts'o5-23/+35
2010-03-15e2fsck: Don't blow up if the physical device is too bigTheodore Ts'o2-7/+7
If the user grows a partition bigger than 2**32 blocks, e2fsprogs 1.41.x is not going to be able to support resizing the filesystem, since it doesn't have > 2**32 block support. However, e2fsck should still work, so the system administrator doesn't get stuck. Addresses-Launchpad-Bug: #521648 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-03-15e2fsck: Make the "filesystem is mounted" message more scaryTheodore Ts'o1-2/+2
I guess the message wasn't scary enough for users who are just smart enough to really get themselves in deep doo-doo. Let's make it even scarier. Addresses-Launchpad-Bug: #537483 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-03-15e2fsck: Make the -n always open the file system read-onlyTheodore Ts'o2-12/+18
A user was surprised when -n -D caused the file system to be opened read/write, and then outsmarted himself when e2fsck asked the question: WARNING!!! Running e2fsck on a mounted filesystem may cause SEVERE filesystem damage. Do you really want to continue (y/n)? This is partially our fault for not documenting the fact that -D overrode opening the filesystem read-write. But the bottom line is it much safer if -n *always* opens the file system read-only, so there can be no confusion. This means that we have to disable certain combination of options, such as "-n -c", "-n -l", and "-n -L", and "-n -D", but the utility of these combinations is pretty low, and is more than offset by making e2fsck idiot-proof. Addresses-Launchpad-Bug: #537483 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-02-24e2fsck: don't complain about i_size for known blocks past EOFEric Sandeen1-1/+2
This is the userspace side of Jiaying's EOFBLOCKS patch. With Aneesh's patches for .33, Jiaying's patch, and this one, xfstests 013/fsstress (even with direct IO enabled) has held up through many runs. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-02-22e2fsck: Fix bug which can cause e2fsck -fD to corrupt non-indexed directoriesTheodore Ts'o1-1/+6
E2fsprogs 1.41.10 introduced a regression (in commit b71e018) where e2fsck -fD can corrupt non-indexed directories when are exists one or more file names which alphabetically sort before ".". This can happen with ext2 filesystems or for small directories (take less than a block) which contain filenames that begin with a space or some other punctuation mark. Fix this by making sure we never reorder the '.' or '..' entry in the directory, since they must be first. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-02-10Merge branch 'maint' into nextTheodore Ts'o1-11/+55
Conflicts: e2fsck/pass1.c
2010-02-05e2fsck: Fix the check if a file is really a directory to understand extentsNick Dokos1-11/+55
Pass 1 has a test to see if a special file is really a directory. Signed-off-by: Nick Dokos <nicholas.dokos@hp.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-01-31Merge branch 'maint' into nextTheodore Ts'o5-83/+81
Conflicts: configure lib/ext2fs/alloc_tables.c misc/mke2fs.c
2010-01-30e2fsck: Remove some erroneously leftover blk_t castsTheodore Ts'o1-7/+5
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-01-04e2fsck: Add new e2fsck.conf option: broken_system_clockTheodore Ts'o2-1/+23
The broken_system_clock allows the time to be in the future when in preen mode. It's useful for people who have, as the name implies, broken system clocks. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-11-29e2fsck: Try to update on-disk bitmap in e2fsck_get_alloc_block() callbackTheodore Ts'o1-0/+4
The e2fsck_get_alloc_block() callback is used so that if the ext2fs library needs to allocate blocks internally (most notably by the extents functions), e2fsck's internal block usage map is consulted since it is the only thing that can be trusted during a large part of e2fsck's operation. Change it to update the on-disk bitmap if it is loaded. This reduces the number of spurious differences found in pass #5. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-11-29e2fsck: Don't rehash directories which can fit in a single directory blockTheodore Ts'o1-0/+12
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-11-29e2fsck: Fix block allocation for holes in extent-mapped directoriesTheodore Ts'o1-28/+2
In pass 2, when allocating new blocks for holes in directories, use ext2fs_set_bmap() instead of ext2fs_block_iterate2() with a helper function so that the newly allocated directory blocks are correctly assigned in extent-mapped directories. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-11-29e2fsck: detect holes in extent-mapped directoriesTheodore Ts'o1-0/+13
Directories are not allowed to be sparse; the code for scanning extent-mapped directories was not calling ext2fs_add_dir_block() for missing directory blocks, so we weren't catching this form of file system corruption. Fix this. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-11-29e2fsck: Move check to add an index to a directory after fixing i_sizeTheodore Ts'o1-4/+6
The check that determines whether an directory needs to be have an index added to it depends on i_size. So move it after we have fixed up i_size so that we reliable will rehash a directory that needs it, even if its i_size field was originally incorrect. Otherwise, a second run of e2fsck would be needed before the directory gets an index added. Thanks to Mikulas Patocka for providing a sample file system which demonstrated this problem. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-11-29e2fsck: Fix directory with holes even when i_size is wrongTheodore Ts'o1-44/+15
The old method for detecting directories with holes depended on i_size being correct, even though the correct value of i_size hadn't been calculated yet. Hence, a directory inode with holes and an i_size of 0 would require two e2fsck passes to fix completely. The replacement method for determining whether or not ext2fs_add_dir_block() should be called is more reliable, and reduces the size of e2fsck and makes the code more readable as a bonus. Thanks to Mikulas Patocka for providing a sample file system which demonstrated this problem. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-11-16e2fsck: Fix duplicate directory entries for non-indexed directoriesTheodore Ts'o1-6/+6
Duplicate directory entries were not necessarily getting found and fixed for non-indexed directories, since we were sorting these directories by inode number, and the duplicate entry code assumed the entries were getting sorted by name or directory name hash. Addresses-Sourceforge-Bug: #2862551 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-11-16Add $(LIBINTL) to tst_problem linked libs.Matthias Andree1-1/+2
Fixes build problem on systems where gettext() isn't in libc, such as FreeBSD. Signed-off-by: Matthias Andree <matthias.andree@gmx.de> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-10-25Convert ext2fs_group_{first,last}_block() to *block2()Theodore Ts'o2-7/+7
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25Convert ext2fs_block_alloc_stats() calls to block_alloc_stats2()Valerie Aurora Henson5-9/+11
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25Convert to use block group accessor functionsValerie Aurora Henson6-74/+71
Convert direct accesses to use the following block group accessor functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(), ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(), ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(), ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(), ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(), ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set() Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: Nick Dokos <nicholas.dokos@hp.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25libext2fs: Convert ext2fs_bg_flag_test() to ext2fs_bg_flags_test()Theodore Ts'o3-10/+10
After cleaning up ext2fs_bg_flag_set() and ext2fs_bg_flag_clear(), we're left with ext2fs_bg_flag_test(). Convert it to ext2fs_bg_flags_test(). Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25libext2fs: clean up ext2fs_bg_flags_ interfacesEric Sandeen3-13/+10
The ext2fs_bg_flag* functions were confusing. Currently we have this: void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags); void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group,__u16 bg_flags); (_set (unused) sets exactly bg_flags; _clear clears all and ignores bg_flags) and these, which can twiddle individual bits in bg_flags: void ext2fs_bg_flag_set(ext2_filsys fs, dgrp_t group, __u16 bg_flag); void ext2fs_bg_flag_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flag); A better interface, after the patch below, is just: ext2fs_bg_flags_zap(fs, group) /* zeros bg_flags */ ext2fs_bg_flags_set(fs, group, flags) /* adds flags to bg_flags */ ext2fs_bg_flags_clear(fs, group, flags) /* clears flags in bg_flags */ and remove the original ext2fs_bg_flags_set / ext2fs_bg_flags_clear. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-24Merge branch 'maint' into nextTheodore Ts'o6-40/+53
Conflicts: configure configure.in
2009-10-16e2fsck: Accept superblock times to be fudged by up to 24 hours by defaultTheodore Ts'o4-36/+48
Unfortunately, due to Windows' unfortunate design decision to configure the hardware clock to tick localtime, instead of the more proper and less error-prone UTC time, many users end up in the situation where the system clock is incorrectly set at the time when e2fsck is run. Historically this was usually due to some distributions having buggy init scripts and/or installers that didn't correctly detect this case and take appropriate countermeasures. However, it's still possible, despite the best efforts of init script and installer authors to not be able to detect this misconfiguration, usually due to a buggy or misconfigured virtualization manager or the installer not having access to a network time server during the installation process. So by default, we allow the superblock times to be fudged by up to 24 hours. This can be disabled by setting options.accept_time_fudge to the boolean value of false in e2fsck.conf. The old options.buggy_init_scripts is left for backwards compatibility. Since we are now accepting the 24 hour time fudge by default, there is no longer a need to install an Ubuntu-specific e2fsck.conf file, so we can remove it. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-12e2fsck: Fix handling of non-zero i_blocks_high fieldTheodore Ts'o2-4/+14
E2fsck was not properly printing the i_blocks field in filesystem corruption messages, and it was not properly checking i_blocks_hi and i_blocks_lo, either. This commit fixes this. Thanks to Felipe Conteras for pointing this out. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-04Merge branch 'maint' into nextTheodore Ts'o4-122/+122
Conflicts: configure configure.in misc/mke2fs.c
2009-10-04e2fsck: Interpret negative blkcount in file system problem reportsTheodore Ts'o2-25/+50
Non-expert users get confused when they see messages like this: Illegal block #-1 (2291965952) in inode 176. CLEARED. So change it to be something a little bit more understandable: Illegal indirect block (2291965952) in inode 176. CLEARED. Addresses-SourceForge-Bug: #2871782 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-04Don't use in-tree header files if using system uuid or blkid librariesTheodore Ts'o1-96/+71
This commit forces the use of the system-provided blkid or uuid header files if we are using the system-provided blkid or uuid libraries. This avoids using the in-tree header files with the system libraries. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-03e2fsck: Use the correct problem code in the case of LAST_WRITE_FUDGEDTheodore Ts'o1-1/+1
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07Convert uses of super->s_*_blocks_count to ext2fs_*_blocks_count()Valerie Aurora Henson7-49/+50
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: Nick Dokos <nicholas.dokos@hp.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07Use ext2fs_file_acl_block() instead of using .i_file_acl directlyValerie Aurora Henson5-49/+63
This provides support for 48-bit file acl blocks. Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07Fix overflow in calculation of total file system blocksValerie Aurora Henson1-1/+1
Blocks per group and group desc count are both 32-bit; multiplied they produce a 32-bit quantity which overflowed. Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-01e2fsck: Avoid scary failure messages on low-memory systemsTheodore Ts'o1-2/+7
On a very low-memory system, where ext2fs_check_desc() fails because it can't allocate a block bitmap, catch this error and report it immediate. This avoids something like this, which could scare and mislead the user: e2fsck: Group descriptors look bad... trying backup blocks... Media was not cleanly unmounted, check forced. Pass 1: Checking inodes, blocks, and sizes Error allocating block bitmap (1): Memory allocation failed e2fsck: aborted Addresses-Debian-Bug: #509529 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07Use accessor functions fields for bg_flags in the block group descriptorsTheodore Ts'o3-23/+24
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07Convert to use io_channel_read_blk64() and io_channel_write_blk64()Valerie Aurora Henson7-17/+17
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07Merge branch 'maint' into nextTheodore Ts'o1-2/+7
2009-08-22e2fsck: Convert e2fsck to new bitmap interfaceValerie Aurora Henson11-139/+151
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-19e2fsck: Add a global latch question for bad group descriptor checksumsTheodore Ts'o2-1/+11
Very often all the block group descriptors will have bad checksums, so don't force the user answer 'yes' many, many times. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-18e2fsck: Only ask to relocate a block group's inode table onceTheodore Ts'o1-1/+2
If multiple blocks of a block group's inode table overlaps with other file system blocks, only ask once for each block group. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-18e2fsck: Teach new_table_block() to allocate new itables/bitmaps with FLEX_BGTheodore Ts'o1-3/+29
If the filesystem feature FLEX_BG is enabled, the inode table and bitmap blocks can be located anywhere in the inode table. So for FLEX_BG filesystems, new_table_block() now tries allocate in the block group's flex_bg first, and if there is no space in the local flex_bg, then try to allocate from the whole filesystem. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-08e2fsck: Fix and enhance superblock dates in future problem reportsTheodore Ts'o3-17/+30
Fixed a bug where e2fsck would report that last mount time was in the future when it was really the last write time that was in the future. Also, since people can't seem to believe that (a) their distribution has buggy init scripts, or (b) their CMOS/RTC clock or backup battery is dead, print the incorrect time and the current system time. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-04e2fsck: Allow cancellation during group descriptor checks.Valerie Aurora Henson1-0/+3
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-22Merge branch 'maint' into nextTheodore Ts'o5-22/+72
2009-07-16e2fsck: Fix superblock times in the future even if buggy_init_scripts=1Theodore Ts'o3-6/+32
Unfortunately, distributions like Ubuntu seem to have buggy init scripts that run e2fsck and mount the root filesystem before making sure the system time and time zone is correctly set. As a result, a filesystem's last write and last mounted time can be set in future. The buggy_init_scripts configuration option will stop e2fsck from aborting the boot process, but it also inhibits the superblock times from getting fixed. This causes resize2fs to refuse to resize the filesystem, even after running e2fsck on the file system. To deal with this, we need to fix the superblock write times unconditionally. Addresses-Launchpad-bug: #373409 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-06e2fsck: remove unused variable in check_block_bitmap()Kazuya Mio1-3/+1
check_block_bitmap() calculates the block number of superblock in the current block group but it's not used. Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-07-06e2fsck: optimize loop counter when fixing bitmap paddingKazuya Mio1-2/+2
If unused range of the bitmap has an unmarked bit, check_[inode/block]_end() marks all bits in the range. However, we know that the checked bits are marked. So this patch fixes loop counter to mark from the unmarked bit. Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-07-06e2fsck: remove unnecessary continue statementKazuya Mio1-2/+0
Remove the continue statement because it calls at the end of the loop. Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>