Commit Graph

466 Commits (714da4515e716a35edf602d0ea8dcd072ad9e0d8)

Author SHA1 Message Date
Theodore Ts'o d7b64725ee Update Release Notes, Changelogs, version.h, etc. for 1.40 release
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-24 17:32:47 -04:00
Andreas Dilger a34c6ffd68 e2fsck: added sanity check for xattr validation
Add an extra validity test in check_ext_attr().  If an attribute's
e_value_size is zero the current code does not allocate a region for it
and as a result the e_value_offs value is not verified.  However, if
e_value_offs is very large then the later call to
ext2fs_ext_attr_hash_entry() can dereference bad memory and crash
e2fsck.

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: Jim Garlick <garlick@llnl.gov>
2007-06-22 02:22:38 -04:00
Theodore Ts'o 058ad1c70c Don't write changes to the backup superblocks by default
This patch changes ext2fs_open() to set EXT2_FLAG_MASTER_SB_ONLY by
default.  This avoids some problems in e2fsck (reported by Jim Garlick)
where a corrupt journal can end up writing the bad superblock to the
backups.  In general, only e2fsck (after the filesystem is clean),
tune2fs, and resize2fs should change the backup superblocks by default.
Most callers of ext2fs_open() should not be touching anything where the
backups should be touched.  So let's change the defaults to avoid
potential problems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-18 18:26:50 -04:00
Theodore Ts'o d2af1bdd05 Fix e2fsck's get_size logic so it will work with the Linux floppy driver
The Linux floppy driver is a bit different from the other block device
drivers, in that if the device has been opened with O_EXCL, it disallows
another open(), even if the second open() does not have the O_EXCL flag.
So this patch moves the call to ext2fs_get_device_size() so that if it
returns EBUSY, e2fsck can close the filesystem, retry the device size,
and then reopen it.  This rather complicated approach is required since
we need to know the blocksize of the filesystem before we can call
ext2fs_get_device_size().

Addresses Debian Bug: #410569

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-04 01:14:52 -04:00
Daniel Drake e7b5d3c0b2 e2fsck: Add blocksize sanity check when finding a backup superblock
I've been investigating why e2fsck refuses to restore the backup superblock
of a partition with a broken primary superblock.

The partition in question has a block size of 4096, and mke2fs reports that
backup superblocks were created on blocks 32768, 98304, 163840, ...

When running e2fsck, get_backup_sb starts by guessing a block size of 1024
and backup superblock at block 8193. I'm not sure why, but it actually finds
a superblock at this location, so returns a context with superblock 8193,
blocksize 1024.

Later on, ext2fs_open2() tries to process this superblock. It then realises
that the block size value stored in the superblock (4096) does not match what
it was told (1024), so it bails out with EXT2_ET_UNEXPECTED_BLOCK_SIZE. fsck
aborts without fixing the partition.

The following patch solves the problem by discounting superblocks which do
not meet the currently-sought block size.
As a result, block 32768 (blocksize=4096) is now used to restore the backup,
which agrees with the first location that mke2fs listed.

Signed-off-by: Daniel Drake <d.drake@mmm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-31 11:56:17 -04:00
Brian Behlendorf 8f234d9650 [COVERITY] Free potential null dereference bug in e2fsck
At the second conditional iter->file could still be NULL. We need to
check for it again.  Should never happen in practice, but better to be
sure.

