Commit Graph

112 Commits (fd80e987d7a62a4aee7a9a4fb167f707b312e9fa)

Author SHA1 Message Date
Darrick J. Wong 7dd0dfca04 e2image: ignore checksum errors
Since e2image is used to capture broken fs images for debugging,
ignore checksum errors when creating the image.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-04-25 11:03:09 -04:00
Theodore Ts'o 4ea40c0bc2 Merge branch 'maint' into next 2016-04-15 11:33:30 -04:00
Eric Sandeen be5ce27525 e2image: don't leak progress info to stdout
Commit c8ee0d60 fixed most of these, but missed this one.

# e2image -r -p <device> - > imagefile

leads to a corrupted image due to the "Scanning inodes..."
printf going to stdout.

Reported-by: Alex Markley <alex@malexmedia.net>
Addresses-Red-Hat-Bugzilla: #1327329
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-04-15 10:59:02 -04:00
Theodore Ts'o f1644c324b Eliminate doubly defined _LARGEFILE_SOURCE warning
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-07-12 22:54:37 -04:00
Theodore Ts'o 99ceb8ec1a Move the check_plausibility() function from misc to lib/support
The check_plausibility() function is now used all over the place, so
we should move the plausible.c file to lib/support and remove the
special case handling for that file that had been in the build system.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-07-12 22:01:17 -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
Theodore Ts'o 7f7d1cb462 Merge branch 'maint' into next
Conflicts:
	debugfs/set_fields.c
	tests/f_mmp/script
	tests/f_mmp_garbage/script
	tests/m_mmp/script
	tests/t_mmp_1on/script
	tests/t_mmp_2off/script
2014-07-06 00:09:27 -04:00
Lukas Czerner 47fee2ef6a e2fsprogs: introduce ext2fs_close_free() helper
Currently there are many uses of ext2fs_close() which might be wrong.
First of all ext2fs_close() does not set the ext2_filsys pointer to NULL
so the caller is responsible for clearing it, however there are some
cases there we do not do it.

Second of all very small number of users of ext2fs_close() actually
check the return value. If there is a problem in ext2fs_close() it will
not even free the ext2_filsys structure, but majority of users expect it
to do so.

To fix both problems this commit introduces a new helper
ext2fs_close_free() which will not only check for the return value and
free the ext2_filsys structure if the call to ext2fs_close2() failed,
but it will also set the ext2_filsys pointer to NULL.

Replace every use of ext2fs_close() in e2fsprogs tools with
ext2fs_close_free() - there is no real reason to keep using
ext2fs_close().

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
2014-07-05 21:06:48 -04:00
Theodore Ts'o dc084ab7b1 Merge branch 'maint' into next 2014-02-20 21:39:29 -05:00
Andreas Dilger 4d46e6c737 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 11d1116a7c.  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>
2014-02-18 12:17:53 -05:00
Theodore Ts'o d2dce124dd Merge branch 'maint' into next
Conflicts:
	debian/changelog
	e2fsck/Makefile.in
2014-01-06 06:58:58 -05:00
Theodore Ts'o fa24c8faa1 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>
2014-01-04 19:11:37 -05:00
Theodore Ts'o 781c0df508 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>
2014-01-04 19:11:37 -05:00
Theodore Ts'o e9b5923544 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>
2014-01-04 19:11:37 -05:00
jon ernst e38bfbe912 e2image: mark strings for internationalization
Signed-off-by: Jon Ernst <jonernst07@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-01-04 19:11:36 -05:00
Theodore Ts'o d7e6e97871 e2image: fix printf format type match
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-30 16:56:19 -05:00
Theodore Ts'o 9c846766fd Merge branch 'maint' into next
Conflicts:
	RELEASE-NOTES
	debian/changelog
	version.h
2013-12-28 23:27:39 -05:00
Theodore Ts'o c003f48b48 e2image: Clarify e2image's usage message
Also reflect a similar change to e2image's man page.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-27 01:14:09 -05:00
Theodore Ts'o c8ee0d60fd e2image: write progress information to stderr
This allows "e2image -rp /dev/sdc1 - | bzip2 > sdc1.img.bz2" to work
correctly, so the progress information doesn't corrupt the image being
sent to stdout.

