OSDN Git Service

android-x86/external-e2fsprogs.git
10 years agoAdd coverage testing using gcov
Theodore Ts'o [Sun, 23 Feb 2014 05:17:09 +0000 (00:17 -0500)]
Add coverage testing using gcov

To check the coverage of e2fsprogs's regression test, do the
following:

configure --enable-gcov
make -j8 ; make -j8 check ; make coverage.txt

The coverage information will be the coverage.txt and *.gcov files in
the build directories.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoSet pointer to NULL after ext2fs_free
Lukas Czerner [Fri, 21 Feb 2014 01:54:29 +0000 (20:54 -0500)]
Set pointer to NULL after ext2fs_free

ext2fs_free() does not set the ext2_filsys pointer to null so the
caller is responsible to setting it himself if it is needed.

This patch fixes some places where caller did not set ext2_filsys
pointer to NULL after ext2fs_free() which might result in use after
free.  Fix it.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agotune2fs: allow removal of dirty journal with two "-f" options
Eric Sandeen [Fri, 21 Feb 2014 01:18:41 +0000 (20:18 -0500)]
tune2fs: allow removal of dirty journal with two "-f" options

Jim pointed out that "tune2fs -f -O ^has_journal" won't remove the
journal if the needs_recovery flag is set; the manpage seems to indicate
that it should.  And if you've lost an external journal and can no longer
replay it, how should one proceed?

Change tune2fs so that two "-f" options will allow removal of a dirty
journal from a filesystem, even if the filesystem needs recovery.

e2fsck can then do its best to pick up the pieces.

Addresses-Debian-Bug: #559301

Reported-by: Jim Faulkner <james.faulkner@yale.edu>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: delete unused "handle" variable
jon ernst [Fri, 21 Feb 2014 00:59:24 +0000 (19:59 -0500)]
libext2fs: delete unused "handle" variable

After commit 62f17f36031102a2a40fac338e063c556f73b94a, variable
"handle" has no use.  So delete it.

Signed-off-by: Jon Enrst <jonernst07@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe4defrag: remove local sync_file_range and fallocate
Baruch Siach [Wed, 19 Feb 2014 01:02:49 +0000 (20:02 -0500)]
e4defrag: remove local sync_file_range and fallocate

The locally defined versions of both sync_file_range and fallocate are broken
on 32bit systems. On these systems two 32bit registers are needed for each
64bit parameter. Also, sync_file_range on MIPS32 needs a dummy parameters
after the fd parameter. Just leave all these subtleties to the C library.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agoext2fs: declare struct_io_manager at end of file
Andreas Dilger [Tue, 18 Feb 2014 23:31:36 +0000 (18:31 -0500)]
ext2fs: declare struct_io_manager at end of file

Declare struct_io_manager at the end of unix_io.c, undo_io.c, and
test_io.c files so that there isn't a need to forward declare every
member of this structure.  That avoids a lot of redundant code
at the start of every one of these files.

Move the test_flush() function above test_abort() to avoid the need
for a forward declaration.

Fix a few instances of space before tab in these files.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agotests: skip unsupported tests on MacOS systems
Andreas Dilger [Tue, 18 Feb 2014 23:29:55 +0000 (18:29 -0500)]
tests: skip unsupported tests on MacOS systems

The "mkswap" program is not available on MacOS, so just use the
existing swap0.img.bz2 and swap1.img.bz2 files directly.

Because MacOS HFS+ doesn't support sparse files (welcome to the 80's)
the m_bigjournal test takes forever to zero out the whole 42GB test
filesystem.  Skip this test for Darwin kernels for now.

Unfortunately, neither "df -T" nor "stat -f -c %T" is available on
MacOS to directly determine the filesystem type, and I'm too lazy
to parse the output of "mount" and match it to the path of the test
directory in shell, so it just checks the kernel type and assumes
the filesystem type is HFS and skips the test.

Since this test runs on Linux the majority of the time, the loss of
test coverage is minimal.  If MacOS should ever get a real filesystem,
this can be revisited.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agobuild: fix LLVM compiler warnings
Andreas Dilger [Tue, 18 Feb 2014 17:12:32 +0000 (12:12 -0500)]
build: fix LLVM compiler warnings

Fix a number of non-literal string format warnings from LLVM due
to the use of _() that were not fixed in commit 45ff69ffeb.

Fix mismatched int vs. __u64 format warnings in blkmap64_rb.c.
There were also some comparisons of __u64 start or count <= 0.
Change them to be comparisons == 0, or start + count overflow.

Fix operator precedence warning for (value & (value - 1) != 0)
introduced in 11d1116a7c0b.  It seems "&" is lower precedence
than "!=", so the above didn't fail for power-of-two values,
but only odd values.  Fortunately, either s_desc_size nor
s_inode_size is valid if odd.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agochattr: improve the description for 'j' option in manpage
Zheng Liu [Wed, 12 Feb 2014 17:28:29 +0000 (12:28 -0500)]
chattr: improve the description for 'j' option in manpage

Ext4 file system also supports to set/clear 'j' attribute, but it just
say that this option is only useful for ext3 in manpage.  This commit
fixes it.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
10 years agolibe2p: allow libe2p.h to be used in C++ programs
Theodore Ts'o [Fri, 7 Feb 2014 22:25:28 +0000 (17:25 -0500)]
libe2p: allow libe2p.h to be used in C++ programs

In C++, "private" is a reserved keyword, so don't use it in the header
file as a function parameter name.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: try to roll back when splitting an extent fails
Darrick J. Wong [Thu, 6 Feb 2014 20:34:00 +0000 (15:34 -0500)]
libext2fs: try to roll back when splitting an extent fails

