Commit Graph

5062 Commits (63a801dec75d9a7f9ec2973d6f59ac864d22d8bd)

Author SHA1 Message Date
Darrick J. Wong 63a801dec7 tests: fix test scripts that don't work on non-Linux systems.
Fix various tests that break on non-Linux systems; in particular,
sed -i doesn't work the same on all platforms; and try to keep the
GNU getopt-isms out.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-07 20:53:39 -05:00
Darrick J. Wong 210baa5d8a mke2fs: warn if enabling metadata_csum on a pre-3.18 kernel
The metadata_csum feature (really, the journal checksum disk format)
didn't stabilize until the 3.18 kernel, at which point the companion
journal_csum feature was turned on by default if metadata_csum was
enabled.  Therefore, warn the user if they try to create such a
filesystem on a pre-3.18 kernel.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-05 11:16:57 -05:00
Theodore Ts'o 11ca1e9294 Merge branch 'maint' into next 2014-11-05 11:15:06 -05:00
Darrick J. Wong beec19ff21 e2fsck: fix dangling pointer when dir_info array is resized
e2fsck uses an array to store directory usage information during pass
3; the usage context also contains a pointer to the last directory
looked up.  When expanding the dir_info array, this cache pointer
needs to be cleared if the array resize changed the pointer location,
or else we'll later walk off the end of this dead pointer.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-05 11:14:26 -05:00
Darrick J. Wong ea9085c711 e2fsck: fix reporting of unknown htree block inode number
Sami Liedes reports that e2fsck fails to report the correct directory
inode number during a pass2 check for unexpected HTREE blocks.
Provide the inode number in the problem report.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-05 11:10:31 -05:00
Darrick J. Wong 12406b37b2 libext2fs: fix endian checking bits
Commit 3e683eef93 ("define bitwise types and annotate conversion
routines") broke the build on various platforms.  Turns out that
crossing our fingers wasn't such a good idea, so just define it
separately.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-05 11:08:32 -05:00
Darrick J. Wong a4b528692e tune2fs: don't change metadata_csum on a mounted fs
Don't let users change metadata_csum on a mounted filesystem because
there's no way to tell the kernel to turn on the feature; there's no
way to prevent the kernel from rewriting on-disk structures while
tune2fs is also rewriting them; and there's no way to tell the kernel
to reload them after tune2fs is finished.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-04 11:52:26 -05:00
Darrick J. Wong 8302e2e688 tune2fs: speed up rewriting extent tree when enabling metadata_csum
When enabling checksums, tune2fs naively rewrites every extent in the
entire tree!  This is unnecessary since we only need to rewrite each
extent tree block; therefore, only rewrite the extent if it's the
first one in an internal extent tree block.

Also, don't bother iterating the extent tree when clearing checksums.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-04 11:52:03 -05:00
Darrick J. Wong e49b03e341 misc: fix broken libmagic interaction with plausibility check
If we get as far as calling libmagic, return the correct error code so
that mkfs asks for confirmation if libmagic finds something and
doesn't ask if nothing is found.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-04 11:49:39 -05:00
Darrick J. Wong bab25cb7a7 libext2fs: zero the EA block buffer before filling it
When writing an extended attribute (EA) block, it's quite possible
that the EA formatting code will not write the entire buffer.
Therefore, we must zero the buffer beforehand to avoid writing random
heap contents to disk.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-04 11:47:30 -05:00
Theodore Ts'o dfa667dab6 Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/dir_iterate.c
2014-11-04 11:46:55 -05:00
Darrick J. Wong 8d5324c43f libext2fs: don't memcpy identical pointers when writing a cache block
Sami Liedes found a scenario where we could memcpy incorrectly:

If a block read fails during an e2fsck run, the UNIX IO manager will
call the io->read_error routine with a pointer to the internal block
cache.  The e2fsck read error handler immediately tries to write the
buffer back out to disk(!), at which point the block write code will
try to copy the buffer contents back into the block cache.  Normally
this is fine, but not when the write buffer is the cache itself!

So, plumb in a trivial check for this condition.  A more thorough
solution would pass a duplicated buffer to the IO error handlers, but
I don't know if that happens frequently enough to be worth the extra
point of failure.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-04 11:43:08 -05:00
Darrick J. Wong dab7435917 libext2fs: directory iteration mustn't walk off the buffer end
When we're iterating a directory, the loop control code reads the
length of the next directory record, failing to account for the fact
that there must be at least 8 bytes (the minimum size of a directory
entry) left in the buffer to read the next directory record.  Fix the
loop conditional so that we don't read off the end of the buffer.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-04 11:39:51 -05:00
Darrick J. Wong be2ad9ed2c e2fuzz: exercise fuzzed blocks more aggressively
Exercise fuzzed metadata blocks more aggressively by expanding up to
50000 files (instead of just test.1, which might not hit anything).
Fix a typo while we're at it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-04 11:36:28 -05:00
Darrick J. Wong b9b768687f e2fsck: fix compiler warnings
Fix some gcc-4.8 warnings.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-04 11:35:56 -05:00
Eric Sandeen a7db275f31 quotaio: annotate & fix up for sparse endian checker
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-04 11:26:24 -05:00
Eric Sandeen 8f358e58fe libext2: minor sparse endian checker fixup
The sparse checker treats 0 assignments as special, but
doesn't catch a = b = 0; separate them to make it quieter.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-04 11:26:23 -05:00
Eric Sandeen 77b493e35b debugfs: don't swap htree nodes in-place
htree_dump_int_node() was swapping htree nodes in-place,
something not done elsewhere, so it made the sparse checker
unhappy.  Just use dedicated variables to hold the 2 needed
(endian-swapped) values.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-04 11:26:21 -05:00
Eric Sandeen 1224c0d3ea endian-annotate most on-disk structures
This annotates most on-disk structures for endianness;
however it does not annotate some, like the superblock, inodes,
mmp, etc, as these are swapped in-place at this point.  This is
a little inconsistent, but should help catch some endian mistakes,
at least.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-04 11:24:56 -05:00
Eric Sandeen 387e03160c libext2fs: fix endian handling of ext3_extent_header in inline_data
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
2014-11-04 11:24:50 -05:00
Eric Sandeen 3e683eef93 define bitwise types and annotate conversion routines
This lays the groundwork for sparse-checking e2fsprogs for
endianness; defines bitwise types, and fixes up the ext2fs_*
swapping routines to do the proper casts.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-04 11:24:44 -05:00
Theodore Ts'o 8b779489ea Merge branch 'maint' into next
Conflicts:
	configure
2014-11-04 11:20:09 -05:00
Eric Sandeen 160f131dee libext2fs: fix endian handling of ext3_extent_header
This turned up when trying to resize a filesystem containing
a file with many extents on PPC64.

Fix all locations where ext3_extent_header members aren't
handled in an endian-safe manner.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
2014-11-04 11:12:45 -05:00
Theodore Ts'o 441eb337a8 util: allow subst to build on systems that do not have utimes()
Make subst more portable so it can deal with such oler systems that do
not have utimes().  Note that it is important that subst build
correctly without an autoconf-generated config.h (since that is what
happens on a cross-compile), as well as using whatever features are
available as determined by autoconf when doing a native build.  We
currently assume the presence of utime(), but not utimes() or
futimes().

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-10-19 22:13:09 -04:00
Darrick J. Wong 8467b3bec8 contrib: add support for COLLAPSE_RANGE and ZERO_RANGE to falocate program
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-10-18 12:15:03 -04:00
Theodore Ts'o 831aa869e8 debugfs: fix build on systems that don't have gettext built-in
Debugfs (unlike all of the other programs in e2fsprogs) is not set up
to use translated strings.  So when building misc/plausible.c for
debugfs, we need to disable NLS.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-10-18 09:13:09 -04:00
Theodore Ts'o 9ed2c124f3 debugfs: add allocate and set functionality to the bmap command
This also makes it easier test the ext2fs_bmap2() function.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-10-13 11:59:30 -04:00
Darrick J. Wong 08c8e319e3 libext2fs/e2fsck: refactor everyone who writes zero blocks to disk
Convert all call sites that write zero blocks to disk to use
ext2fs_zero_blocks2() since it can use Linux's zero out feature to do
the writes more quickly.  Reclaim the zero buffer at freefs time and
make the write-zeroes fallback use a larger buffer.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-10-13 04:31:17 -04:00
Eric Whitney 0745e78741 mke2fs: fix man page discussion of usage type defaults
The man page description of the file system size thresholds used by
mke2fs to select a usage type when not otherwise specified by the -T
switch does not match the code.

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-10-13 04:19:24 -04:00
Theodore Ts'o 6a0f113535 Merge branch 'maint' into next 2014-10-11 19:26:55 -04:00
Theodore Ts'o deae5e809b resize2fs: fix fs->blocksize dereference after fs has been freed
Commit 77255cf369 introduced a use after free bug.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-10-08 12:09:35 -04:00
Theodore Ts'o ebdf895b43 e2fsck: fix free pointer dereferences
Commit 47fee2ef6a introduces some free pointer dereference bugs by
not clearing ctx->fs after calling ext2fs_close_free().

Reported-by: Matthias Andree <mandree@FreeBSD.org>
Cc: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-10-08 11:18:41 -04:00
Artemiy Volkov d50fd63369 misc: fix build on absence of magic.h
If magic.h is not present, there will be unresolved references to the magic_t
type in plausible.c. Fix that by moving the protecting #ifdef directive.

Signed-off-by: Artemiy Volkov <artemiyv@acm.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-10-04 13:22:52 -04:00
Eric Whitney 5ae83d6593 mke2fs: clarify inline data inode size error message
The existing error message can be made more helpful by more clearly
implying the attempt to make a file system with undersized inodes is
failing and suggesting a corrective action.

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-10-01 08:36:36 -04:00
Theodore Ts'o 3d78d037ec Merge branch 'maint' into next 2014-10-01 08:36:28 -04:00
Eric Sandeen c6889a6430 e2fsprogs: add large_file to base mkfs features
large_file (> 2G) support has been around since at least kernel 2.4;
mkfs of any sufficiently large filesystem sets it "accidentally"
when the resize inode exceeds 2G.  This leaves very small
filesystems lacking the feature, which potentially changes
their behavior & codepaths the first time a > 2G file gets
written.

There's really no reason to be making fresh filesystems which
strive to keep compatibility with 10 year old kernels; just
enable large_file at mkfs time.  This is particularly obvious
for ext4 fielsystems, which set huge_file by default, but not
necessarily large_file.

If old-kernel compatibility is desired, mke2fs.conf can be
modified locally to remove the feature.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-10-01 08:33:54 -04:00
Theodore Ts'o 074931ab76 libext2fs: use ~0UL instead of -1UL to avoid static checker warnings
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-21 15:36:57 -04:00
Theodore Ts'o ed9881bb6c MCONFIG: allow developers to override CFLAGS
Move other C compiler flags to ALL_CFLAGS so that CFLAGS only controls
the debugging and optimization flags.  This allows a developer to
build with "make CFLAGS=-g" in order to compile w/o optimization.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-21 15:35:21 -04:00
Theodore Ts'o d2e3c0dc60 misc: if dlopen() is available, use it to load the libmagic library
This prevents the libmagic library from being a hard dependency; if
it's not there, we can simply do without it.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: Darrick J. Wong <darrick.wong@oracle.com>
2014-09-21 01:25:58 -04:00
Darrick J. Wong b291c11f08 misc: use libmagic when libblkid can't identify something
If we're using check_plausibility() to try to identify something that
obviously isn't an ext* filesystem and libblkid doesn't know what it
is, try libmagic instead.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-20 23:42:19 -04:00
Darrick J. Wong c8b20b40eb misc: add plausibility checks to debugfs/tune2fs/dumpe2fs/e2fsck
If any of these utilities detect a bad superblock magic, call
check_plausibility to see if blkid can identify the passed-in argument
as something else (xfs, partition, etc.) in the hopes of catching a
user error.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-19 23:44:31 -04:00
Darrick J. Wong b598c517b3 misc: move check_plausibility into a separate file
Move check_plausibility() into a separate file so that various
programs can use it without having to declare useless global variables
that the util.c functions seem to require.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-19 13:10:21 -04:00
Darrick J. Wong 0858268dff dumpe2fs: provide a machine-readable group-only mode
Spit out just the group descriptor data in a machine readable format.
This is most useful for testing and scripting purposes.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-19 12:16:44 -04:00
Andreas Dilger ca209dc625 ext2fs: add readahead method to improve scanning
Add a readahead method for prefetching ranges of disk blocks.  This is
useful for inode table scanning, and other large contiguous ranges of
blocks, and may also prove useful for random block prefetch, since it
will allow reordering of the IO without waiting synchronously for the
reads to complete.

It is currently using the posix_fadvise(POSIX_FADV_WILLNEED)
interface, as this proved most efficient during our testing.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-19 12:16:08 -04:00
Darrick J. Wong 53c5d6062e debugfs: manage needs_recover feature when messing with the journal
Set the needs_recover incompat feature when debugfs writes journal
transactions so that we actually replay the journal contents at the
next mount.

Likewise, clear it if we successfully recover the journal.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-19 02:01:43 -04:00
Theodore Ts'o 755a6083d8 e2fsck: use ext2fs_get_mem() instad of ext2fs_get_memalign()
There is no reason to request a aligned buffer in
check_{inode,block}_bitmap, and this will cause failures for dietlibc,
which doesn't have support for posix_memalign() or any other way to
request an aligned memory allocation.  Fortunately, this is only
needed in very few places where direct I/O is required.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-19 01:30:04 -04:00
Theodore Ts'o cc0d983303 Fix build failures due to missing $(SYSLIBS)
Two link lines were missing $(SYSLIBS), which is needed for dietlibc.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-19 01:05:14 -04:00
Theodore Ts'o cbe867f039 e2fsck: fix build under dietlibc
The asm_types.h file needs to include stdio.h and stdlib.h in order to
get integer types included.  So add those includes into jfs_user.h to
avoid a build faliure under dietlibc.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-19 00:48:24 -04:00
Theodore Ts'o 0c49965fb6 create_inode: don't indiscriminately #include "nls-enable.h"
The create_inode.h header file is pulled in by debugfs, which is not
internationalized.  It had no business pulling in nls-enable.h; that
header file should only be used in specific .c files that support
internationalization.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-19 00:46:41 -04:00
Theodore Ts'o a133c81d06 Merge branch 'maint' into next 2014-09-19 00:28:46 -04:00