Also add a diagnostic indicating that the -p option is currently only
implemented for raw mode.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-27 01:04:32 -05:00
Theodore Ts'o 212c994883 e2image: clean up progress reporting
The old progress reporting code would crash on small file systems.
For example:

    cp /dev/null /tmp/foo.img
    mke2fs -t ext4 -F /tmp/foo.img 100
    e2image -o 0 -O 4096 -rap /tmp/foo.img

Fix this, and while we're at it, factor out the code to make it easier
to read and maintain.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 23:45:17 -05:00
Theodore Ts'o 2ffccc82c4 Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/csum.c
2013-12-26 00:30:56 -05:00
Theodore Ts'o 737a88673d e2image: make sure all strings are marked for internationalization
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 00:21:13 -05:00
Theodore Ts'o 0155e77021 e2image: add -n option to show what blocks would have been written
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 00:21:13 -05:00
Theodore Ts'o 38c771d6dd e2image: add -c option to optimize file system copying for flash devices
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 00:21:13 -05:00
Theodore Ts'o aa2c743331 e2image: only skip writing zero blocks when writing to a new file
The e2image progam was originally intended to create image files.
However, some people have started using e2image to copy a file system
from one block device to another, since it is more efficient than
using dd because it only copies the blocks which are in use.  If we
are doing this, however, we must not skip writing blocks which are all
zero in the source device, since they may not be zero in the
destination device.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Phillip Susi <psusi@ubuntu.com>
2013-12-26 00:21:08 -05:00
Theodore Ts'o d28759b223 e2image: clean up gcc -Wall and sparse nits
Fix up the gcc -Wall and sparse nits introduced by Phillip Susi's
e2image patches.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Phillip Susi <psusi@ubuntu.com>
2013-12-26 00:20:43 -05:00
Theodore Ts'o 80fe25a2d7 e2image: refactor calls to ext2fs_llseek()
Refactor calls to ext2fs_llseek().  This makes the code more compact,
easier to read, and it also fixes a number of places where we call
ext2fs_llseek() without doing proper error checking.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 00:20:43 -05:00
Phillip Susi ecc859b281 e2image: handle SIGINT safely
When doing an in place move, interrupting it past the
point of no return will destroy the filesystem since
parts of it have been overwritten.  Catch SIGINT the
first time and issue a warning if this is the case.

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 00:20:43 -05:00
Phillip Susi c40c7ceffe e2image: add progress indicator
When given the -p switch, print progress information, including
block counts, percentage complete, estimated time remaining, and
throughput.

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 00:20:43 -05:00
Phillip Susi 22b83f6280 e2image: perform in-place move
If given at least one offset and only one file, assume source
and dest are the same, and do an in place move.

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 00:20:40 -05:00
Phillip Susi 6b5535f409 e2image: add offset switches
Add -o and -O switches to specify the offset where the source
and destination filesystems start.  This is useful if you have
an image of a partitioned disk or wish to create one.

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-24 23:34:04 -05:00
Theodore Ts'o f404167dda Clean up sparse warnings
Mostly by adding static and removing excess extern qualifiers.  Also
convert a few remaining non-ANSI function declarations to ANSI.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-16 18:56:36 -05:00
Theodore Ts'o e4681bca17 Merge branch 'maint' into next
Conflicts:
	debugfs/debugfs.8.in
2013-12-16 01:35:56 -05:00
Andreas Dilger 45ff69ffeb build: quiet LLVM non-literal string format warning
Compiling with LLVM generates a large number of warnings due
to the use of _() for wrapping strings for i18n:

    warning: format string is not a string literal
          (potentially insecure) [-Wformat-security]
    ./nls-enable.h:4:14: note: expanded from macro '_'
    #define _(a) (gettext (a))
                 ^~~~~~~~~~~~

