summaryrefslogtreecommitdiff
path: root/e2fsck
AgeCommit message (Collapse)AuthorFilesLines
2011-12-18e2fsck: use different bitmap types as appropriateTheodore Ts'o7-30/+137
Now that we have multiple backend implementations of the bitmap code, this commit teaches e2fsck to use either the most appropriate backend for each use case. Since we don't know for sure if we will get it all right, the default choices can be overridden via e2fsck.conf. The various definitions are shown here, with the current defaults (which may change as we add more bitmap implementations and as learn what works better). ; EXT2FS_BAMP64_BITARRAY is 1 ; EXT2FS_BMAP64_RBTREE is 2 ; EXT2FS_BMAP64_AUTODIR is 3 [bitmaps] inode_used_map = 2 ; pass1 inode_dir_map = 3 ; pass1 inode_reg_map = 2 ; pass1 block_found_map = 2 ; pass1 inode_bad_map = 2 ; pass1 inode_imagic_map = 2 ; pass1 block_dup_map = 2 ; pass1 block_ea_map = 2 ; pass1 inode_link_info = 2 ; pass1 inode_dup_map = 2 ; pass1b inode_done_map = 3 ; pass3 inode_loop_detect = 3 ; pass3 fs_bitmaps = 2 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-12-18e2fsck: fix pass5 bug when using two different bitmap backendsTheodore Ts'o1-2/+2
The pass5 checks would fail if the expected and current {inode,block} bitmaps used different back ends that returned different non-zero values from the test_*_bitmap() functions. Fix this by changing "(actual == bitmap)" to "(!actual == !bitmap)". Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-12-16e2fsck: fix use of uninitialized value in the MMP codeTheodore Ts'o2-2/+2
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-29e2fsck: speed up runs when using tdb for large atypical filesystemsTheodore Ts'o1-1/+5
Optimize how the tdb library so that running with [scratch_files] in /etc/e2fsck.conf is more efficient. Use a better hash function, supplied by Rogier Wolff, and supply an estimate of the size of the hash table to tdb_open instead of using the default (which is way too small in most cases). Also, disable the tdb locking and fsync calls, since it's not necessary for our use in this case (which is essentially as cheap swap space; the tdb files do not contain persistent data.) Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-28e2fsck: fix handling of duplicate blocks with bigalloc file systemsTheodore Ts'o1-31/+24
We need to do an accounting of duplicate clusters on a per-cluster instead of a per-block basis so we know when we've correctly accounted for all of the multiply claimed blocks in a particular inode. Thanks to Robin Dong for reporting this bug. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-27libquota: remove use of PATH_MAX and replace it with QUOTA_NAME_LENTheodore Ts'o1-1/+2
PATH_MAX is not portable (for example, it doesn't exist on the Hurd). So replace it with a new define, which defines the maximum length of the base quota name. As it turns out, this is substantially smaller than PATH_MAX. Also move the definitions relating to quotaio.c from mkquota.h to quotaio.h, as a cleanup. Addresses-Debian-Bug: #649689 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-25e2fsck: fix the max size calculation for non-extent fileKazuya Mio1-1/+1
When I create a non-extent file with the maximum size in ext4, e2fsck detects the following error: Pass 1: Checking inodes, blocks, and sizes Inode 12, i_size is 4402345721856, should be 4402345721856. Fix? As we know, e2fsck checks the size field of the inode in pass 1. However, in case of the ext4 with the feature of ^extent and huge_file, the maximum file size calculated in e2fsck is less than the real one. The patch fixes this problem. Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-11-20e2fsck: return more status if fsck abortsEric Sandeen1-2/+21
If we abort fsck (due to ENOMEM for example) we exit with only the FSCK_ERROR flag. It seems useful to do the same sorts of checks as we do on normal exit, and return whether the filesystem was modified, whether there are still uncorrected errors, etc, even in the abort case. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-11-14libquota: cleanup libquota codeAditya Kali2-5/+4
This patch cleans up the quota code as suggested in previous reviews. This includes * remove BUG_ON()s and 'exit()' calls from library code * remove calls to malloc/free and instead use ext2fs_get/free_mem functions. * lib/quota/common.c file in not needed anymore and is removed. * rename exported functions to start with quota_ (ex: init_quota_context --> quota_init_context) * better error handling in quota library Signed-off-by: Aditya Kali <adityakali@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-10-16libext2fs: ext2fs_[set_]file_acl_block needs to check for 64-bit feature flagTheodore Ts'o5-50/+55
The ext2fs_file_acl_block() and ext2fs_set_file_acl_block() needs to only check i_file_acl_high if the 64-bit flag is set. This is needed because otherwise we will run into problems on Hurd systems which actually use that field for h_i_mode_high. This involves an ABI change since we need to pass ext2_filsys to these functions. Fortunately these functions were first included in the 1.42-WIP series, so it's OK for us to change them now. (This is why we have 1.42-WIP releases. :-) Addresses-Sourceforge-Bug: #3379227 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-09Fix more spelling errors found by translators and add pluralizationTheodore Ts'o2-3/+5
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-09e2fsck: fix problem message for PR_1_QUOTA_BAD_MODETheodore Ts'o1-1/+1
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-08e2fsck: recover revoke blocks on 64bit filesystems correctlyDarrick J. Wong2-2/+12
Since the advent of 64bit filesystems, revoke blocks store 64-bit block numbers instead of 32-bit block numbers. Therefore we need to be able to handle that case. Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-08Fix spelling errors pointed out by translatorsTheodore Ts'o1-1/+1
Also remove the _("<foo>") marker from a string that was all numbers and hence didn't need punctuation. Thanks to Philipp Thomas and Goeran Uddeborg for reporting these buglets. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-05e2fsck: make e2fsck sigcatcher use SIGCHLD rather than SIGCLDTheodore Ts'o1-1/+1
SIGCHLD is more portable than SIGCLD, which is a Linux specific thing Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-05Pass the gettext() function to libcom_errTheodore Ts'o1-0/+1
For those e2fsprogs programs which use libcom_err and are internationalized, pass the gettext() function to libcom_err during program initialization. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-04libquota: remove get_qf_name()Theodore Ts'o1-1/+2
The get_qf_name() function used PATH_MAX, which is non-portable. Worse, it blindly assumed that PATH_MAX was the size of the buffer passed to it --- which in the one and only place where it was used in libquota, was a buffer declared to a fixed size 256 bytes. Fix this by simply getting rid of the function altogether. Cc: Aditya Kali <adityakali@google.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-04e2fsck: make the signal catcher more portable, take 2Theodore Ts'o1-0/+18
One table got missed when adding #ifdef's so that e2fsck/sigcatcher.c would compile on non-Linux systems. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-30e2fsck: avoid unnecessary reboots in some cases when checking the root fsTheodore Ts'o1-4/+4
If e2fsck modifies certain superblock fields which the kernel doesn't look at, mark the superblock as dirty without marking the file system as changed. This will avoid e2fsck signalling the init scripts that a reboot is necessary. This is safe, because the kernel doesn't actually look at these superblock fields. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-30e2fsck: zero ctx->fs after freeing fs when restarting due to MMPDarrick J. Wong1-0/+1
If MMP is enabled and e2fsck determines that it needs to restart itself on account of various MMP conditions, it will close the current fs and jump back to the start of fs checking. However, closing fs also frees it, which means that we need to set ctx->fs to NULL to prevent subsequent open code from accessing the old deleted pointer. Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-30e2fsck: simplify binary search in ea_refcount.cTheodore Ts'o1-26/+0
Remove the interpolation search in ea_refcount. The added complexity isn't worth the speed up. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-28e2fsck: make the signal catcher more portableTheodore Ts'o1-0/+142
All of the signals which the signal catcher tries to interpret aren't necessarily defined on all systems. So add #ifdef's to protect various signals to avoid compilation failures on non-x86 platforms. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-28e2fsck: check for invalid bad block inodeTheodore Ts'o3-0/+19
In some cases the bad block inode gets corrupted. If it looks insane, offer to clear it before trying to interpret it does more harm than good. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-25ext2fs: add multi-mount protection (INCOMPAT_MMP)Andreas Dilger9-2/+164
Multi-mount protection is feature that allows mke2fs, e2fsck, and others to detect if the filesystem is mounted on a remote node (on SAN disks) and avoid corrupting the filesystem. For e2fsprogs this means that it checks the MMP block to see if the filesystem is in use, and marks the filesystem busy while e2fsck is running on the system. This is useful on SAN disks that are shared between high-availability servers, or accessible by multiple nodes that aren't in HA pairs. MMP isn't intended to serve as a primary HA exclusion mechanism, but as a failsafe to protect against user, software, or hardware errors. There is no requirement that e2fsck updates the MMP block at regular intervals, but e2fsck does this occasionally to provide useful information to the sysadmin in case of a detected conflict. For the kernel (since Linux 3.0) MMP adds a "heartbeat" mechanism to periodically write to disk (every few seconds by default) to notify other nodes that the filesystem is still in use and unsafe to modify. Originally-by: Kalpak Shah <kalpak@clusterfs.com> Signed-off-by: Johann Lombardi <johann@whamcloud.com> Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-24misc: quiet minor compiler errorsAndreas Dilger3-17/+16
Several compiler errors are quieted: - zero-length gnu_printf format string - unused variable - uninitalized variable (though it isn't actually used for anything) - fixed a bug in ext2fs_stat() if stat64() does not exist Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-20e2fsck.8: fix spelling mistake in man pageTheodore Ts'o1-1/+1
Addresses-Debian-Bug: #642193 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-18Shorten compile commands run by the build systemTheodore Ts'o37-105/+186
The DEFS line in MCONFIG had gotten so long that it exceeded 4k, and this was starting to cause some tools heartburn. It also made "make V=1" almost useless, since trying to following the individual commands run by make was lost in the noise of all of the defines. So fix this by putting the configure-generated defines in lib/config.h and the directory pathnames to lib/dirpaths.h. In addition, clean up some vestigal defines in configure.in and in the Makefiles to further shorten the cc command lines. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-16e2fsprogs: Don't try to close an fd which is negativeEric Sandeen2-5/+10
These reflect either file descriptors which aren't tested for failure, or closures of fd's which may have failed. In setup_tdb(), test for failure of mkstemp and return without trying to open the file (again). In reserve_stdio_fds, rather than closing the "extra" fd == 3 due to the way the loop is written, just don't go that far by using while (fd <= 2). In logsave, it forks and retries forever if open fails, but at least make coverity happy by explicitly not trying to close a negative file descriptor. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16e2fsck: Fix leaks in error pathsEric Sandeen1-2/+5
fn and/or array was not freed in some error paths. [ Also make sure the array is NULL terminated before we free it in get_dirlist(). --tytso] Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16e2fsck: remove extraneous memsetEric Sandeen1-1/+0
e2fsck_allocate_memory() already sets allocated memory to 0, so remove the explicit memset. Especially since it was setting the wrong size (iter not *iter) Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16e2fsck: Don't store old_op from ehandler_operation if we don't restore it.Eric Sandeen2-4/+2
old_op is set but never used, because we restore "0" not old_op. So don't bother with it. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16e2fsck: handle null fs in print_pathname()Eric Sandeen1-2/+3
testing fs for NULL in expand_percent_expression(): e2fsck_ctx = fs ? (e2fsck_t) fs->priv_data : NULL; implies that fs could be NULL, but it's passed to print_pathname() which defererences it without further testing. So make this safe by returning "???" for a nul fs. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16e2fsprogs: Remove impossible name_len tests.Eric Sandeen2-8/+0
The name_len field in ext2_dir_entry is actually comprised of the name length in the lower 8 bytes, and the filetype in the high 8 bytes. So in places, we mask name_len with 0xFF to get the actual length. But once we have masked name_len with 0xFF, there is no point in testing whether it is greater than EXT2_NAME_LEN, which is 255 - or 0xFF. So all of these tests are extraneous. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16libext2fs: add metadata checksum and snapshot feature flagsTheodore Ts'o1-2/+2
Reserve EXT4_FEATURE_RO_COMPAT_METADATA_CSUM and EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP. Also reserve fields in the superblock and the inode for the checksums. In the block group descriptor, reserve the exclude bitmap field for the snapshot feature, and checksums for the inode and block allocation bitmaps. With this commit, the metadata checksum and exclude bitmap features should have reserved all of the fields they need in ext4's on-disk format. This commit also fixes an a missing byte swap for s_overhead_blocks. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Cc: Darrick J. Wong <djwong@us.ibm.com> Cc: Amir Goldstein <amir73il@gmail.com>
2011-09-16e2fsck: fix error in computing blocks of the ending groupYongqiang Yang1-3/+2
If the blocks of a filesystem is a multiple of blocks_per_group, blocks of the ending group is computed wrongly. Use the new ext2fs_group_blocks_count() helper instead. Eric Sandeen: Converted to use new blocks per group helper Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15e2fsck: do not attempt to discard if -n was specifiedLukas Czerner1-4/+3
If '-n' option is specified there should be no changes made to the file system hence we should not attempt to discard the file system. This commit adds a check into the e2fsck_discard_blocks() condition so it skip discard if E2F_OPT_NO flag is set. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-03e2fsck: fix valgrind commit in sigcatcherTheodore Ts'o1-0/+1
Thanks to Andreas Dilger for catching this. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-08-31e2fsck: add support for checking the built-in quota filesAditya Kali13-21/+238
This patch adds support for doing quota accounting during full e2fsck scan if the 'quota' feature was set on the superblock. If user-visible quota inodes are in use, they will be hidden and converted to the reserved quota inodes. Signed-off-by: Aditya Kali <adityakali@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-08-11e2fsck: catch termination signals and print information about themTheodore Ts'o4-3/+295
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-10e2fsck: teach e2fsck how to deal with bigalloc in non-extent-mapped inodesTheodore Ts'o1-3/+10
Currently the bigalloc implementation in the kernel requires extents, but this restriction might get relaxed in the future. Also, old versions of mke2fs that supported bigalloc during early testing created the root and lost+found directories without using extent-mapped inodes. This makes it possible for e2fsck to better support these old legacy file systems if it comes across them. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-09e2fsck: fix pass1b handling for bigalloc file systemsTheodore Ts'o1-89/+182
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-08misc: use EXT2_I_SIZE() consistently to get sizeAndreas Dilger4-9/+5
Use the EXT2_I_SIZE() macro consistently to access the inode size. The i_size/i_size_high combination is open coded in several places. Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-07-05e2fsck, libext2fs: support for bigalloc file systems with a blocksize of 1024Theodore Ts'o1-1/+4
Filesystems with a blocksize of 1024 have the superblock starting at block #1. However, the first data block in the superblock is 0 to simplify the cluster calculations. So we must compensate for this in a number of places, mostly in the ext2fs library, but also in e2fsck. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-16mke2fs, e2fsck: fix i_blocks handling for bigalloc file systemsTheodore Ts'o1-3/+5
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-16Fix superblock field s_blocks_count for bigalloc file systemsTheodore Ts'o2-1/+2
Treat the s_blocks_count field in the superblock as a free block count (instead of the number of free clusters) for bigalloc file systems. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-16e2fsck: fix mysterious "FILE SYSTEM WAS MODIFIED" with no changesTheodore Ts'o5-18/+52
Commit 2a77a784a3 (firest released in e2fsprogs 1.33) compared superblock summary free blocks and inode counts with the allocation bitmap counts before starting the file system check proper, and if they differed, set the superblock and marked it as dirty. If no other file systme changes were required, this would cause a "*** FILE SYSTEM WAS MODIFIED ***" message without any explanation of what e2fsck had changed. We fix this by only setting the superblock summary free block/inodes counts if we are skipping a full check, and in non-preen mode, e2fsck will now print an explicit message stating how the superblock had been updated. In a full check, any updates to the superblock free blocks/inodes fields will be noted in pass5. This change requires changing a few test results (essentially reversing the changes made in commit 2a77a784a3). Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-15e2fsck: Fix pass5 handling for bigalloc && uninit_bg file systemsTheodore Ts'o1-29/+36
The code which simulated handling uninitialized block bitmaps didn't take bigalloc file systems into account correctly. Fix it. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-11ext2fs: Handle internal journal over 2^32 bytesAndreas Dilger2-5/+9
The write_journal_inode() code is only setting the low 32-bit i_size for the journal size, even though it is possible to specify a journal up to 10M blocks in size. Trying to create a journal larger than 2GB will succeed, but an immediate e2fsck would fail. Store i_size_high for the journal inode when creating it, and load it upon access. Use s_jnl_blocks[15] to store the journal i_size_high backup. This field is currently unused, as EXT2_N_BLOCKS is 15, so it is using s_jnl_blocks[0..14], and i_size is in s_jnl_blocks[16]. Rename the "size" argument "num_blocks" for the journal creation functions to clarify this parameter is in units of filesystem blocks and not bytes. Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11misc: clean up compiler warningsAndreas Dilger5-6/+7
Fix several types of compiler warnings (unused variables/labels), uninitialized variables, etc that are hit with gcc -Wall. Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-10e2fsck: add basic bigalloc support to check (but not yet repair) file systemsTheodore Ts'o5-30/+59
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>