Commit Graph

172 Commits (a46300fe703a03185575ad1b45ff03e90d76f04c)

Author SHA1 Message Date
Darrick J. Wong a46300fe70 misc: create better-packaged static analysis reports
Fix some minor bugs relating to passing CFLAGS to cppcheck, and
package the cppcheck output into nicer looking reports.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-11 18:32:07 -04:00
Theodore Ts'o c9bc7484cc Merge branch 'maint' into next
Conflicts:
	e2fsck/pass1.c
2014-05-11 18:30:11 -04:00
David Michael 4e2d9f7f4e Add a make variable for the pkgconfig install dir
Adding the pkgconfigdir variable allows specifying an installation
location for pkg-config files independent of libdir.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-05-07 10:51:50 -04:00
Darrick J. Wong f1605243a4 all: Introduce cppcheck static checking for make C=1
Introduce more static checking via cppcheck.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-14 09:32:50 -04:00
Theodore Ts'o cecc79ac3f Update Makefile dependencies
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-06 11:26:41 -05:00
Zheng Liu 3125348838 libext2fs: add a unit test for inline data
In this unit test, we will test the interface of inline data and make
sure it is fine.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-04 08:46:16 -05:00
Zheng Liu 416c1de94d libext2fs: handle inline data in dir iterator function
Inline_data is handled in dir iterator because a lot of commands use
this function to traverse directory entries in debugfs.  We need to
handle inline_data individually because inline_data is saved in two
places.  One is in i_block, and another is in ibody extended attribute.

After applied this commit, the following commands in debugfs can
support the inline_data feature:
	- cd
	- chroot
	- link*
	- ls
	- ncheck
	- pwd
	- unlink

* TODO: Inline_data doesn't expand to ibody extended attribute because
  link command doesn't handle DIR_NO_SPACE error until now.  But if we
  have already expanded inline data to ibody ea area, link command can
  occupy this space.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-04 08:46:08 -05:00
Theodore Ts'o 3ba59bf649 Merge branch 'maint' into next 2014-02-23 23:07:38 -05:00
Theodore Ts'o fedfb27fe5 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>
2014-02-23 00:17:09 -05:00
Theodore Ts'o f0996c12d5 Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/alloc.c
	misc/mke2fs.c
2014-01-30 19:05:16 -05:00
Theodore Ts'o c714d02482 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>
2014-01-30 18:48:23 -05:00
Theodore Ts'o d954fa407b 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>
2014-01-19 19:19:26 -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 6c59a665da 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>
2014-01-05 22:58:16 -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 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 e337e7fad8 Merge branch 'maint' into next
Conflicts:
	e2fsck/problem.c
	e2fsck/rehash.c
	e2fsck/super.c
2013-10-12 22:26:28 -04:00
Darrick J. Wong 832cb612f8 e2fsprogs: add (optional) sparse checking to the build
Run sparse against source files when building e2fsprogs with 'make C=1'.  If
instead C=2, it configures basic ext2 types for bitwise checking with sparse,
which can help find the (many many) spots where conversion errors are
(possibly) happening.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-10-11 23:12:40 -04:00
Theodore Ts'o 7b68fa38b8 Merge branch 'maint' into next
Conflicts:
	RELEASE-NOTES
	lib/ext2fs/ext2_err.et.in
	version.h
2013-01-16 14:14:09 -05:00
Darren Hart f01c1a6bce libext2fs: add the ext2fs_symlink() function
Creating symlinks is a complex affair when accounting for slowlinks.

Create a new function, ext2fs_symlink(), modeled after ext2fs_mkdir().
Like ext2fs_mkdir(), ext2fs_symlink() takes on the task of allocating a
new inode and block (for slowlinks), setting up sane default values in
the inode, copying the target path to either the inode (for fastlinks)
or to the first block (for slowlinks), and accounting for the inode and
block stats.  Disallow link targets longer than blocksize as the Linux
kernel prevents this.

It does not attempt to expand the parent directory, instead returning
EXT2_ET_DIR_NO_SPACE and leaving it to the caller to expand just as
ext2fs_mkdir() does.  Ideally, I think both of these functions should
make a single attempt to expand the directory.