These warnings are fixed by using "%s" as the format string,
and then _() is used as the string argument.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-15 22:12:16 -05:00
Darrick J. Wong 22cde0096d misc: use the checksum predicate function, not raw flag tests
metadata_csum implies uninit_bg, and in fact forces the bit off for
rocompat with older implementations.  Therefore, to detect the
presence of checksums, we should use the predicate function to decide
if group descriptor checksums are turned on, not open-coded flag
tests.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-12 23:33:48 -05:00
Darrick J. Wong b399382586 e2image: check return value from check_if_mounted()
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-12 13:09:29 -05:00
Darrick J. Wong e39082e2e8 misc: don't leak file descriptors (on error paths)
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-12 13:05:52 -05:00
Theodore Ts'o 4c2ae57d38 e2image: pass the correct size write_header
Commit bf0449b1a6, which added the ability to write qcow2 files,
generalized the write_header() file to take the size of the header
structure which it writes out.  Unfortunately, it changed the call
which supported original e2image format to pass in fs->blocksize,
instead of the actual size of the e2image header structure (which is
substantially smaller than fs->blocksize).  This meant that we copied
in stack garbage into the e2image file, and it made valgrind quite
unhappy.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-02 13:14:43 -05:00
Carlos Maiolino 6c327e9ca4 e2image: complain if running e2image -r or -Q on a mounted filesystem
Several users have used e2image on a mounted RW filesystem, resulting in
inconsistent, useless e2images for debugging purposes.

This commit will forbid this and print an error message, although the
user can override this using a new force option.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-10-11 21:49:16 -04:00
Theodore Ts'o e7f983bfb2 e2image: fix crash when using e2image -I with a 64-bit file system
Addresses-Debian-Bug: #703067

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-06-15 20:52:08 -04:00
Theodore Ts'o 577c773a60 misc: fix gcc -Wall warnings
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-05-19 20:03:48 -04:00
Tomas Racek fdaf34f8c0 e2image: require that -a option is used only with raw or QCOW2 image
All data cannot be included in normal image file so e2image should exit
in this case.

Signed-off-by: Tomas Racek <tracek@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
2013-04-21 23:21:46 -04:00
Tomas Racek d55e68a660 e2image: remove useless exit call
Exit is called right after the install_image anyway so this one can
be removed.

Signed-off-by: Tomas Racek <tracek@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-04-21 23:21:32 -04:00
Phillip Susi 0e51f5ae16 e2image: add -a switch to include all data
Normally the raw and QCOW2 images only contain fs metadata.
Add a new switch ( -a ) to include all data.  This makes it
possible to use e2image to clone a whole filesystem.

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-16 14:09:20 -05:00
Andreas Dilger 2d2abcc646 e2fsck: rename "bool" variables
Since "bool" is a valid C type, declarations of the form "int bool"
will cause compiler errors if <stdbool.h> is included.  Rename these
variables to avoid this name clash.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-07-14 19:43:20 -04:00
Theodore Ts'o e64e6761aa Fix gcc -Wall nitpicks
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-04-05 12:13:05 -07:00
Phillip Susi 6c9ce8a9b0 e2image: skip uninitialized bitmaps and inode tables
When the block bitmap is uninitialized, skip copying it.
When the inode bitmap is uninitialized, skip copying it,
as well as the inode table.  When there are unused inodes
towards the end of the table, skip those blocks too.

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-27 00:56:49 -05:00
Theodore Ts'o 50a676e944 e2image: attempt to use ftruncate64 to set i_size for raw images
If ftruncate64() exists, try to use it to set i_size.  This isn't
guaranteed to work, per SuSv3, but if it doesn't work, it's guaranteed
to return an error.  So for file systems and/or operating systems that
don't support extending i_size via ftruncate64(), fall back to writing
the trailing null.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-17 15:28:21 -05:00
Theodore Ts'o 2b7a30cc52 e2image: fix logic bug which could cause a raw image not to be extended
If the size of the last "hole" in the raw file was an exact multiple
of a megabyte, then we wouldn't write a null at the end of the file in
order to extend the size of the raw image to correspond with the file
system size.  Thanks to Lukas Czerner for suggesting the fix, and
Phillip Susi for pointing out the problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-17 15:28:20 -05:00
Theodore Ts'o 0c80c44bd0 libext2fs: ext2fs_[set_]file_acl_block needs to check for 64-bit feature flag
The ext2fs_file_acl_block() and ext2fs_set_file_acl_block() needs to
only check i_file_acl_high if the 64-bit flag is set.  This is needed
because otherwise we will run into problems on Hurd systems which
actually use that field for h_i_mode_high.

This involves an ABI change since we need to pass ext2_filsys to these
functions.  Fortunately these functions were first included in the
1.42-WIP series, so it's OK for us to change them now.  (This is why
we have 1.42-WIP releases.  :-)

Addresses-Sourceforge-Bug: #3379227

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-16 20:46:49 -04:00