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>
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>
If the RO compat HUGE_FILE feature flag is set, but the inode's
HUGE_FILE_FL flag is not set, we should still pay attention to the
high 32 bits of the i_blocks filed.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Commit 1d9b818: dumpe2fs: Print more information about the inline journal
caused dumpe2fs to use ext2fs_file_open2(). Previously the file_io
functions were only used by debugfs, so if debugfs was disabled,
file_io was not built. Now that dumpe2fs is also using file_io, we
need to build it unconditionally.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
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>
The x86 BT assembly instructure can overshoot the end of a bit array
when testing a bit at the end of the bit array, even if it never needs
to look at those memory locations. This can cause a spurious
segmentation fault. If we allocate a little extra memory, it avoids
this problem. See:
http://faydoc.tripod.com/cpu/bt.htm
This doesn't happen on Linux, probably because of the glibc's malloc()
function works, but apparently it's a major problem on the *BSD
operating systems.
Addresses-Sourceforge-Bug: #2328708
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
For filesystms that have the extent feature enabled, we need to grab
the use EXT2_IOC_GETFLAGS so that we don't accidentally end up trying
to request clearing the EXT2_EXTENT_FL, which is not supported and
causes the tune2fs -j error out.
Also fix the error returning in ext2fs_add_journal_inode() so it
returns a proper error code if the fstat() or ioctl() calls fail.
Addresses-Launchpad-bug: #416648
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
With 64-bit file systems, mke2fs can take a long time to do things
other than write inode tables. I exported the mke2fs numeric progress
meter and used it for allocating group tables and the final file
system flush.
Signed-off-by: Valerie Aurora (Henson) <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Several routines in lib/ext2fs/blknum.c:
ext2fs_bg_free_blocks_count()
ext2fs_bg_free_inodes_count()
ext2fs_bg_used_dirs_count()
ext2fs_bg_itable_unused()
and their _set() counterparts, operate as if they are dealing with
blk64_t quantities, but they should be dealing with __u32 counts
instead.
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Initial design was done by Theodore Ts'o; implementation was fleshed
out by Valerie Aurora Henson. Also includes some fixes from Nick Dokos.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
We are using a signed int to store a block number in
ext2fs_allocate_group_table. We don't actually do any computation or
comparisons using it, so it shouldn't cause any bugs, but it's
technically incorrect, and it's possible an overly clever compiler
might do something wrong with it.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Avoiding inserting a new extent if it is possible to merge the new
block to the beginning or the end of the previous or next extent.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Comment out less common debugging printf's, and fix some type
warnings. Add high-level debugging printf's for ext2fs_extent_goto(),
ext2fs_extent_insert(), ext2fs_extent_delete(), ext2fs_extent_replace()
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Commit 0dc291611 introduced a regression when unmapping the first
block in an extent. This caused e2fsck -fD to corrupt large
directories if the directory has to shrink by more than one block.
The problem was set_bmap should only go to a next leaf when setting a
first block in an extent, and not when it is unmapping the first block
in an extent.
Addresses-Debian-Bug: #537510
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The tst_csum test is now part of csum.c, so there isn't a separate
tst_csum.c file that should be listed as one of the source files in
lib/ext2fs.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
In the case where we ext2fs_extent_set_bmap() is replacing the block
mapping at the beginning of an already-existing extent, insert a new
extent if necessary before shrinking an existing extent, to avoid data
loss if the disk is full.
This mostly addresses the problem described in Red Hat Bugzilla's
statistics are still wrong, but at least the files on the filesystem
are not corrupted. If there is a failure during the
inode_scan_and_fix pass, the simplest thing to do may be to tell the
user to run e2fsck -fy.
Addresses-Red-Hat-Bug: #510379
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Optimize ext2fs_test_block_bitmap_range() and add a new function,
ext2fs_test_inode_bitmap_range(), which works the same way as
ext2fs_block_bitmap_range() but for inode bitmaps. It's needed for
some code in the development branch, so let's drop it into the maint
branch to make life easier in the future.
Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Commit 53422e moved the new extent insertion in
ext2fs_extent_set_bmap() prior to the modification of the original
extent, but the insert function left the handle pointing to the new
extent. This left us modifying the -new- extent, instead of the
original one, and winding up with a corrupt extent tree something
like:
BLOCKS:
(0-1):588791-588792, (0):588791
We need to move back to the previous extent prior
to modification, if we inserted a new one.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Some people don't want to see the concise "kernel-style" make output.
This configure option allows build engines that want to see the full
set of commands executed by the makefile to get what they want. Most
people will find this more distracting than useful, unless they need
to debug the Makefiles.
(It is not necessary to rerun configure to enable this verbose make
output temprarily; if a developer wants to do a quick debug of a
directory's makefile, he or she can simply edit the definition of the
$(E) and $(Q) variables in the Makefile; instructions can be found in
the MCONFIG file which is included in at the beginning of every
Makefile.)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The e2fsprogs makefiles were using the same Makefile variable
LIBCOM_ERR for the link-line arguments as well as the dependencies.
Since LIBCOM_ERR can now include non-file arguments such as
"-lpthread", we need to use a separate DEPLIBCOM_ERR variable that
only has build file dependencies.
Do the same thing for STATIC_LIBCOM_ERR and PROFILED_LIBCOM_ERR.
Addresses-Sourceforge-Patches: #2813809
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
ext2fs_validate_entry would read beyond the end of the block to get
dirent->rec_len for certain arguments (like if blocksize ==
final_offset). This patch adds a check so that doesn't happen, and
changes the types of the arguments to avoid a compiler warning.
Signed-off-by: Nic Case <number9652@yahoo.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Previously e2fsprogs interpreted 0 for a rec_len of 65536 (which could
occur if the directory block is completely empty in 64k blocksize
filesystems), while the kernel interpreted 65535 to mean 65536. The
kernel will accept both to mean 65536, and encodes 65535 to be 65536.
This commit changes e2fsprogs to match.
We add the encoding agreed upon for 128k and 256k filesystems, but we
don't enable support for these larger block sizes, since they haven't
been fully tested.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
I noticed that neither the journal nor resize inodes have
i_extra_isize set post-mkfs; while this isn't likely
to be a big problem, I think the below patch tidies
it up.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The ext2_extent_handle only has a struct ext2_inode allocated on
it, and the same amount copied into it in that same function,
but in update_path() we're possibly writing out more than that -
for example 256 bytes, from that address. This causes uninitialized
memory to get written to disk, overwriting the parts of the
inode past the osd2 member (the end of the smaller structure).
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Each time an extent handle is opened and closed, if the inode has an
extent tree which does not fit in the inode's i_block structure, a
filesystem block buffer was not getting released. Since e2fsck opens
an extent handle for every inode using extents, this can translate to
a very large amount of memory getting lost.
Thanks to Henrik 'Mauritz' Johnson for discovering and pointing out
this leak, which he ran into while running the "rdump" command in
debugfs.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Added 64-bit mkjournal.c interface. Needed to zero inode tables.
Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Add new ext2fs_descriptor_block_loc2() routine that takes blk64_t as
an input.
Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The new ext2fs_super_and_bgd_loc2() function has some changes aside
from just blk64_t support. Lets make sure that the interfaces are
sane by adding libext2fs support early to get the new API tested here.
Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Add new ext2fs_super_and_bgd_loc2() that returns blk64_t pointers.
The function now returns the number of blocks used by super block and
group descriptors since with flex_bg, it can no longer be assumed that
bitmaps and inode tables still resided within the block group.
Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>