Adding upstream version 0.3.1.

Roberto Maar <>
This diff is collapsed.
0.3.1 Some minor bugs been fixed.
new : support for ecryptfs by Magic-function
0.3.0 switch to BETA status
Some minor bugs been fixed. compiler warnings eliminated
0.3.0.pv2 new : a new partial step, recovers journal lost inodes
new : support for libext2fs 1.41.x and 1.42.x
BUG : #018449 #018437
for file systems > 8TByte some errors fixed
0.3.0.pv1 new : functions for RPM; DBF; XCF(Gimp); ESRI; DjVu and CDF
change : DEB; ZIP; TTF; Gnumeric; some Perl and Python files
Optimization for text based files (not completed yet)
0.3.0-pv0 new : the first experimental version of the magic-functions for ext4
disabled : the magic-function for ext3 is switched off in this version
change : Most functions in file_type.c are strongly modified, or completely new;
Many functions in magic_block_scan.c been enhanced for the properties of ext4
filetype sorted file names with file extension in the directory MAGIC-2
new dependencies: zlib ; bzlib
0.2.3 temporarily separate development branch
BUG : 018244
change : filetype sorted file names with file extension in the directory MAGIC-2
0.2.2 new : Option -D (Disaster recovery) recover data from severely damaged file systems (Expert-Mode)
move : option -Q has been moved to the expert mode(too much confusion for normal users)
BUG : Memory leak fixed (ext4 inode extents)
BUG : #018106 ext4 extents are displayed partly false
change : improved evaluation of directory data blocks
this eliminate some errors in directories with HTREE
0.2.1 new : optional Expert-Mode (activate at configure) new Options "-s blocksize" ; "-n blockcount" ; "-c"
change : activate magic level 1 and 2 for recover from the root inode
BUG : #018040
0.2.0 change :optimization of the ext3 magic scan functions
new: support for a lot of images, video and audio
new: possibility of the stream orientation. (needed for mp3)
change : prevent partially recover on txt and other
change : an already restored file tail does not prevent the recover of the entire file
BUG: #017694; #017695; #017712
0.2.0-pv2 new: support and modification for a lot of filetype
change :adjusting settings for version file-5.04
change :stabilization of the magic scan functions
BUG: segfault if filesystem can not open.
BUG: #017625; #017618
BUG: #017547; #017556; #017557; #017559; #017562
BUG: #017561 change Install HOWTO
0.2.0-pv0 BUG: #017447 ; #017453
enable the first version of the magic-functions for ext3
new Options "-M" and "-m"
check header und library in configure
0.1.4 BUG: #17387 symlink not restored
BUG: #17423 undeleted directory not found
BUG: #17425 run-time error "segmentation fault" at the beginning of a directory
enable optional support for ext2/3/4 file attributes
restore unlinked files
0.1.3 BUG: crash if no write access to input filename list
changes: time option to "-a ...." and "-b ...."
changes: time match search for inode in directory
changes: BIG ENDIAN swap dirblock
changes: checking recover device
fix: some small bugs
0.1.2 hardlink database: Changes handling link-count
hardlink database: at end of process print content
set_dir_attributes(): create now also empty directories with "-R"
new option "-Q" : high quality recover, not use of deleted directory entry
BUG: incorrect cr_time in histogram
BUG: recover_file(): socket Inode not ignored
BUG: list of special and bad Inodes produce crash
BUG: symlink : group and owner not correct
Change some display options
0.1.1 first complete version
Install ext4magic
Quick Install HOWTO
You have to compile the ext4magic source code. It install a binary program /usr/local/sbin/ext4magic and a manpage
This works only on Linux (also Big-Endian-CPUs)
Other UNIX operating systems will not compile.
You need the packages :
Furthermore, there are dependencies to following libraries:
These libraries are present on any Linux, but you need some actual versions.
Check the version with the following commands:
# file -v
# /sbin/fsck.ext3 -V
the version of "file" must be > 5.03
and the EXT2FS Library version >= 1.41.9 (libext2fs-1.42 see Known Bugs)
Under these conditions, installation is fairly simple.
Install the following devel packages:
There are possibley different names according your Linux distribution
openSuse debian Fedora
libext2fs-devel e2fslibs-dev e2fsprogs-devel
libuuid-devel uuid-dev libuuid-devel
libblkid-devel libblkid-dev libblkid-devel
file-devel libmagic-dev file-devel
zlib-devel zlib1g-dev ?
libbz2-devel libbz2-dev ?
unzip the archive and cd into the directory
# tar -xzf ext4magic-?.?.?.tar.gz
# cd ext4magic-?.?.?
The following commands to compile ext4magic
# ./configure
# make
and install as root
# make install
this is everything, and it installs the following files
Optional extensions
with configure the following extensions can be activated
--enable-expert-mode # use of file system superblock copies
and recover from partially destroyed file systems
--enable-file-attr # restore also file attributes
Detailed Install Howto for special cases
Following detailed instructions for installing considered special cases,
depends on the library versions also on older operating systems or
if the devel package can not be found or if certain libraries to be statically linked.
The file-command and the library libmagic
In versions ext4magic > 0.1.4 you need the package of the Linux command "file".
Needed a version > 5.03 (see also BUG:#017561) for stabil magic-functions in ext4magic.
Which version is installed displays the following command
# file -v
If found 5.04 on your Linux, install also the devel package, or you must create a symlink of the library. (see follow)
No version 5.04 for your Linux available? You can also install version file-5.04 from source.
You can uninstall the older version of "file" (not recommended) if it has no dependencies to other packages. (eg. perl,apache,...)
If the old version deleted, the new must necessarily configured to /usr and not to /usr/local.
Or you can install a second version to /usr/local (recommended)
In this case, do not install the devel package of an old version.
The following illustrates the installation of a second version
# tar -xzf file-5.04.tar.gz
# cd file-5.04
# ./configure
# make
# su -
# cd ????/file-5.04
# make install
# ldconfig
The following command should now show both, the version in "/usr/lib/" and in "/usr/local/lib/"
(If use a 64-bit system, the library path can also be /usr/lib64 and /usr/local/lib64)
# ldconfig -p | grep libmagic (libc6) => /usr/local/lib/ (libc6) => /usr/lib/ (libc6) => /usr/local/lib/
In this case, the symlink "/usr/lib/" should not exist. (see follow)
If the new version libmagic is now not available in /usr/local/... , or the following command failed
#/usr/local/bin/file -v
then try the following command as root
# ldconfig /usr/local/lib /usr/local/lib64
and check again.
Which of the two libmagic versions the finished ext4magic use, you can check with:
# ldd /usr/local/sbin/ext4magic | grep libmagic => /usr/local/lib/ (0xb7741000)
If you get the following error during configure ext4magic:
"library >= 5.04 not found, install package "file-5.04" and "file-devel" (workaround see INSTALL)"
and >= "file-5.04" is installed, then no file "" is found, probably the devel package is not installed.
Not for all distributions it is available. You can work around that by generate a symlink "" to the
existing version of this library. (on a 64-bit system, the library path can also be /usr/lib64 )
see the following log:
# cd /usr/lib
# ln -s
# ls -l /usr/lib/libmagic*
lrwxrwxrwx 1 root root 13 Sep 23 01:40 /usr/lib/ ->
lrwxrwxrwx 1 root root 17 Aug 28 16:09 /usr/lib/ ->
-rwxr-xr-x 1 root root 116720 Oct 24 2009 /usr/lib/
For more than one version of libmagic:
The version for compiling with ext4magic should have the symlink ""
another version of libmagic should not have this symlink.
Devel packages and librarys of libext2fs
First check your current version of libext2fs with the following command
# /sbin/fsck.ext3 -V
if Version >= 1.41.9
Install the following devel packages:
There are possibley different names according your Linux distribution
openSuse debian Fedora
libext2fs-devel e2fslibs-dev e2fsprogs-devel
libuuid-devel uuid-dev libuuid-devel
libblkid-devel libblkid-dev libblkid-devel
then compile ext4magic
# tar -xzf ext4magic-0.3.0.tar.gz
# cd ext4magic-0.3.0
# ./configure
# make
# su
# make install
if Version < 1.41.9
download a actual version of e2fsprogs from
# tar -xzf e2fsprogs-1.41.9.tar.gz
# cd e2fsprogs-1.41.9
# ./configure
# make
Important: Please do not install this version.
This could create problems with programs of your current distribution ..
save the actual directory path of lib/ in a variable for future use in configure commandline.
# EXT2LIB="$(pwd)/lib"
After this, change into the code directory of ext4magic
# tar -xzf ext4magic-0.3.0.tar.gz
# cd ext4magic-0.3.0
# ./configure CFLAGS="-I$EXT2LIB" LDFLAGS="-L$EXT2LIB" LIBS="-luuid -lcom_err -lpthread"
# make
# su
# make install
ext4magic is so static linked to the newer library. You can see different version of libext2fs by:
# ext4magic -V x
# /sbin/fsck.ext3 -V
This diff is collapsed.
# not a GNU package. You can remove this line, if
# have all needed files, that a GNU package needs
AUTOMAKE_OPTIONS = foreign 1.4
This diff is collapsed.
ext4magic 0.3.1 new : support for ecryptfs by Magic-function
ext4magic 0.3.0 switch to BETA status
Some minor bugs been fixed. compiler warnings eliminated
English documentation translation is started
ext4magic 0.3.0 pv2 A new recover sub-step. Inode found in partially overwritten areas of the
journal can now also recovers. It is impossible to identify the inode number,
the file name and the time of deletion. These files are also restored to the
MAGIC-2 directory.
ext4magic can now also be compiled with libext2fs-1.42.x
but ext4 file systems >= 16 TByte do not work.
Some errors in file system > 8 TByte fixed.
ext4magic 0.3.0 pv1 New features for restoring Gimp images, many of document formats and
enhancements to recover text-based files.
ext4magic 0.3.0 pv0 Contains the first experimental version of the magic function for ext4
The magic function for ext4 can restore deleted files which
consisted of more than 4 extents (includes extra large and sparse files)
and files that are unfragmented. (most small and medium-sized files
and many large files, are often unfragmented)
This version can not recover files with 2 to 4 extents. But it's prepared and
will be possible in later versions for some file types.
Depending of the file type, different methods for recovery are used.
For most file types specific functions have been developed.
Supported the most important file formats for:
file archivs, compressed files, a lot off video-, audio- and picture formats,
ELF-binary format, Mail, PDF, a lot of text-based file formats, and much more.
Tested are more than 50 file formats and if available, also possible
variants and subtypes.
Possible, this version will work well for you, possible, it does not work.
This version includes a lot of new and experimental code.
The magic-function for ext3 is switched off in this version. For ext3 use
ext4magic 0.2.3
ext4magic 0.2.3 This version is separated from the main development branch.
Version 0.2.3 contains the old version of Magic function only for ext3
with some new features and bug fixes.
ext4magic 0.2.2
Expansion of the Expert-Mode.
With the new "-D" option it is possible to recover data from severely damaged file systems.
For example: the file system has been partially overwritten. But large parts of the file
system are not destroyed.
improved evaluation of directory data blocks eliminate some errors in directories with HTREE
thus, a better file name resolution and fewer files with incorrect names.
ext4magic 0.2.1 Optional Expert-Mode with the following new options "-s blocksize" ; "-n blockcount" ; "-c"
This makes it possible to open front corrupted file systems.
Modified flow control allows automatic a recover-all ("-r" or "-R" on the entire file system)
This enables the restore of deleted inode even if the directory inode is not found in journal.
The function uses the first two stages of the magic functions (ext3/ext4)
ext4magic 0.2.0 The Magic features for ext3 are complete.
Support for most files types of a typical Linux system and lots of multimedia files.
ext4magic 0.2.0 pv2 The magic functions have been adjusted for libmagic (file-5.04)
Many bugs have been fixed and added support for many file types
ext4magic 0.2.0 pv0 First test version of ext3 magic-scan-functions. This is a novel multi-stage recovery.
There are several recover methods used in succession. All functions use journal entries.
Furthermore, the library libmagic and coded file properties are implemented.
This automatic functions are specifically designed to recover deleted files immediate
after a recursiv delete command.
For this purpose two new options are available.
"-M" if the entire file system is deleted
"-m" if only parts of the file system is deleted
ext4magic 0.1.4 Support for user-modifiable file attributes.
ext4magic can now restore the ext2/3/4 File attributes.
It is disabled by default. To activate, you must add the option --enable-file-attr
when running configure.
ext4magic 0.1.3 there is now a german documentation
We start with the BETA testing and try to find some german users for the
tests of general use, the elementary functions and the documentation.
The aim is to check the stability and to optimize the german documentation
for a translation.
This diff is collapsed.
TODO over of the next year ;-)
- English documentation
we working on it, but we need help !!!!!!!
Current stat 04.2012: not ready but looks good
- support for ecrypfs in the Magic-function
is particularly interesting for Ubuntu user
Current stat 04.2012: ready for test
- the new Magic-function for ext3
old 0.2.x function is very slow and inaccurate
and is not compatible with the Magic-functions of the ext4 in 0.3.x
a support for both file systems is planned with 0.4.x
Current stat 04.2012: open
- better support for source code and other text files
"file" can not detect the text file type if a long comment at begin of the file
therefore the Magic-function recovers not all
shell example : for a possibility solution approach
# file -i ext4magic.c
ext4magic.c: text/plain; charset=us-ascii
# sed '1,/^$/d' ext4magic.c | file -i -
/dev/stdin: text/x-c; charset=us-ascii
Current stat 04.2012: The current libmagic-5.11 eliminated the problem.
Changes within ext4magic therefore, not required
- ext4 : with the Magic-function it should be possible to recover also some file types
if the deleted file has existed with 2 to 4 extents
the conditions and preparations are already included
the possible individual extents are already collected in the database
a function is needed to find out and check the correct order
Current stat 04.2012: open
Currently known issues
- on big-endian the crtime and deleted directory entry not correct if use the
real libfunction for read the inode.
The modified version to read the Journal inode works. BUG:#017304 ; #017304
This diff is collapsed.
This diff is collapsed.
/* Generated from by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
/* Define to 1 if you have the <inttypes.h> header file. */
/* Define to 1 if you have the <memory.h> header file. */
/* Define to 1 if you have the <stdint.h> header file. */
/* Define to 1 if you have the <stdlib.h> header file. */
/* Define to 1 if you have the <strings.h> header file. */
/* Define to 1 if you have the <string.h> header file. */
/* Define to 1 if you have the <sys/stat.h> header file. */
/* Define to 1 if you have the <sys/types.h> header file. */
/* Define to 1 if you have the <unistd.h> header file. */
/* Define to the sub-directory in which libtool stores uninstalled libraries.
#undef LT_OBJDIR
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
/* Define to the full name of this package. */
/* Define to the full name and version of this package. */
/* Define to the one symbol short name of this package. */
/* Define to the version of this package. */
/* Define to 1 if you have the ANSI C header files. */
/* Version number of package */
#undef VERSION
This diff is collapsed.
This diff is collapsed.
AM_INIT_AUTOMAKE(ext4magic, 0.3.1)
test $fail = 1 &&
AC_MSG_ERROR([You must install the develop packages "ext2fs , blkid , e2p , uuid" to build ext4magic])
test $fail = 1 &&
AC_MSG_ERROR([You must install the packages "zlib-devel and libbz2-devel" to build this version])
AC_SEARCH_LIBS([ext2fs_test_inode_bitmap_range], [ext2fs], [], [fail=1])
test $fail = 1 &&
AC_MSG_ERROR([You must have ext2fs version >= 1.41.9 to build ext4magic])
AC_SEARCH_LIBS([magic_getpath], [magic], [], [fail=1])
test $fail = 1 &&
AC_MSG_ERROR([library >= 5.04 not found, install package "file-5.04" and "file-devel" (workaround see INSTALL)])
AC_ARG_ENABLE(debug,[ --enable-debug Turn on debugging ],
[if test "$GCC" = "yes"; then CPPFLAGS="$CPPFLAGS -DDEBUG"; fi])
AC_ARG_ENABLE(debug-magic,[ --enable-debug-magic Turn on debugging magic-scan-engine ],
[if test "$GCC" = "yes"; then CPPFLAGS="$CPPFLAGS -DDEBUG_MAGIC_SCAN"; fi])
AC_ARG_ENABLE(file-attr,[ --enable-file-attr enable restore of file attribute ],
[if test "$GCC" = "yes"; then CPPFLAGS="$CPPFLAGS -DFILE_ATTR"; fi])
AC_ARG_ENABLE(expert-mode,[ --enable-expert-mode enable advanced options for expert mode ],
[if test "$GCC" = "yes"; then CPPFLAGS="$CPPFLAGS -DEXPERT_MODE"; fi])
AC_OUTPUT(Makefile src/Makefile)
This diff is collapsed.
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/
# Copyright 1991 by the Massachusetts Institute of Technology
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
# Calling this script install-sh is preferred over, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
# put in absolute paths if you don't have them in your path; or use env. vars.
chmodcmd="$chmodprog 0755"
rmcmd="$rmprog -f"
while [ x"$1" != x ]; do
case $1 in
-c) instcmd=$cpprog
-d) dir_arg=true
-m) chmodcmd="$chmodprog $2"
-o) chowncmd="$chownprog $2"
-g) chgrpcmd="$chgrpprog $2"
-s) stripcmd=$stripprog
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
*) if [ x"$src" = x ]
# this colon is to work around a 386BSD /bin/sh bug
if [ x"$src" = x ]
echo "$0: no input file specified" >&2
exit 1
if [ x"$dir_arg" != x ]; then
if [ -d "$dst" ]; then
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f "$src" ] || [ -d "$src" ]
echo "$0: $src does not exist" >&2
exit 1
if [ x"$dst" = x ]
echo "$0: no destination specified" >&2
exit 1
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d "$dst" ]
dst=$dst/`basename "$src"`