If a client asks us to remap a block in the middle of an extent, we
potentially have to allocate a fair number of blocks to handle extent
tree splits.  A failure in either of the ext2fs_extent_insert calls
leaves us with an extent tree that no longer maps the logical block in
question and everything that came after it!  Therefore, try to roll
back the extent tree changes before returning an error code.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agolibext2fs: don't hang on to unmapped block if extent tree update fails
Darrick J. Wong [Thu, 6 Feb 2014 20:32:18 +0000 (15:32 -0500)]
libext2fs: don't hang on to unmapped block if extent tree update fails

If we're doing a BMAP_ALLOC allocation and the extent tree update
fails, there's no point in hanging on to the newly allocated block.
So, free it to make fsck happy.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agolibext2fs: during punch, fix parent extents after modifying extent
Darrick J. Wong [Thu, 6 Feb 2014 20:30:59 +0000 (15:30 -0500)]
libext2fs: during punch, fix parent extents after modifying extent

When modifying/removing an extent during punch, don't forget to update
the extent's parents.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agolibext2fs: iterate past lower extents during punch
Darrick J. Wong [Thu, 6 Feb 2014 20:29:15 +0000 (15:29 -0500)]
libext2fs: iterate past lower extents during punch

When we're iterating extents during a punch operation, the loop exits
if the punch region is entirely to the right of the extent we're
looking at.  This can happen if the punch region starts in the middle
of a hole and covers mapped extents.  When this happens, we want to
skip to the next extent, because it might be punchable.

Also, if we've totally passed the punch range, stop.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agomke2fs: clean up kernel version tests
Darrick J. Wong [Thu, 6 Feb 2014 20:24:01 +0000 (15:24 -0500)]
mke2fs: clean up kernel version tests

Refactor the running kernel version checks to hide the details of
version code checking, etc.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agoe2fsprogs: Disallow tune2fs enabling sparse_super with ext4 meta_bg enabled
Akira Fujita [Thu, 6 Feb 2014 20:11:52 +0000 (15:11 -0500)]
e2fsprogs: Disallow tune2fs enabling sparse_super with ext4 meta_bg enabled

When meta_bg feature is enabled, group descriptor block is allocated
every 128 block group (or every 64 block group if 64bit feature is
enabled).

In such situation, files in block group more than #128 will be removed
if sparse_super feature is enabled with tune2fs and afterwards
necessary e2fsck running.