[ Fixed a few bugs discovered when creating a test case for ext2fs_symlink() ]

Signed-off-by: Darren Hart <dvhart@infradead.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: Andreas Dilger <adilger@dilger.ca>
2013-01-16 14:09:17 -05:00
Theodore Ts'o ab83252174 Merge branch 'maint' into next
Conflicts:
	e2fsck/problem.c
	e2fsck/problem.h
2012-12-24 10:50:20 -05:00
Theodore Ts'o 068136c31e libext2fs: link the test programs with static libraries
Force the use of the static libraries when linking the test program so
that "make check" works when the shared libraries have not been
installed, and so that we test against the version of the libraries in
the source tree.

Reported-by: g.esp@free.fr
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-24 10:49:45 -05:00
Theodore Ts'o bee7b67ce9 debugfs: add the ability to manipulate the extent tree directly
This commit adds the functionality which had previously only been in
the tst_extents command to debugfs.  The debugfs command extent_open
will open extent tree of a particular inode, and enables a series of
commands which will allow the user to interact with the extent tree
directly.  Once the extent tree is closed via extent_open(), these
additional commands will be disabled again.

This commit exports two new functions from lib/ext2fs/extent.c which
had previously been statically defined: ext2fs_extent_node_split() and
ext2fs_extent_goto2().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-24 10:49:41 -05:00
Theodore Ts'o 0e7e7c8ef8 Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/ext2fs.h
2012-09-09 22:52:26 -04:00
Theodore Ts'o ab3f5c5aad Allow e2fsprogs to be built using the clang (LLVM) frontend
Since clang uses C99 semantics by default, the main changes required
to allow clang to build e2fsprogs was to add support the C99 inline
semantics, while still allowing us to be built when the legacy (but
still default for gcc) GNU C89 inline semantics are in force.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-09-09 21:35:39 -04:00
Theodore Ts'o 2d913dbcdf Merge branch 'maint' into next 2012-08-06 21:09:49 -04:00
Theodore Ts'o d5aa6a82b3 Put ELF_OTHER_LIBS in the right place for the linker
Commit a7c17431b9 attempted to fix a problem where the system
libraries might get used instead of local libraries for things like
-lcom_err.  It tried to accomplish this by moving $(ELF_OTHER_LIBS) to
before $(LDFLAGS).

Unfortunately, this was the wrong fix; $(ELF_OTHER_LIBS) *MUST* be
after the object files, or the linker might not pull in the necessary
library and not include it into the DT_NEEDED section of the shared
library.  The proper fix is to add a -L$(LIB) before $(LDFLAGS), and
then remove the -L option from all of the ELF_OTHER_LIBS definitions
in the library Makefiles.

Addresses-Sourceforge-Bug: #3554345

Cc: Olivier Blin <olivier.blin@softathome.com>
Reported-by:  Mike Frysinger <vapier@gentoo.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-08-06 12:30:49 -04:00
Theodore Ts'o bc0b1a899a libext2fs: move ext2fs_get_num_dirs to its own file
This reduces the number of C library symbols needed by boot loader
systems such as yaboot.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-07-30 17:19:15 -04:00
Theodore Ts'o c1986ecb6f Fix blhc (Build Log Hardening Check) warnings
The Build Log Hardening Check is a debian tool which scans the output
of a package build making sure that the security hardening flags are
used when compiling and linking all of binaries in a package.

For the most part we were passing CFLAGS, CPPFLAGS, and LDFLAGS down
to the compiler and link commands, but there there were one or two
exceptions.  In addition, there where a few places in "make install"
where the V=1 option was not being honored, which triggered blhc
warnings since it couldn't analyze those commands.

The e2fsck.static was the only binary that was not getting built and
packaged with the hardening flags, but I've fixed all of the blhc
warnings so in the future it will be obvious if we regress.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-06-13 16:06:44 -04:00
Theodore Ts'o d71520751e Support systems without posix_memalign() and memalign()
MacOS 10.5 doesn't have posix_memalign() nor memalign(), but it does
have valloc().  The Android SDK would like to be built on MacOS 10.5,
so I've added support for a good-enough emulation of memalign()'s
functionality using valloc(), with an explicit test to make sure
valloc() is returning a pointer which is sufficiently aligned given
the requested alignment.  This won't work if you try to operate on a
file system with a 16k blocksize using an e2fsprogs built on MacOS
10.5 system, but it is good enough for the common case of 4k
blocksize file systems, and we will let the memory allocation fail in
the alignment is not good enough.

