Commit Graph

24 Commits (master)

Author SHA1 Message Date
Eric Sandeen 32bf36dc0f e2undo: fix endian issues
Two new e2undo issues exist in the latest release on big endian
machines.

From sparse check:

undo_io.c:157:26: warning: invalid assignment: |=
undo_io.c:157:26:    left side has type restricted __le32
undo_io.c:157:26:    right side has type int
undo_io.c:161:26: warning: invalid assignment: &=
undo_io.c:161:26:    left side has type restricted __le32
undo_io.c:161:26:    right side has type int

e2undo.c:211:16: warning: cast to restricted __le64
e2undo.c:211:16: warning: cast from restricted blk64_t
e2undo.c:212:16: warning: cast to restricted __le64
e2undo.c:212:16: warning: cast from restricted blk64_t

Addresses-RedHat-Bugzilla: 1344636
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-06-21 23:10:40 -04:00
Theodore Ts'o 7618802123 e2undo: #include <libgen.h> since we use basename()
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-06-06 16:19:11 -04:00
Theodore Ts'o 377e3a9657 misc: fix gcc -Wall complaints
Especially when compiling for a 32-bit architecture.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-06-02 22:40:41 -04:00
Marcus Huewe 0935fa8da3 e2undo: support the undo header's fs_offset feature
If the fs_offset feature is present (and no "-o offset"
option is specified), e2undo performs the undo operation at
the stored offset.

Signed-off-by: Marcus Huewe <suse-tux@gmx.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-05-12 15:36:39 -04:00
Marcus Huewe 6930537d52 e2undo: add "-o offset" option to specify the filesystem offset
This is useful if the filesystem is located at an arbitrary
offset instead of the beginning of a device or file.

Signed-off-by: Marcus Huewe <suse-tux@gmx.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-05-12 15:36:00 -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 b085139224 misc: fix undo file setup
Fix Coverity bugs 1297094-1297101 by fixing all the mutations in the
*_setup_tdb() functions, fixing buffer overflows, and checking
return values.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-05-16 20:19:52 -04:00
Darrick J. Wong 4892bce3c4 e2undo: ditch tdb file, write everything to a flat file
The existing undo file format (which is based on tdb) has many
problems.  First, its comparison of superblock fields is ineffective,
since the last mount time is only written by the kernel, not the tools
(which means that undo files can be applied out of order, thus
corrupting the filesystem); block numbers are written in CPU byte
order, which will cause silent failures if an undo file is moved from
one type of system to another; using the tdb database costs us an
enormous amount of CPU overhead to maintain the key data structure,
and finally, the tdb database is unable to deal with databases larger
than 2GB.  (Upstream tdb 1.2.12 can handle 4GB, but upgrading a 2TB FS
to 64bit,metadata_csum easily produces 2.9GB of undo files, so we
might as well move off of tdb now.)

The last problem is fatal if you want to use tune2fs to turn on
metadata checksumming, since that rewrites every block on the
filesystem, which can easily produce a many-gigabyte undo file, which
of course is unreadable and therefore the operation cannot be undone.

Therefore, rip all of that out in favor of writing to a flat file.
Old blocks are appended to a file and the index is written to the end
when we're done.  This implementation is much faster than wasting a
considerable amount of time trying to maintain a hash index, which
drops the runtime overhead of tune2fs -O metadata_csum from ~45min
to ~20 seconds on a 2TB filesystem.

I have a few reasons that factored in my decision not to repurpose the
jbd2 file format for undo files.  First, undo files are limited to
2^32 blocks (16TB) which some day might not serve us well.  Second,
the journal block size is tied to the file system block size, but
mke2fs wants to be able to back up big chunks of old device contents.
This would require large changes to the e2fsck journal replay code,
which itself is derived from the kernel jbd2 driver, which I'd rather
not destabilize.  Third, I want to require undo files to store the FS
superblock at the end of undo file creation so that e2undo can be
reasonably sure that an undo file is supposed to apply against the
given block device, and doing so would require changes to the jbd2
format.  Fourth, it didn't seem like a good idea that external
journals should resemble undo files so closely.