Because tune2fs does not reallocate group descriptor blocks but just
set sparse_super feature.  If ext4 has sparse_super,
ext2fs_descriptor_block_loc2() called by e2fsck thinks the block group
(e.g. #128) that it has group descriptor block at the head offset. But
that offset is used as backup super block before.  So e2fsck fixes
ext4 based on invalid group descriptor blocks and this cause data
lost.

The patch avoids this problem simply by disallow tune2fs enabling
sparse_super if meta_bg is enabled.

Steps to reproduce:

1. Create ext4 which has meta_bg, ^sparse_super and 129+ block groups.
# mke2fs -t ext4 -O meta_bg,^resize_inode,^sparse_super DEV 17G
# mount DEV /MP

2. Create direcotry and files which use block group #128's metadata.
# echo $((8192*128+1)) > /sys/fs/ext4/DEV/inode_goal
# mkdir /MP/DIR
# for i in $(seq 1 100); do dd if=/dev/urandom of=/MP/DIR/file$i bs=1024 count=10; done

3. Enable sparse_super with tune2fs then execute e2fsck.
   Data in block group #128 will be lost!!
# umount DEV
# tune2fs -O sparse_super DEV
# e2fsck/e2fsck -yf DEV

Signed-off-by: Akira Fujita <a-fujita@rs.jp.ne.cocm>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agodebian: fix spelling typo in debian/control.in
Theodore Ts'o [Thu, 6 Feb 2014 20:00:44 +0000 (15:00 -0500)]
debian: fix spelling typo in debian/control.in

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agodebian: add make variable to prevent building udeb packages
Theodore Ts'o [Thu, 6 Feb 2014 19:59:25 +0000 (14:59 -0500)]
debian: add make variable to prevent building udeb packages

Setting SKIP_UDEBS=yes in rules.custom will prevent the debian/rules
makefile from building the udeb files for the debian installer.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs: minor bugfixes for mk_hugefiles
Theodore Ts'o [Thu, 6 Feb 2014 19:34:12 +0000 (14:34 -0500)]
mke2fs: minor bugfixes for mk_hugefiles

Interpret "zero_hugefiles" relation in mke2fs.conf as a boolean value,
as documented in the man page.

If the hugefile is larger than 2GB, set the large_file file system
feature so e2fsck doesn't complain.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoconfigure: support biarch builds with --multiarch=lib64
Theodore Ts'o [Wed, 5 Feb 2014 20:45:36 +0000 (15:45 -0500)]
configure: support biarch builds with --multiarch=lib64

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agodebian: update debian/changelog and e2fslibs.symbols for 1.42.9-3 release
Theodore Ts'o [Wed, 5 Feb 2014 03:59:25 +0000 (22:59 -0500)]
debian: update debian/changelog and e2fslibs.symbols for 1.42.9-3 release

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agodebian: fix dpkg-buildpackage for Debian Squeeze
Theodore Ts'o [Wed, 5 Feb 2014 02:45:51 +0000 (21:45 -0500)]
debian: fix dpkg-buildpackage for Debian Squeeze

Commit becb01ce84d breaks building e2fsprogs with dpkg 1.15.8 which is
used in Debian 6.0 (Squeeze), since it doesn't support package
specifications qualified with an architecture (i.e., "dpkg-query -W
libblkid1:amd64").

Debian only needs to use its own version of libblkid and libuuid for
versions of Debian 5.0 (Lenny) or before.  So default to using
util-linux-ng, instead of trying to test the version number of
libblkid1.

Lenny was released in February, 2009, and the current stable Debian
release is 7.x, so it is two stable releases back as of February 2014.
In the unlikely case someone needs to build a modern version of
e2fsprogs on a version of Debian which is five years old or older, can
create the file Debian/rules.custom with the line:

UTIL_LINUX_NG = no

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs: add support for hugefiles_align
Theodore Ts'o [Tue, 4 Feb 2014 17:30:00 +0000 (12:30 -0500)]
mke2fs: add support for hugefiles_align

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoFix up the Makefiles dependencies in lib/ext2fs and lib/quota
Theodore Ts'o [Thu, 30 Jan 2014 23:48:23 +0000 (18:48 -0500)]
Fix up the Makefiles dependencies in lib/ext2fs and lib/quota

Also use angle brackets for the #include of dirpaths.h to avoid the
need to manually massage the Makefile.in for the util directory.  This
is needed because we have to create a fake dirpaths.h file in the util
directory.  The fake dirpaths.h file is rquired to break the circular
dependency caused by util/subst creating dirpaths.h, while
util/subst.c is including config.h, which includes dirpaths.h.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoblkid: suppress Coverity warning
Theodore Ts'o [Thu, 30 Jan 2014 23:02:37 +0000 (18:02 -0500)]
blkid: suppress Coverity warning

The getopt() function will never let optarg be NULL (at least without
using the GNU double-colon extension, which we don't use because it's
not portable), so don't bother checking for that case.  It's harmless,
but it triggers a Coverity warning elsewhere, since it thinks optarg
could in fact be NULL.

Addresses-Coverity-Id: #1049156

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibss: fix potential buffer overrun in list_rqs
Theodore Ts'o [Thu, 30 Jan 2014 22:45:36 +0000 (17:45 -0500)]
libss: fix potential buffer overrun in list_rqs

Addresses-Coverity-Bug: #709516

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoquota: fix uninitiaized memory reference in mke2fs with quota enabled
Theodore Ts'o [Thu, 30 Jan 2014 22:10:46 +0000 (17:10 -0500)]
quota: fix uninitiaized memory reference in mke2fs with quota enabled

Initialize the on-disk structure before we fill it in, to avoid the
following valgrind warning:

   Conditional jump or move depends on uninitialised value(s)
      at 0x4323A8: qtree_entry_unused (quotaio_tree.c:40)
      by 0x431218: v2r1_mem2diskdqblk (quotaio_v2.c:85)
      by 0x432409: qtree_write_dquot (quotaio_tree.c:336)
      by 0x431136: v2_commit_dquot (quotaio_v2.c:264)
      by 0x42FB63: quota_write_inode (mkquota.c:126)
      by 0x408BE6: create_quota_inodes (mke2fs.c:2466)
      by 0x409A2D: main (mke2fs.c:2850)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoblkid: avoid potential integer overflow issues identified by Coverity
Theodore Ts'o [Thu, 30 Jan 2014 21:19:01 +0000 (16:19 -0500)]
blkid: avoid potential integer overflow issues identified by Coverity

Addresses-Coverity-Id: #1049157
Addresses-Coverity-Id: #1049158

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs: add make_hugefile feature
Theodore Ts'o [Tue, 21 Jan 2014 04:06:07 +0000 (23:06 -0500)]
mke2fs: add make_hugefile feature

This feature is enabled via settings in /etc/mke2fs.conf.  For
example:

hugefile = {
features = extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize,^resize_inode,sparse_super2
inode_size = 128
num_backup_sb = 0
packed_meta_blocks = 1
make_hugefiles = 1
inode_ratio = 4194304
hugefiles_dir = /database
hugefiles_uid = 120
hugefiles_gid = 50
hugefiles_name = storage
hugefiles_digits = 4
hugefiles_size = 1G
num_hugefiles = 0
}

Then "mke2fs -T hugefile /dev/sdXX" will create as many 1G files
needed to fill the file system.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe2fsck, mke2fs: enable octal integers in the profile/config file
Theodore Ts'o [Tue, 21 Jan 2014 05:59:03 +0000 (00:59 -0500)]
e2fsck, mke2fs: enable octal integers in the profile/config file

If an integer in the config file starts with a 0, interpret it as an
octal number.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs: allow metadata blocks to be at the beginning of the file system
Theodore Ts'o [Tue, 28 Jan 2014 19:44:23 +0000 (14:44 -0500)]
mke2fs: allow metadata blocks to be at the beginning of the file system

Add the extended options packed_meta_blocks and journal_location_front
which causes mke2fs to place the metadata blocks at the beginning of
the file system.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoAdd support for new compat feature "sparse_super2"
Theodore Ts'o [Sun, 12 Jan 2014 03:11:42 +0000 (22:11 -0500)]
Add support for new compat feature "sparse_super2"

In practice, it is **extremely** rare for users to try to use more
than the first backup superblock located at the beginning of block
group #1.  (i.e., at block number 32768 for file systems with a 4k
block size).  This new compat feature restricts the backup superblock
to block group #1 and the last block group in the file system.

Aside from reducing the overhead of the file system by a small number
of blocks, by eliminating the rest of the backup superblocks, it
allows us to have a much more flexible metadata layout.  For example,
we can force all of the allocation bitmaps and inode table blocks to
the beginning of the disk, which allows most of the disk to be
exclusively used for contiguous data blocks.

This simplifies taking advantage of certain HDD specific features,
such as Shingled Magnetic Recording (aka Shingled Drives), and the
TCG's OPAL Storage Specification where having a simple mapping between
LBA block ranges and the data blocks used by the file system can make
life much simpler.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agotune2fs, mke2fs: add the ability to control the location of the journal
Theodore Ts'o [Tue, 28 Jan 2014 17:58:56 +0000 (12:58 -0500)]
tune2fs, mke2fs: add the ability to control the location of the journal

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: add new function ext2fs_add_journal_inode2()
Theodore Ts'o [Tue, 28 Jan 2014 17:16:35 +0000 (12:16 -0500)]
libext2fs: add new function ext2fs_add_journal_inode2()

This new function has an parameter which allows the caller to specify
the location of the journal.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: factor out get_midpoint_journal_block() in mkjournal.c
Theodore Ts'o [Tue, 28 Jan 2014 17:12:27 +0000 (12:12 -0500)]
libext2fs: factor out get_midpoint_journal_block() in mkjournal.c

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs: optimize fix_cluster_bg_counts()
Theodore Ts'o [Mon, 20 Jan 2014 00:44:45 +0000 (19:44 -0500)]
mke2fs: optimize fix_cluster_bg_counts()

Instead of iterating over the allocation bitmap using
ext2fs_test_block_bitmap2(), bit by bit, use
ext2fs_find_first_set_block_bitmap2() instead.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: optimize ext2fs_new_block2()
Theodore Ts'o [Mon, 20 Jan 2014 00:35:33 +0000 (19:35 -0500)]
libext2fs: optimize ext2fs_new_block2()

If there are hundreds of thousands of blocks which are in use before
the first free block, it is much, MUCH faster to use
ext2fs_find_first_zero_block_bitmap2() instead of searching the
allocation bitmap bit by bit.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: optimize ext2fs_allocate_group_table()
Theodore Ts'o [Sun, 19 Jan 2014 21:47:21 +0000 (16:47 -0500)]
libext2fs: optimize ext2fs_allocate_group_table()

By using ext2fs_mark_block_bitmap_range2 and/or
ext2fs_block_alloc_stats_range(), we can significantly speed up the
time needed by mke2fs to allocate the inode table.

For example, the CPU time needed to run the command "mke2fs -t ext4
/tmp/foo.img 32T" (where tmpfs was mounted on /tmp) was decreased from
21.7 CPU seconds down to under 1.7 seconds.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: add ext2fs_block_alloc_stats_range()
Theodore Ts'o [Sun, 19 Jan 2014 21:35:50 +0000 (16:35 -0500)]
libext2fs: add ext2fs_block_alloc_stats_range()

This function is more efficient than using ext2fs_block_alloc_stats2()
for each block in a range.  The efficiencies come from being able to
set a block range in the block bitmap at once, and from being update
the block group descriptors once per block group.  Especially now that
we are checksuming the block group descriptors, and we are using red
black trees for the allocation bitmaps, these changes can make a huge
difference in the CPU time used by mke2fs when creating very large
file systems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: further clean up and rename check_block_uninit
Theodore Ts'o [Sun, 19 Jan 2014 06:24:30 +0000 (01:24 -0500)]
libext2fs: further clean up and rename check_block_uninit

Commit 8e44eb64bb (libext2fs: mark group data blocks when loading
block bitmap) simplified check_block_uninit since we are now
initializing the bitmap when it is loaded from disk.  It left some
variables which were being set but never used, however.  In addition,
since we only need check_block_uninit() to clear the block bitmap's
uninit flag, rename it to clear_block_uninit(), and only call it once
we have found a free block in ext2fs_new_blocks2().

This cleans up the code some and optimizes things if we need to search
multiple block groups trying to find a free block.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Darrick J. Wong <darrick.wong@oracle.com>
10 years agolibext2fs: optimize find_first_{zero,set}() for red-black tree based bitmaps
Theodore Ts'o [Mon, 13 Jan 2014 02:46:46 +0000 (21:46 -0500)]
libext2fs: optimize find_first_{zero,set}() for red-black tree based bitmaps

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: optimize find_first_set() for bitarray-based bitmaps
Theodore Ts'o [Mon, 13 Jan 2014 02:45:04 +0000 (21:45 -0500)]
libext2fs: optimize find_first_set() for bitarray-based bitmaps

Basically just a trivial adaption of the find_first_zero() function
for bitarray-based bitmaps.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: build tst_bitmaps with rep invariants checking enabled
Theodore Ts'o [Mon, 13 Jan 2014 01:18:55 +0000 (20:18 -0500)]
libext2fs: build tst_bitmaps with rep invariants checking enabled

When building tst_bitmaps, enable #define DEBUG_RB, so we are
always testing the sanity of the in-memory representation of the
bitmap when using red-black trees as part of a "make check" run.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: clean up generic handling of ext2fs_find_first_{set,zero}_*()
Theodore Ts'o [Mon, 13 Jan 2014 00:45:43 +0000 (19:45 -0500)]
libext2fs: clean up generic handling of ext2fs_find_first_{set,zero}_*()

Move the error checking into the the generic bitmap code, and add
support for bitmaps with cluster_bits set.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: fix off-by-one bug in ext2fs_extent_insert()
Theodore Ts'o [Thu, 16 Jan 2014 04:29:21 +0000 (23:29 -0500)]
libext2fs: fix off-by-one bug in ext2fs_extent_insert()

When inserting the first extent into an empty inode, the
ext2fs_extent_insert() leaves path->left set to 1 instead of 0.  Since
path->curr is pointing at the last (only) extent in the file,
path->left should be 0.

This is mostly harmless, and gets corrected fairly quickly if the
calling applicaton jumps to a different part of the extent tree ---
for example, by calling ext2fs_extent_goto(), or calling
ext2fs_extent_get with the flags argument set to EXT2_EXTENT_ROOT.
Which is why we hadn't noticed this problem until now.

However, if you insert four extents using ext2fs_extent_insert, the
fourth insert will end up copying too many bytes in the i_block[]
array, since path->left is one larger than it should be.  This results
in the inode fields i_generation, i_file_acl, and i_size_high getting
zeroed out.

This problem can be replicated as follows:

% cp /dev/null /tmp/foo.img
% mke2fs -F -t ext4 /tmp/foo.img 100
% debugfs -w /tmp/foo.img
debugfs: write /dev/null foo
debugfs: set_inode_field foo i_size_hi 1
debugfs: stat foo
 <----- note that the inode's size is 4294967296
debugfs: extent_open foo
debugfs (extent ino 12): insert --after 0 1 100
debugfs (extent ino 12): insert --after 1 1 101
debugfs (extent ino 12): insert --after 2 1 102
debugfs (extent ino 12): insert --after 3 1 103
debugfs (extent ino 12): extent_close
debugfs: stat foo
 <----- note that the inode's size is now 0
debugfs: quit

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: add ext2fs_find_first_set_{block,inode}_bitmap2()
Theodore Ts'o [Sun, 12 Jan 2014 20:57:31 +0000 (15:57 -0500)]
libext2fs: add ext2fs_find_first_set_{block,inode}_bitmap2()

Add functions which try to find the first set block or inode in a
bitmap.  This is useful when trying to allocate a range of blocks
efficiently.

Like the find_first_zero family of functions, provide a generic O(N)
search function which will be used if there is no optimized version
provided by the red-black tree or bitarray functions.

Also, expand the test cases for ext2fs_find_first_zero_*() functions.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoext4.5: remove duplicate .TP in man page
Theodore Ts'o [Sun, 12 Jan 2014 03:07:24 +0000 (22:07 -0500)]
ext4.5: remove duplicate .TP in man page

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
10 years agotests: adjust test output to reflect block_uninit calculated block bitmaps
Darrick J. Wong [Sat, 11 Jan 2014 19:15:52 +0000 (14:15 -0500)]
tests: adjust test output to reflect block_uninit calculated block bitmaps

Now that libext2fs marks group metadata in the fs block bitmap, adjust
the expected test output to reflect expanded use of block_uninit and
the fact debugfs no longer prints block bitmap data that fails to
account for group data blocks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agolibext2fs: no need to clear BLOCK_UNINIT during ext2fs_reserve_super_and_bgd
Darrick J. Wong [Sat, 11 Jan 2014 19:15:51 +0000 (14:15 -0500)]
libext2fs: no need to clear BLOCK_UNINIT during ext2fs_reserve_super_and_bgd

Since the beginning of the uninit_bg feature, the kernel[1] and
e2fsck[2] have always been careful to detect the presence of the
BLOCK_UNINIT flag, and compute a block bitmap with any group metadata
blocks marked in that bitmap.  With that in mind, I think it's safe to
say that this is a design feature of uninit_bg.

Now that we've trained libext2fs to have this same behavior whenever
it's loading a block bitmap, we no longer need to unset BLOCK_UNINIT
for a group that contains only its own group metadata -- kernel,
e2fsck, and e2fsprogs will handle this correctly.

[1] kernel git 717d50e4971b81b96c0199c91cdf0039a8cb181a
    "Ext4: Uninitialized Block Groups"
[2] e2fsprogs git f5fa20078bfc05b554294fe9c5505375d7913e8c
    "Add support for EXT2_FEATURE_COMPAT_LAZY_BG"

Reported-by: Akira Fujita <a-fujita@rs.jp.nec.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agoe2fsck: remove uninit block bitmap calculation
Darrick J. Wong [Sat, 11 Jan 2014 19:05:02 +0000 (14:05 -0500)]
e2fsck: remove uninit block bitmap calculation

Since libext2fs now detects a BLOCK_UNINIT group and calculates the
group's block bitmap, we no longer need to emulate this behavior in
e2fsck.  We can simply compare the found block map against the
filesystem's, and proceed from there.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agolibext2fs: mark group data blocks when loading block bitmap
Darrick J. Wong [Sat, 11 Jan 2014 19:04:48 +0000 (14:04 -0500)]
libext2fs: mark group data blocks when loading block bitmap

The kernel[1] and e2fsck[2] both react to a BLOCK_UNINIT group by
calculating the block bitmap that's needed to show all the group
blocks for that group (if any) and using that.  However, when reading
bitmaps from disk, libext2fs simply imports a block of zeroes into the
bitmap, without bothering to check for group blocks.  This erroneous
behavior results in the filesystem having a block bitmap that does not
accurately reflect disk contents, and worse yet makes it seem as
though superblocks, group descriptors, bitmaps, and inode tables are
"free" space on disk.

So, fix the block bitmap loading routines to calculate the correct
block bitmap for all groups and load it into the main fs block bitmap.

This also fixes bogus debugfs output such as:

Group 1: (Blocks 8193-16384) [INODE_UNINIT, BLOCK_UNINIT]
  Checksum 0x1310, unused inodes 512
  Backup superblock at 8193, Group descriptors at 8194-8217
  Reserved GDT blocks at 8218-8473
  Block bitmap at 283 (bg #0 + 282), Inode bitmap at 299 (bg #0 + 298)
  Inode table at 442-569 (bg #0 + 441)
  7911 free blocks, 512 free inodes, 0 directories, 512 unused inodes
  Free blocks: 8193-16384
  Free inodes: 513-1024

Notice how the "free blocks" range includes the backup sb & GDT area
and doesn't match the free block count.

Worse yet, debugfs' testb command will report those group descriptor
blocks as not being in use unless the user also instructs debugfs to
find a free block first.  That is a rather surprising result:

debugfs:  testb 8194
Block 8194 not in use
debugfs:  ffb 1 16380
Free blocks found: 16380
debugfs:  testb 8194
Block 8194 marked in use

Also, remove the part of check_block_uninit() that "fixes" the bitmap
since we're doing that at bitmap load time now.

[1] kernel git 717d50e4971b81b96c0199c91cdf0039a8cb181a
    "Ext4: Uninitialized Block Groups"
[2] e2fsprogs git f5fa20078bfc05b554294fe9c5505375d7913e8c
    "Add support for EXT2_FEATURE_COMPAT_LAZY_BG"

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agolibext2fs: don't always read backup group descriptors on a 1k-block meta_bg fs
Darrick J. Wong [Sat, 11 Jan 2014 18:58:15 +0000 (13:58 -0500)]
libext2fs: don't always read backup group descriptors on a 1k-block meta_bg fs

On a filesystem with 1K blocks and meta_bg enabled, opening a
filesystem with automatic superblock detection tries to compensate for
the fact that the superblock lives in block 1.  However, the method by
which this is done is later misinterpreted to mean "read the backup
group descriptors", which is not what we want in this case.

Therefore, in ext2fs_open3() separate the 'group zero' adjustment into
its own variable so that we don't get fed backup group descriptors
when we try to load meta_bg group descriptors.

Furthermore, enhance ext2fs_descriptor_block_loc2() to perform its own
group zero correction.  The other caller of this function neglects to
do any group-zero correction of their own, so this fixes them too.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agolibext2fs: detect correct superblock adjustments when loading backup groups
Darrick J. Wong [Sat, 11 Jan 2014 18:54:57 +0000 (13:54 -0500)]
libext2fs: detect correct superblock adjustments when loading backup groups

If ext2fs_descriptor_block_loc2() is called with a meta_bg filesystem
and group_block is not the normal value, the function will return the
location of the backup group descriptor block in the next block group.
Unfortunately, it fails to account for the possibility that the backup
group contains a backup superblock but the regular superblock does
not.  This is the case with block groups 48-49 on a meta_bg fs with 1k
blocks; in this case, libext2fs will fail to open the filesystem.

Therefore, teach the function to adjust for superblocks in the backup
group, if necessary.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agoblkid: fix blkid -o list formatting with columns > 160
Theodore Ts'o [Sat, 11 Jan 2014 04:25:54 +0000 (23:25 -0500)]
blkid: fix blkid -o list formatting with columns > 160

This bug is also in the util-linux version of blkid.

Addresses-Coverity-Id: #1049158

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibblkid: add error checking for rename() while saving the blkid cache
Theodore Ts'o [Sat, 11 Jan 2014 03:09:45 +0000 (22:09 -0500)]
libblkid: add error checking for rename() while saving the blkid cache

Addresses-Coverity-Id: #1049141

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibblkid: fix integer width issue in probe_fat
Theodore Ts'o [Sat, 11 Jan 2014 02:56:29 +0000 (21:56 -0500)]
libblkid: fix integer width issue in probe_fat

Addresses-Coverity-Id: #1049162

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibblkid: remove unneeded pointer checks
Theodore Ts'o [Sat, 11 Jan 2014 02:53:08 +0000 (21:53 -0500)]
libblkid: remove unneeded pointer checks

Addresses-Coverity-Id: #207522
Addresses-Coverity-Id: #207523

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoblkid: fix gcc -Wall nits
Theodore Ts'o [Sat, 11 Jan 2014 02:40:28 +0000 (21:40 -0500)]
blkid: fix gcc -Wall nits

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs, tune2fs: remove unneeded access() call
Theodore Ts'o [Sat, 11 Jan 2014 02:39:27 +0000 (21:39 -0500)]
mke2fs, tune2fs: remove unneeded access() call

Addresses-Coverity-Id: #709536
Addresses-Coverity-Id: #709535

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibss: fix potential null dereference if realloc() fails
Theodore Ts'o [Sat, 11 Jan 2014 02:13:15 +0000 (21:13 -0500)]
libss: fix potential null dereference if realloc() fails

Addresses-Coverity-Id: #1153630

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibuuid: add error checking to syscalls in get_clock()
Theodore Ts'o [Sat, 11 Jan 2014 02:06:07 +0000 (21:06 -0500)]
libuuid: add error checking to syscalls in get_clock()

Also remove redundant close() of state_fd, since the fclose() of
state_f will result in the fd being closed.

Addresses-Coverity-Id: #1049146
Addresses-Coverity-Id: #26092

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoutil: fix make dependencies for subst
Theodore Ts'o [Thu, 9 Jan 2014 20:59:29 +0000 (15:59 -0500)]
util: fix make dependencies for subst

Now that subst is using config.h, we need to fix its dependencies so
that if config.h is missing (i.e., after a "make clean" in the tree)
that it is rebuilt by the Makefile rule.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoSave and restore umask around calls to mkstemp()
Theodore Ts'o [Thu, 9 Jan 2014 20:18:44 +0000 (15:18 -0500)]
Save and restore umask around calls to mkstemp()

The races would be hard to exploit, but let's close them off.

Addresses-Coverity-Id: #709504
Addresses-Coverity-Id: #709505
Addresses-Coverity-Id: #709506

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibuuid: check return value of uuid_parse() in test
Theodore Ts'o [Thu, 9 Jan 2014 20:06:50 +0000 (15:06 -0500)]
libuuid: check return value of uuid_parse() in test

Addresses-Coverity-Id: #709477

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoblkid: add fallthrough comment
Theodore Ts'o [Thu, 9 Jan 2014 20:03:40 +0000 (15:03 -0500)]
blkid: add fallthrough comment

Addresses-Coverity-Id: #709484

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibblkid: clean up some integer promotion / signed issues
Theodore Ts'o [Thu, 9 Jan 2014 19:56:54 +0000 (14:56 -0500)]
libblkid: clean up some integer promotion / signed issues

Addresses-Coverity-Id: #1049165
Addresses-Coverity-Id: #1049164
Addresses-Coverity-Id: #1049163
Addresses-Coverity-Id: #1049162
Addresses-Coverity-Id: #709508
Addresses-Coverity-Id: #709507

10 years agodebugfs: fix typo in commit 5a1d25a7b
Theodore Ts'o [Thu, 9 Jan 2014 19:30:43 +0000 (14:30 -0500)]
debugfs: fix typo in commit 5a1d25a7b

The typo causes a compiler warning, but it's otherwise harmless.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoFix up workarounds for dietlibc breakage
Theodore Ts'o [Thu, 9 Jan 2014 03:25:04 +0000 (22:25 -0500)]
Fix up workarounds for dietlibc breakage

The dietlibc doesn't support the TZ environment variable, which is
required by the standard.  Work around this so that we can run the
regression test suite when building with dietlibc.  (This is useful
for finding problems.)

With this change, the only thing which doesn't work as far as dietlibc
is concerned is the posix_memalign test, and the MMP support tests
(because posix_memalign isn't provided by dietlibc, sigh.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibss: fix memory leak if realloc() fails in ss_parse()
Theodore Ts'o [Tue, 7 Jan 2014 14:36:49 +0000 (09:36 -0500)]
libss: fix memory leak if realloc() fails in ss_parse()

Addresses-Coverity-Id: #709491

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agobadblocks: print warning if set_o_direct() fails
Theodore Ts'o [Tue, 7 Jan 2014 14:18:19 +0000 (09:18 -0500)]
badblocks: print warning if set_o_direct() fails

Addresses-Coverity-Id: #1049148

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agodebugfs: remove dead code
Theodore Ts'o [Tue, 7 Jan 2014 14:08:05 +0000 (09:08 -0500)]
debugfs: remove dead code

Addresses-Coverity-Id: #1138573

Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: fix memory leaks on error paths in ext2fs_create_icount_tdb
Theodore Ts'o [Tue, 7 Jan 2014 14:05:03 +0000 (09:05 -0500)]
libext2fs: fix memory leaks on error paths in ext2fs_create_icount_tdb

Addresses-Coverity-Id: #1138575

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibquota: add error checking to quota_remove_inode
Theodore Ts'o [Tue, 7 Jan 2014 06:00:49 +0000 (01:00 -0500)]
libquota: add error checking to quota_remove_inode

Addresses-Coverity-Id: #709475

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibquota: add error checking to quota_write_inode()
Theodore Ts'o [Tue, 7 Jan 2014 05:55:02 +0000 (00:55 -0500)]
libquota: add error checking to quota_write_inode()

Addresses-Coverity-Id: #709476

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: remove redundant code in rb_print_stats()
Theodore Ts'o [Tue, 7 Jan 2014 05:50:05 +0000 (00:50 -0500)]
libext2fs: remove redundant code in rb_print_stats()

Addresses-Coverity-Id: #709550

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe2fsck: fix memory leak on error path in read_bad_blocks_files()
Theodore Ts'o [Tue, 7 Jan 2014 05:47:40 +0000 (00:47 -0500)]
e2fsck: fix memory leak on error path in read_bad_blocks_files()

Addresses-Coverity-Id: #1049170

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: make ext2fs_group_desc_csum return 0 if meta_csum not enabled
Theodore Ts'o [Tue, 7 Jan 2014 05:41:50 +0000 (00:41 -0500)]
libext2fs: make ext2fs_group_desc_csum return 0 if meta_csum not enabled

Addresses-Coverity-Id: #1147784

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe2fsck: release allocated memory on error or abort in e2fsck_pass1()
Theodore Ts'o [Tue, 7 Jan 2014 05:39:19 +0000 (00:39 -0500)]
e2fsck: release allocated memory on error or abort in e2fsck_pass1()

Addresses-Coverity-Id: #1148450

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibss: fix potential memory leak on realloc() failure
Theodore Ts'o [Tue, 7 Jan 2014 03:20:38 +0000 (22:20 -0500)]
libss: fix potential memory leak on realloc() failure

Commit 191a03ac5f was an incorrect fix for this issue.  Fix it up.

Addresses-Coverity-ID: #295143
Addresses-Coverity-ID: #1148451

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe2fsck: add error checking when moving the quota inode
Theodore Ts'o [Mon, 6 Jan 2014 01:31:18 +0000 (20:31 -0500)]
e2fsck: add error checking when moving the quota inode

Addresses-Coverity-Bug: #1049140

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibblkid: fix memory overrun in probe_lvm2
Theodore Ts'o [Sun, 5 Jan 2014 06:12:49 +0000 (01:12 -0500)]
libblkid: fix memory overrun in probe_lvm2

Addresses-Coverity-ID: #1049167

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agotest_extents: fix a possible memory leak
Theodore Ts'o [Sun, 5 Jan 2014 06:12:49 +0000 (01:12 -0500)]
test_extents: fix a possible memory leak

Addresses-Coverity-Bug: #1049185

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: fix potential memory leak in qcow2_write_raw_image()
Theodore Ts'o [Sun, 5 Jan 2014 06:12:49 +0000 (01:12 -0500)]
libext2fs: fix potential memory leak in qcow2_write_raw_image()

Addresses-Coverity-ID: #1049179
Addresses-Coverity-ID: #1049180

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibss: fix potential memory leak on realloc() failure
Theodore Ts'o [Sun, 5 Jan 2014 06:12:48 +0000 (01:12 -0500)]
libss: fix potential memory leak on realloc() failure

Addresses-Coverity-ID: #295143

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agodebian: renable use of internal uuid and blkid libraries for e2fsck.static
Theodore Ts'o [Sun, 5 Jan 2014 06:09:07 +0000 (01:09 -0500)]
debian: renable use of internal uuid and blkid libraries for e2fsck.static

Now that the diet libc support is working again, we need to use the
internal uuid and blkid library in order for e2fsck.static to be
compiled properly.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoUse consistent e2fsprogs-standard types
Theodore Ts'o [Sun, 5 Jan 2014 05:15:54 +0000 (00:15 -0500)]
Use consistent e2fsprogs-standard types

Some different types such as u_int16_t and __uint32_t have snuck into
e2fsprogs.  These types are not guaranteed by any standard, and they
are not provided by dietlibc.  Convert them to __u16, __u32,
etc. since these are guaranteed to be provided by e2fsprogs' build.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoconfigure: fix --with-diet-libc
Theodore Ts'o [Sun, 5 Jan 2014 01:44:29 +0000 (20:44 -0500)]
configure: fix --with-diet-libc

Newer versions of autoconf pull in AC_PROG_GCC as part of
AC_CANONICAL_HOST.  So we need check for WITH_DIET_LIBC earlier in
configure.in.

Also, e2fsprogs now needs functions which are found in diet libc's
compat library.  So add support for autoconf's LIBS function, and
automatically set libs to include -lcompat.

Finally, disable compiling e4defrag by deault if --with-diet-libc is
specified because the program has too many glibc dependencies.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe4defrag: choose the best available posix_fadvise variant
Baruch Siach [Thu, 2 Jan 2014 18:05:37 +0000 (13:05 -0500)]
e4defrag: choose the best available posix_fadvise variant

Use posix_fadvise64() when available.  This allows 64bit offsets on
32bit systems.

[ Modified by tytso to try to use fadvise64() as well, and to remove
  the attempt to call the syscall directly, since because and
  complexities caused by required dummy arguments on some
  architectures, it's not worth the hair.  ]

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agoe2fsck: fix possible double free when searching for config file
Theodore Ts'o [Fri, 3 Jan 2014 14:51:44 +0000 (09:51 -0500)]
e2fsck: fix possible double free when searching for config file

This happens if there is an error while scanning a directory for
config file fragments.  This is rarely used, which is why we didn't
notice this.

Addresses-Coverity-Bug: #1138576

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agodebugfs: clean up read_journal_block() to avoid Coverity complaint
Theodore Ts'o [Fri, 3 Jan 2014 14:39:33 +0000 (09:39 -0500)]
debugfs: clean up read_journal_block() to avoid Coverity complaint

The read_journal_block() function was needlessly complicated, which
made it harder to read/maintain, and it also tripped up Coverity.
Cleaning it up also avoided some signed/unsigned casts, and allows us
to avoid passing got back to the caller, since it wasn't needed.

Addresses-Coverity-Bug: #709539

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agosubst: clean up various coverity nits
Theodore Ts'o [Fri, 3 Jan 2014 05:26:43 +0000 (00:26 -0500)]
subst: clean up various coverity nits

Add appropriate error checking for all error returns, and only open
each file that we need to manipulate once, to avoid potential
time-of-check/time-of-use races.  (Not that this is likely for this
program, but the result is much more clean.)

We also preserve the atime in the case where the file has not changed.

Addresses-Coverty-Id: #709537
Addresses-Coverty-Id: #1049150
Addresses-Coverty-Id: #1049151

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibblkid: fix sizeof(foo) vs sizeof(*foo) malloc() bug
Theodore Ts'o [Fri, 3 Jan 2014 02:54:03 +0000 (21:54 -0500)]
libblkid: fix sizeof(foo) vs sizeof(*foo) malloc() bug

Addresses-Coverity-Bug: #709510

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
10 years agoe2image: avoid potential divide by zero
Theodore Ts'o [Fri, 3 Jan 2014 02:15:20 +0000 (21:15 -0500)]
e2image: avoid potential divide by zero

It's highly unlikely after five seconds that zero blocks would have
been written, but let's silence the Coverity warning.

Addresses-Coverity-ID: 1147780

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
10 years agoe2image: eliminate division by zero
Theodore Ts'o [Fri, 3 Jan 2014 02:04:01 +0000 (21:04 -0500)]
e2image: eliminate division by zero

Dividing a floating point number by zero is undefined in C.  It
happens to work with gcc/glibc, but it's not something that's
guaranteed.

Addresses-Coverity-ID: #1147781

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
10 years agoe2image: fix resource leak when running e2image -n
Theodore Ts'o [Fri, 3 Jan 2014 01:18:20 +0000 (20:18 -0500)]
e2image: fix resource leak when running e2image -n

Addresses-Coverity-ID: #1147783

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
10 years agoe2image: mark strings for internationalization
jon ernst [Tue, 31 Dec 2013 06:50:31 +0000 (01:50 -0500)]
e2image: mark strings for internationalization

Signed-off-by: Jon Ernst <jonernst07@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agoe2fsck.conf: clarify man page's description of accept_time_fudge
Theodore Ts'o [Wed, 1 Jan 2014 04:18:44 +0000 (23:18 -0500)]
e2fsck.conf: clarify man page's description of accept_time_fudge

Addresses-Debian-Bug: #719189

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe2fsck: improve the "superblock corrupt" message
Theodore Ts'o [Wed, 1 Jan 2014 04:02:44 +0000 (23:02 -0500)]
e2fsck: improve the "superblock corrupt" message

Previously, this message used 8193 as the example alternate
superblock.  But for most file systems, the backup superblock is
located at 32768 (since most file systems have a block size of 4k, and
not 1k).

Addresses-Debian-Bug: #719185

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs: use [^]feature instead of just feature in the man page
Theodore Ts'o [Wed, 1 Jan 2014 03:53:52 +0000 (22:53 -0500)]
mke2fs: use [^]feature instead of just feature in the man page

Addresses-Debian-Bug: #719184

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agodebian: add mention of the badblocks program in the package description
Theodore Ts'o [Wed, 1 Jan 2014 03:34:52 +0000 (22:34 -0500)]
debian: add mention of the badblocks program in the package description

Addresses-Debian-Bug: #718725

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>