I've also added a unit test for ext2fs_get_memalign() so we can be
sure it's working as expected.  I've tested the code paths with
HAVE_POSIX_MEMALIGN defined, HAVE_POSIX_MEMALIGN undefined, and
HAVE_POSIX_MEMALIGN and HAVE_MEMALIGN undefined on an x86 Linux
system, and so I know the valloc() code path works OK.  The simplistic
(and less safe) patch at:

https://trac.macports.org/attachment/ticket/33692/patch-lib-ext2fs-inline.c.diff

Shows that using valloc() apparently works OK for MacOS 10.5 (but if
it doesn't the unit test will catch a problem).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-05-11 18:21:08 -04:00
Theodore Ts'o 46f100707c libext2fs: improve testing coverage of tst_bitmaps
Improve the test coverage of tst_bitmaps by:

   (a) adding the ability to test the legacy (32-bit) bitmap code
   (b) adding tests for ext2fs_find_first_zero_inode_bitmap2() and
       ext2fs_find_first_zero_block_bitmap2()

The recent regressions caused by the addition (and use) of
ext2fs_find_first_zero_inode_bitmap2() would have been caught if we
had added these tests first.  (Another object lesson in why unit tests
are critically important!)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-04-09 14:29:47 -04:00
Theodore Ts'o 70d7281dcb Update Release Notes, Changelogs, version.h, etc. for 1.42.2 release
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-03-27 16:20:46 -07:00
Theodore Ts'o d182831a15 libext2fs: add pseudo bitmap backend type EXT2FS_BMAP64_AUTODIR
This backend type will automatically switch between the bitarray and
the rbtree backend based on the number of directories in the file
system.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-12-18 01:12:43 -05:00
Lukas Czerner c1359d9195 libext2fs: add a bitmap implementation using rbtree's
For a long time we had a bitarray backend for storing filesystem
metadata bitmaps, however today this approach might hit its limits with
todays huge data storage devices, because of its memory utilization.

Bitarrays stores bitmaps as ..well, as bitmaps. But this is in most
cases highly unefficient because we need to allocate memory even for the
big parts of bitmaps we will never use, resulting in high memory
utilization especially for huge filesystem, when bitmaps might occupy
gigabytes of space.

This commit adds another backend to store bitmaps. It is based on
rbtrees and it stores just used extents of bitmaps. It means that it can
be more memory efficient in most cases.

I have done some limited benchmarking and it shows that rbtree backend
consumes approx 65% less memory that bitarray on 312GB filesystem aged
with Impression (default config). This number may grow significantly
with the filesystem size, but also it may be a lot lower (even negative)
if the inodes are very fragmented (need more benchmarking).

This commit itself does not enable the use of rbtree backend.

[ Simplified the code by avoiding unneeded memory allocation and
  deallocation of del_ext.  In addition, fixed a bug discovered by the
  tst_bitmaps tests: rb_unamrk_bmap() must return true if the bit was
  previously set in bitmap, and zero otherwise -- tytso ]

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-12-18 01:12:40 -05:00
Lukas Czerner 5db745a283 libext2fs: add rbtree library
This commit adds rbtree library into e2fsprogs so it can be used for
various internal data structures. The rbtree implementation is ripped of
kernel rbtree implementation with small changes needed for it to work
outside kernel.

[ I prefixed the exported symbols and interface with ext2fs_ to keep
  avoid pulluting the namespace exported by the libext2fs shared
  library.  -- tytso ]

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-12-18 01:00:44 -05:00
Theodore Ts'o b8ad88b3e7 libext2fs: add tests for the bitmap functions
These tests allow us to be sure that the new bitmap backends are
correctly implemented.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-12-18 01:00:38 -05:00
Theodore Ts'o 499d5ec558 Update Release Notes, Changelogs, version.h, etc. for 1.42 release
Also fixed depfix.sed

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-29 16:48:14 -05:00
Theodore Ts'o 930d7a7fb7 tst_fs_struct: add program to help check ABI compatibility of ext2fs_filsys
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-25 21:16:38 -05:00
Theodore Ts'o c4ab66c526 debugfs: add filefrag command
Add the ability to report on the fragmentation of a file on a file
system opened using debugfs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-18 22:14:15 -05:00
Theodore Ts'o 5e96c5721d debugfs: add the freefrag command
The freefrag command provides the functionality of e2freefrag on the
currently open file system in debugfs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-18 22:12:12 -05:00
Theodore Ts'o fd7c37fec1 Update for e2fsprogs 1.42-WIP-1005 release
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-05 02:40:11 -04:00
Theodore Ts'o 756690a29e libext2fs, libquota: fix some makefile dependency issues
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-03 14:57:51 -04:00
Darrick J. Wong a7a63675af libext2fs: Fix various bugs from the metadata checksum integration
Fix several minor errors in structure definitions, the byteswap code,
and Makefiles that result from merging the crc32c and initial parts of
the metadata checksumming patchset.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-30 21:28:12 -04:00
Andreas Dilger 0f5eba7501 ext2fs: add multi-mount protection (INCOMPAT_MMP)
Multi-mount protection is feature that allows mke2fs, e2fsck, and
others to detect if the filesystem is mounted on a remote node (on
SAN disks) and avoid corrupting the filesystem.  For e2fsprogs this
means that it checks the MMP block to see if the filesystem is in use,
and marks the filesystem busy while e2fsck is running on the system.

This is useful on SAN disks that are shared between high-availability
servers, or accessible by multiple nodes that aren't in HA pairs.  MMP
isn't intended to serve as a primary HA exclusion mechanism, but as a
failsafe to protect against user, software, or hardware errors.

There is no requirement that e2fsck updates the MMP block at regular
intervals, but e2fsck does this occasionally to provide useful
information to the sysadmin in case of a detected conflict.

For the kernel (since Linux 3.0) MMP adds a "heartbeat" mechanism to
periodically write to disk (every few seconds by default) to notify
other nodes that the filesystem is still in use and unsafe to modify.

Originally-by: Kalpak Shah <kalpak@clusterfs.com>

Signed-off-by: Johann Lombardi <johann@whamcloud.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-25 01:55:23 -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
Theodore Ts'o 65b7a463da libext2fs: fix size check in tst_inode_size
Also add run tst_inode_size automaically from "make check"

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-16 09:27:06 -04:00
Darrick J. Wong db8bbf27c9 libext2fs: Add crc32c implementation for metadata checksumming
Add a slicing-by-8 CRC32c implementation for metadata checksumming.
Adapted from Bob Pearson's kernel patch.

Also added a self-test mechanism so we can verify that the crc32c
implementation is working correctly.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15 23:46:51 -04:00
Theodore Ts'o 897fbaac7d libext2fs: add new test: tst_inode_size
This test makes sure the size of the ext2_inode is what we expect

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-14 13:47:35 -04:00
Theodore Ts'o 1ca87790b9 libext2fs: fix makefile dependency problem
lib/ext2fs/Makefile.in had a buggy entry for blkmap64_ba.c in $(SRCS),
which caused this source file to not have a valid Makefile dependency
entry, so blkmap64_ba.o would not get rebuilt when it needed to be.

Also updated the Makefile dependency for the misc directory while
we're at it.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-19 21:58:20 -04:00
Lukas Czerner bf0449b1a6 e2image: Add support for qcow2 format
This commit adds support for exporting filesystem into QCOW2 image
format. Like sparse format this saves space, by writing only necessary
(metadata blocks) into image. Unlike sparse image, QCOW2 image is NOT
sparse, hence does not change its size by copying with not-sparse-aware
tools.

New options '-Q' has been added to tell the e2image to use QCOW2 as an
output image format. QCOW2 supports encryption and compression, however
e2image so far does no support such features, however you can still
scramble filenames with '-s' option.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-18 11:51:06 -04:00