v2: Provide a state bit that is only set when the undo channel is
closed correctly so we can warn the user about potentially incomplete
undo files.  Straighten out the superblock handling so that undo files
won't be confused for real ext* FS images.  Record multi-block runs in
each block key to reduce overhead even further.  Support reopening an
undo file so that we can combine multiple FS operations into one
(overall smaller) transaction file, which will be easier to manage.
Flush the undo index data if the program should terminate
unexpectedly.  Update the ext4 superblock bits if errors or -f is
found to encourage fsck to do a full run the next time it's invoked.
Enable undoing the undo.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-05-05 10:40:16 -04:00
Darrick J. Wong ec2019d109 e2undo: fix memory leaks and tweak the error messages somewhat
Fix memory leaks and improve the error messages to make it easier
to figure out why e2undo went wrong.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-05-05 10:39:51 -04: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
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
Eric Sandeen 19ef479acf e2undo: cast dptr to blk64_t to retrieve block number
A 32-bit s390 build was failing on a 64-bit s390x host, when
make check failed e2undo tests, like this:

md5sum before mke2fs 922c8a591c882dbdd1a381d18547cfd5
using mke2fs to test e2undo
Overwriting existing filesystem; this can be undone using the command:
    e2undo /tmp/mke2fs-tmp.EM9XjmTA81.e2undo /tmp/tmp.EM9XjmTA81

md5sum after mke2fs cbf32fb6c3db45280ad013f42ac294f1
Replayed transaction of size 32768 at location 0
Replayed transaction of size 32768 at location 0
Replayed transaction of size 32768 at location 0
Replayed transaction of size 32768 at location 0
Replayed transaction of size 0 at location 0
md5sum after e2undo 31b4e14307c5b7ccce5b8d300c2ad5f1

Note the "at location 0" for the block number.

A proper cast in e2undo.c fixes this up.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-11-18 22:14:24 -05:00
Theodore Ts'o 9d4507c5b6 Pass the gettext() function to libcom_err
For those e2fsprogs programs which use libcom_err and are
internationalized, pass the gettext() function to libcom_err during
program initialization.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-05 01:00:30 -04:00
Theodore Ts'o d1154eb460 Shorten compile commands run by the build system
The DEFS line in MCONFIG had gotten so long that it exceeded 4k, and
this was starting to cause some tools heartburn.  It also made "make
V=1" almost useless, since trying to following the individual commands
run by make was lost in the noise of all of the defines.

So fix this by putting the configure-generated defines in lib/config.h
and the directory pathnames to lib/dirpaths.h.

In addition, clean up some vestigal defines in configure.in and in the
Makefiles to further shorten the cc command lines.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-18 17:34:37 -04:00
Andreas Dilger cf5301d7f2 misc: clean up compiler warnings
Fix several types of compiler warnings (unused variables/labels),
uninitialized variables, etc that are hit with gcc -Wall.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11 10:58:25 -04:00
Valerie Aurora Henson cd5ca12d43 e2image: Fix up to be 64-bit block number safe
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-13 20:00:00 -04:00
Theodore Ts'o 95bcea9fc1 Merge branch 'maint' into next
Conflicts:
	configure
	configure.in
	misc/mke2fs.c
2009-10-04 20:40:46 -04:00
Theodore Ts'o 1d4a493fa2 e2undo: Initialize com_err error tables for the ext2fs library
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-08 21:29:21 -04:00
Valerie Aurora Henson 24a117abd0 Convert to use io_channel_read_blk64() and io_channel_write_blk64()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 21:14:24 -04:00
Benno Schulenberg 577b5c436f e2undo, tune2fs: Report the correct name for the undo program.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-07-18 21:13:20 -04:00
Theodore Ts'o 38dd11f595 e2undo: Don't use __FUNCTION__ for portability reasons
Solaris C99 apparently doesn't support it.  We should report the
program name, not the internal function name, when printing an error
in any case.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-13 16:06:57 -04:00
Eric Sandeen 79e62409b3 Clean up some trivial build warnings
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-06 18:36:56 -04:00
Theodore Ts'o 11d4f30fe1 e2undo: Enable missing pieces to enable I18N for this application
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-07 22:16:48 -04:00
Aneesh Kumar K.V 5f8a5ae6b8 Add e2undo command
The e2undo command can be used to replay the transaction saved in the
transaction file using undo I/O Manager.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-27 19:42:05 -04:00