Commit Graph

2969 Commits (f2fe5da31deebc689bb64e71c8e873efc925d312)

Author SHA1 Message Date
Eric Sandeen f2fe5da31d e2fsprogs: fix potential null ptr defef in check_for_modules()
The coverity scanner found this one.

If a line in modules.dep has a ":" but no "/" then:

                if ((cp = strchr(buf, ':')) != NULL)
                        *cp = 0;
                else
                        continue;
                if ((cp = strrchr(buf, '/')) != NULL)
                        cp++;
                /* XXX else cp is still null */
                i = strlen(cp);

... we will deref a null pointer (cp).  This can be
demonstrated by putting a line like:

foo.ko:

into modules.dep.  The below change just says that if no "/" is
found, treat the whole string as the module name.

Addresses-Red-Hat-Bugzilla: #486997

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-03-06 02:37:33 -05:00
Theodore Ts'o 8d8224550c mke2fs, tune2fs: Do not allow the reserved_ratio to be negative
Add a check to make sure the argument to the -m option (which
specifies the reserved ratio) is greater than zero.

Addresses-Debian-Bug: #517015

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-03-06 02:25:06 -05:00
Theodore Ts'o b7c5b40308 Add support for a new superblock field: s_kbytes_written
This field tracks the lifetime amount of writes to the filesystem.  It
will be updated by the kernel as well as by e2fsprogs programs which
write to the filesystem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-03-06 01:59:23 -05:00
Theodore Ts'o b2ca48f40e Update release notes, changelog, etc., for e2fsprogs 1.41.4 release
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-27 19:51:00 -05:00
Theodore Ts'o 945ffb9ec9 Update e2fsprogs translation template. 2009-01-26 20:45:46 -05:00
Theodore Ts'o cf9fbcccbc e2fsck: Add missing newlines when reporting errors in pass 3A
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-26 16:41:46 -05:00
Theodore Ts'o 206d2ade6e e2fsck: Change PR_3_CREATE_LPF_ERROR to be a non-fatal problem
The other problem codes associated with failing to create the
lost+found directory are non-fatal, and this one should be non-fatal
as well.  The two places which call e2fsck_get_lost_and_found()
already deal with a failure to create the directory, so there's no
point making this be a fatal error.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-22 16:05:29 -05:00
Theodore Ts'o cf4e06d665 libext2fs: Add sanity checks to ext2fs_{block,inode}_alloc_stats
If ext2fs_inode_alloc_stats2() or ext2fs_block_alloc_stats() is passed
an insanely large inode or block number, it's possible for these
functions to overrun an array boundary and cause the calling program
to crash with a memory error.