Coverity ID: 6: Forward Null

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-31 11:42:48 -04:00
Andreas Dilger de8f3a7621 Fix gcc -Wall warnings, especially on 64-bit systems
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-25 11:18:11 -04:00
Theodore Ts'o f954ba012f Fix gcc -Wall issues in e2fsck sources
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
2007-05-22 20:53:01 -04:00
Theodore Ts'o 32460c1e4c Add new function profile_get_uint() in the e2fsck sources
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-22 20:51:47 -04:00
Kalpak Shah 1a8c2c4a89 Remove check in e2fsck which requires EA's in inodes to be sorted
This patch removes a code snippet from check_ea_in_inode() in pass1 which checks
if the EA values in the inode are sorted or not. The comments in fs/ext*/xattr.c
state that the EA values in the external EA block are sorted but those in the
inode need not be sorted. I have also attached a test image which has unsorted
EAs in the inodes. The current e2fsck wrongly clears the EAs in the inode.

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
2007-05-08 01:07:30 -04:00
Eric Sandeen 5113a6e32b Fix mke2fs and debugfs to support large (> 16 bit) uid's and gid's
Mke2fs is supposed to set the uid/gid ownership of the root directory when
a non-rooot user creates the filesystem.  This wasn't working correctly
if the uid/gid was > 16 bits.   In additional, debugfs wasn't displaying
large uid/gid's correctly.  This patch fixes these two programs.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-08 00:10:54 -04:00
Theodore Ts'o a4d7d90deb Fix minor typo in e2fsck.conf.5.in man page
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-18 22:12:50 -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 0eeb154937 Fix e2fsck's check_is_really_dir logic
Fix a typo which could cause e2fsck to throw an I/O error while doubling
checking whether or not a special device file was really an inode.
Also, don't do this tests on symbolic links since for filesystems with a
large numbers of symlinks it could degrade performance and increases the
risk for false positives.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-14 12:01:39 -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
Jim Garlick 3d51ff876e e2fsck: pass1c terminates early if hard links
I think this is a small buglet in e2fsck:  if a file has multiple hard
links, e2fsck pass1c search_dirent_proc() doesn't maintain its count
properly and may return DIRENT_ABORT before it has found containing
directories for all inodes sharing blocks.

Signed-off-by: Jim Garlick <garlick@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-10 22:55:09 -04:00
Theodore Ts'o 39efa4c500 Update the e2fsck.conf(5) man page to document the [scratch_files] section
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-06 23:32:06 -04:00
Theodore Ts'o 25a9fe2894 Enable e2fsck to use the tdb library to store the dirinfo 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 directory information
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:44:37 -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 86bc90f4f1 Fix potential reference (and free) to an uninitialized pointer in e2fsck
This was introduced recently when fixing a problem noted by Coverty.
Oops!

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-04 21:42:42 -04:00
Theodore Ts'o fbc3f90194 e2fsck: Recover a special file which looks an awful lot like a directory
This is probably only useful in artificial test cases, but it will be
useful if we ever do the "inodes in directory" idea for ext4.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-02 10:08:59 -04:00
Theodore Ts'o ccfbb266d6 e2fsck: Add support for %It in problem description messages
Add support for the %It expansion, which will print the type of the inode
in the problem context.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-31 19:53:53 -04:00
Theodore Ts'o 56c8c592ac Fix e2fsck to set the filetype of '..' when connecting a dir, to lost+found
If there is an orphaned inode whose '..' entry is pointing at a special
file, the filetype of the '..' entry will set to the type of the special
file.  When the orphaned directory is reconnected to /lost+found, the
filetype of the '..' field is not reset to EXT2_FT_DIR, so a second
e2fsck is required to repair the filesystem.

We address this situation by setting the filetype of '..' when we
reconnect the inode to /lost+found.

Addresses Lustre Bug: #11645

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-31 19:18:24 -04:00
Theodore Ts'o 441ab1e020 Fix edge case when i_size doesn't get fixed until second e2fsck run
Don't assume that a special device is bogus just because i_blocks is
non-zero.  The i_blocks field could get adjusted later, and if this
happens it will confuse the e2fsck_process_bad_inode() in pass 2.  In
practice true garbage inodes will have random non-zero in
i_blocks[4..15], so there's no point doing the check for an illegal
i_blocks value.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-31 18:56:09 -04:00
Brian Behlendorf 2bfe0bdba3 [COVERITY] Fix (error case only) memory leak in e2fsck_get_journal
Coverity ID: 43: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2007-03-29 00:19:17 -04:00
Brian Behlendorf 06c9c6ffc1 [COVERITY] Fix (error case only) memory leak in e2fsck pass #4
Coverity ID: 42: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2007-03-28 12:43:05 -04:00
Brian Behlendorf 1db4c4397d [COVERITY] Fix (error case only) memory leak in e2fsck -S
Coverity ID: 41: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-28 12:36:41 -04:00
Brian Behlendorf 49e2df2954 [COVERITY] Fix (error case only) memory leak in e2fsck pass #5
Coverity ID: 39: Resource Leak
Coverity ID: 40: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2007-03-28 12:07:41 -04:00
Brian Behlendorf 9d45b6ef7e [COVERITY] Fix (error case only) memory leak in e2fsck pass #1
Coverity ID: 37: Resource Leak
Coverity ID: 38: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2007-03-28 11:57:20 -04:00
Brian Behlendorf 5469d76759 [COVERITY] Fix memory leak when parsing extended options in e2fsck
Coverity ID: 36: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2007-03-28 11:41:40 -04:00
Brian Behlendorf cae542ce8e [COVERITY] Fix memory leak when parsing extended options in e2fsck
Coverity ID: 35: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2007-03-28 11:28:24 -04:00
Brian Behlendorf 93503267c9 [COVERITY] Fix memory leak in profile library
The profile must be freed early if the subsequent memory allocation
fails for 'expanded_filename'.