Detect this case, and since these functions don't return an error
code, print a warning message, much like we do in ext2fs_warn_bitmap2().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-22 16:01:38 -05:00
Theodore Ts'o a93d406960 ext2fs_new_inode(): Add sanity check to assure a valid inode number
Add a sanity check to makesure that even if the superblock field
s_first_inode is insane, that we won't return an invalid inode number.
(The function will return the error EXT2_ET_INODE_ALLOC_FAIL in that
case.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-22 15:55:49 -05:00
Theodore Ts'o 1f790a7cc1 e2fsck: Add superblock check to make sure s_first_ino is valid
An deliberately corrupted filesystem with an insanely large
s_first_ino field could cause e2fsck to crash with a seg fault.

Thanks to Eric Sesterhenn for supplying test cases which demonstrated
this issue.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-22 15:52:50 -05:00
Theodore Ts'o 37d17a65ec mke2fs: If the device size is exactly 16TB treat it as if it had 16TB - 1 block
This allows users who create a 16TB LVM to have mke2fs do (mostly) the
right thing automatcally.
2009-01-20 14:03:03 -05:00
Theodore Ts'o 9f7a1fc936 ext2fs_get_device_size: Fix error handling
The previous patch would return EFBIG for any failure called from
ext2fs_get_device_size2().  (I didn't merge this fix with the
preceeding commit to allow merges to happen more easily.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 13:37:47 -05:00
Jose R. Santos beab8de477 Add 64-bit getsize interface.
Added interface capable of opening 64-bit block device.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 13:35:15 -05:00
Theodore Ts'o b0afdda1bc mke2fs: Add -U option to specify the UUID for the new filesystem
Patch integrated from Mandriva

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 13:20:31 -05:00
Theodore Ts'o 5299580c1c Use format strings directly to prevent -Werror=format-security failures
Gcc is too stupid to realize that:

    const char *usage="String which has no percent signs";

    com_err(progname, 0, usage);

is OK.  I refuse to bow to stupidity with:

   com_err(progname, 0, "%s", usage);

but I will use the string directly for the sake of people who like to
build with -Werror=format-security.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 13:05:25 -05:00
Theodore Ts'o 31e2a75484 blkid: Add support for detecting user-level suspend as a swsuspend signature
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 12:08:07 -05:00
Theodore Ts'o 1a71bd4200 mke2fs: Treat an argv[0] of "mke3fs" the same as "mkfs.ext3"
Mandriva apparently uses "mke3fs" as an alias for mkfs.ext3.  I'm not
particularly fond of that practice, but we'll include it as legacy
support.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 12:02:40 -05:00
Theodore Ts'o 31f1815fa9 tune2fs: Fix tune2fs -I so it won't corrupt RAID filesystems
If a filesystem is built with the stride extended-option (which is
often used in RAID filesystems to make sure the block and inode
allocation bitmaps don't end up hitting one disk platter harder than
the rest), this can cause tune2fs -I to corrupt the filesystem because
it fails to handle the case where the allocation bitmaps are located
after the inode table, where the inode table needs to grow.  Handle
this case correctly.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 11:49:17 -05:00
Theodore Ts'o ec43da2f35 tune2fs: General (whitespace) cleanup
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 02:34:39 -05:00
Theodore Ts'o 5bf81baea0 tune2fs: Don't allow the -I option if the flex_bg feature is enabled
With flex_bg usually the inode table for most block groups are packed
right against each other, so expanding the inode table size needs
special handling that's not currently in tune2fs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 01:50:07 -05:00
Eric Sandeen 801b005333 blkid: recognize btrfs
Add btrfs detection to libblkid, now that the disk format should be
recognizable in the future.

# misc/blkid /tmp/fsfile
/tmp/fsfile: LABEL="mylabel" UUID="102b07f0-0e79-4b42-8a4e-1dde418bbe6d" TYPE="btrfs"

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-01-20 00:57:59 -05:00
Theodore Ts'o c66130f186 debian: Add "set -e" to uuid-runtime's prerm script
This addresses a Lintian warning.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 00:55:32 -05:00
Theodore Ts'o 793a04a071 resize2fs: Reserve some extra space for -P/-M for ext4 filesystems
Some extra blocks may be needed to expand some extent allocation trees
while we are shrinking the filesystem.  We don't know exactly how
much, so we use a hueristic.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 00:46:06 -05:00
Thiemo Nagel 79a9ab1454 ext2fs_open2: Add more checks for filesystem consistency
Add more checks to assure the filesystem is sane to avoid later
division by zero errors.

Patch adds consistency checks on superblock to fix serveral crashes:
* require EXT2_INODES_PER_GROUP != 0
* require EXT2_DESC_PER_BLOCK != 0
* require s_first_data_block < s_blocks_count
* require group_desc_count * EXT2_INODES_PER_GROUP == s_inodes_count

Signed-off-by: Thiemo Nagel <thiemo.nagel@ph.tum.de>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-19 23:16:10 -05:00
Theodore Ts'o a7843581f5 ext2fs_read_inode_full: Add safety check to avoid SEGV's on corrupted fs's
Thanks to Thiemo Nagel for suggesting this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-19 23:09:37 -05:00
Theodore Ts'o 3a4ec2ba0f debian: Add mkfs.ext4 symlink to the e2fsprogs-udeb package
This patch is needed for Ubuntu Januty.

Addresses-Debian-Bug: #511207

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-19 21:05:49 -05:00
Theodore Ts'o 07f1a070ff ext2fs_block_iterate2: Preserve the uninit flag in extents
When modifying a block via the block_iterate interface, preserve the
uninit flag in the extent.  Resize2fs uses this interface, so we have
to preserve the uninit status when relocating a block.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-19 19:30:59 -05:00
Theodore Ts'o d3a8fc5ae6 ext2fs_block_iterate2: Reflect errors from ext2fs_extent_set_bmap to caller
If the callback function tries to change a block, and
ext2fs_extent_set_bmap() fails for some reason (for example, there
isn't enough disk space to split a node and expand the extent tree,
make sure that error is reflected back up to the caller.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-19 14:29:08 -05:00
Theodore Ts'o 9227c5bbbd resize2fs: Release bitmap and itable blocks in flex_bg filesystems
Previously resize2fs assumed that bitmap and inode table blocks were
always located in their respective block group.  However, this is no
longer true with flex_bg.  So it is necessary to check all of the
block groups which will be truncated to see if they have metadata
blocks that need to be marked as no longer being in use in the new,
shrunk filesystem.

This bug fixes resize2fs -M, which would otherwise fail because
without the released blocks, there would not be enough space in the
filesystem.  This bug also avoids (mostly harmless) filesystem
corruptions reported by e2fsck regarding blocks marked in use but not
actually used (these being the bitmap and inode table blocks
associated with the truncated block groups).

Note: in theory it is possible to have block group N utilize bitmap
and inode table blocks in block group N+X with flex_bg.  At the moment
neither mke2fs nor e2fsck will create filesystems like this, which is
good, because resize2fs doesn't handle this case correctly.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-19 09:02:55 -05:00
Theodore Ts'o c58a08e673 resize2fs: Move all required blocks for ext4 filesystems
In the function blocks_to_move(), when checking to see if a block
group's block bitmap is initialized, we need to check the old_fs's
block group descriptors, not the new file system's (already truncated)
group descriptor data structures.  Otherwise we will end up
derferencing past the end of the array boundary, and the resulting
garbage value may indicate that the bitmap is uninitialized, and so
all of the blocks in that block group will be skipped, resulting in
some blocks not getting marked as needing relocation.

This showed up in the following test case:

     mke2fs -t ext4 -b 1024 test.img 1048576
     resize2fs test.img 80000

The journal inode after the resize operation looked like this:

debugfs:  stat <8>
Inode: 8   Type: regular    Mode:  0600   Flags: 0x80000
...
BLOCKS:
(IND):35385, (0-5836):2356-8192, (5837-21959):8454-24576, (21960-32506):24838-35
384, (32507-32767):434177-434437
TOTAL: 32769

The blocks 434177-434437 were not moved because block group 53 was
wrongly thought to have an unitialized block group.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-19 08:43:36 -05:00
Theodore Ts'o 98446d7382 debugfs: Fix logdump command for 32-bit filesystems
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-18 22:48:16 -05:00
Theodore Ts'o e35d548b59 e2fsck: Fix journal replay for block sizes greater than 8k
E2fsck was using a fixed-size 8k buffer for replaying blocks from the
journal.  So attempts to replay a journal on filesystems greater than
8k would cause e2fsck to crash with a segfault.

Thanks to Miao Xie <miaox@cn.fujitsu.com> for reporting this problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-02 18:14:42 -05:00
Theodore Ts'o dd04d05f70 e2fsck: Remove "ext3" from problem descriptions of the journal
The ext4 filesystem uses journals too, so remove "ext3" from the
problem descriptions involving journals.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-01 23:10:40 -05:00
Theodore Ts'o a558d5dc22 Add e2fsck regression test case f_extent_bad_node
This test case is designed to test e2fsck's ability to deal with a
corrupted interior node in an extent tree.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-12-25 22:47:03 -05:00
Theodore Ts'o 7518c17686 e2fsck: Fix an unhandled corruption case in scan_extent_node()
A corrupted interior node in an extent tree would cause e2fsck to
crash with the error message:

Error1: Corrupt extent header on inode 107192
Aborted (core dumped)

Handle this and related failures when scanning an inode's extent tree
more robustly.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-12-25 22:42:38 -05:00
Theodore Ts'o 7dca4c88f1 e2fsck: When repacking directories, leave slack space for more efficiency
If the directory is packed with no slack space, as soon as any new
directory entries are added, leaf nodes end up getting split and
directory ends up getting very inefficient.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-12-25 17:59:36 -05:00
Theodore Ts'o d5a74ff10b e2fsck: Fix double-counting of non-contiguous extent-based inodes
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-12-22 01:23:59 -05:00
Theodore Ts'o 100d4701d5 e2fsck: Enhance fragcheck report with file/directory information
Report whether a fragmented inode is a directory or a file, as this is
highly useful for determining what is going on with an ext4 filesystem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-12-08 22:00:13 -05:00
Theodore Ts'o ce44d8cafa e2fsck: In verbose mode, distinguish between fragmented directories/files
Track the number of non-contiguous files and directories so we can
give more detailed information in verbose mode.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-12-08 21:33:11 -05:00
Theodore Ts'o 42e89ce7f8 e2fsck: Don't cancel the fsck run after clearing an errant INODE_UNINIT flag
Thanks to Kelly Kane from Dreamhost for reporting this bug and then
helping us find and fix it.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-11-26 20:41:26 -05:00
Theodore Ts'o 8680b4e680 Add make-sparse.c to contrib
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-11-17 17:52:15 -05:00
Theodore Ts'o 124e6767fc debian: Fix mkinitfs on x86_64 systems
On x86_64 systems, we need to filter out linux-vdso.so lines from the
output of the ldd program when determining the library dependencies.

Addresses-Debian-Bug: #503057

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-11-16 10:35:41 -05:00
Theodore Ts'o 03fa6f8ae2 Fix various signed/unsigned gcc warnings
Some of these could affect filesystems between 2^31 and 2^32-1 blocks.

Thanks to Valerie Aurora Henson for pointing out the problems in
lib/ext2fs/alloc_tables.c, which led me to do a "make gcc-wall" scan
over the source tree.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-11-16 10:06:59 -05:00
David Planella dd20e25f06 po: update ca.po (from translationproject.org)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-11-15 15:07:39 -05:00
Theodore Ts'o a11d0746b4 dumpe2fs: Only print inline journal information if the journal is internal
Currently dumpe2fs displays an error if run on a filesystem with an
external journal.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-11-15 15:05:51 -05:00
Theodore Ts'o ad64399d15 Add support to build profiled binaries in the misc directory
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-11-15 12:34:28 -05:00
Theodore Ts'o 992a2f7f68 e2fsck: Fix build of e2fsck.profiled if profiling is enabled
It's been a while since I've done a build using "configure
--enable-profile", and some bitrot had set into the Makefiles...

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-11-15 12:12:57 -05:00
Theodore Ts'o 27c6de45a4 tune2fs: Fix inefficient O(n**2) algorithms when expanding the inode size
When running "tune2fs -I 256" on moderate to large filesystems, the
time required to run tune2fs can take many hours (20+ before some
users gave up in disgust).  This was due to some O(n**2) and O(n*m)
algorithms in move_block() and inode_scan_and_fix(), respectively.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-11-15 00:32:39 -05:00
Theodore Ts'o 9d4a4dc287 tune2fs: Update the block group checksums when changing the UUID
Since the block group checksums depend on the UUID, we need to update
the block group checksums when setting the UUID.  We only do so if all
of the checksums are correct, however.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-11-14 17:42:27 -05:00
Theodore Ts'o e3d41d397f debugfs: Fix ncheck display so that extra characters aren't printed
Fix a single-character typo in the printf format statement.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-10-20 23:51:53 -04:00