Coverity ID: 14: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-21 16:14:37 -04:00
Brian Behlendorf a4b66fb133 [COVERITY] Add missing NULL check to e2fsck_get_dir_info()
It is possible that e2fsck_get_dir_info() returns a NULL pointer.
We do not want to blow up when dereferencing p.  It seems to be
more sane/safe to call fix_problem(ctx, PR_3_NO_DIRINFO, pctx)
if p is NULL at this point since we do not have any DIRINFO
for pctx->ino.

Also fix another (already existing) error check for
e2fsck_get_dir_info() later in the function so that it reports the
correct inode number if the dirinfo information is not found for
p->parent.

(Both of these are "should-never-happen" internal e2fsck errors that
would indicate a programming bug of some kind.)

Coverity ID: 10: Null Returns

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-19 08:58:47 -04:00
Brian Behlendorf 538e654c25 [COVERITY] Check for NULL return from dict_lookup() in e2fsck
The dict_lookup() function can potentially return a NULL dnode_t.  It is
not checked in two places in the clone_file() function.  Looks to be
safe to continue if n is NULL, so just print a warning message and
continue.

Coverity ID: 9: Null Returns

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-19 08:52:10 -04:00
Brian Behlendorf 12f9195999 [COVERITY] Fix segfault bug if the profile directory is empty
Coverity ID: 5: Forward NULL

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-19 08:36:45 -04:00
Theodore Ts'o a6d8302b48 Use the newer add/remove_error_table com_err interfaces
Change all of the e2fsprogs programs to use the newer add_error_table()
and remove_error_table() interfaces instead of the much older
initialize_*_error_table() function.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-12-26 03:38:07 -05: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 8ade479230 Fix e2fsck and mke2fs -c to be pass the last _block change to badblocks
Badblocks now interprets last_block argument as the last block to check,
instead of the number of blocks to check, to be consistent with the
badblocks man page.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-08 00:41:50 -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
Theodore Ts'o 2d1fa59d90 Minor correction to e2fsck.conf man page
Addresses Debian Bug: #369761

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-10-02 08:38:44 -04:00
Theodore Ts'o cce2f497e0 Fix Debian FTBFS problem caused by devmapper library using pthreads
Addresses Debian bug: #388718

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-10-01 22:18:08 -04:00
Eric Sandeen d1b4b85c3a Fix more rounding overflows for filesystems that have 2**32-1 blocks
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-09-12 14:56:18 -04:00
Eric Sandeen f335864338 Add checks to make sure inode counts don't overflow a 32-bit value
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-09-12 14:56:17 -04:00
Eric Sandeen abf23439d5 Create new ext2fs library inlines: ext2fs_group_{first,last}_block()
Create new ext2fs library inline functions in order to calculate
the starting and ending blocks in a block group.

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-09-12 14:56:16 -04:00
Eric Sandeen d0ff90d520 Fix signed vs unsigned printf format strings for block and inode numbers
There were still some %d's lurking when we print blocks & inodes; also
many of the counters in the e2fsck_struct were signed, and probably
need to be unsigned to avoid overflows.

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-09-12 14:56:15 -04:00
Eric Sandeen 62c6d1403e Remove unused variables
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-09-12 14:56:12 -04:00
Eric Sandeen bb1a46a430 Fix loops over group descriptors to prevent 2**32-1 block number overflows
For loops iterating over all group descriptors, consistently define
first_block and last_block in a way that they are inclusive of the
range, and do not overflow.

Previously on the last block group we did a test of <= first +
dec_blocks; this would actually wrap back to 0 for a total block count
of 2^32-1

Also add handling of last block group which may be smaller.

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-09-12 14:55:22 -04:00