Commit Graph

1935 Commits (fd80e987d7a62a4aee7a9a4fb167f707b312e9fa)

Author SHA1 Message Date
Theodore Ts'o 3888c1e84d libext2fs: sanity check group argument to ext2fs_clear_{block,inode}_uninit()
Avoid a potential out-of-bounds memory access if the group passed to
ext2fs_clear_block_uninit() or ext2fs_clear_inode_uninit() is greater
than the number of groups in the file system.  This prevents a failure
in resize2fs when to allocate a block when growing the file system
significantly.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-05-11 23:23:06 -04:00
Theodore Ts'o b8aa9b6294 libext2s: only define FS_IOC_FIEMAP on Linux systems
Hurd and *BSD is not going to have FS_IOC_FIEMAP, at least not at
Linux's codepoint.

Addresses-Debian-Bug: #822576

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-05-10 23:44:21 -04:00
Theodore Ts'o aaa1ae0856 resize2fs, libext2fs: fix bugs in sparse_super2 support
Fix resize2fs so that the location of the backup superblocks when the
sparse_super2 feature is enabled is properly set when growing the file
system from a single block group to larger file system sizes.

Also fix a bug where the block group summary statistics in some cases
when exapnding a sparse_super2 file system.

Finally, accurately calculate the file system metadata overhead of the
last block group in sparse_super2 file systems.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-05-10 21:06:15 -04:00
Theodore Ts'o 97d7e2fdb2 libe2p: change the long flag name for -P to be Project_Hierarchy
This more clearly describes what the flag means.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-05-08 22:11:36 -04:00
Theodore Ts'o a195e862ca mke2fs: fix the parsing used for -E quotatype=usrquota:grpquota:prjquota
Commit 2d2d799c72 tried to use parse_quota_options(), which uses
commas to separate out the quota types.  Unfortunately, when parsing
extended options, commands are used to separate different extended
options.

To fix this, I've add a new support function parse_quota_type(), which
allows either commas or colons to used as a separator character, and
which manipulates a bit field to indicate which quota types should be
enabled.  Eventually tune2fs should be converted to use
parse_quota_type() as well, thus obsoleting parse_quota_options(), but
that's a more complicated cleanup patch for later.

Fix a lint warning which could the number of blocks to be incorretly
printed if it exceeds 2**32.

Also fix some typos and other minor bugs in the usage message.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-05-08 21:25:55 -04:00
Theodore Ts'o f08999053e Fix build failure if --config-jbd-debug isn't enabled
This fixes a bug that was introduced recently in commit 1fc23b5e77.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-04-17 00:23:48 -04:00
Theodore Ts'o 1fc23b5e77 Fix support for configure --enable-jbd-debug
We haven't used this in a while, so it's bitrotted a bit.  Fix it up
so that it works correctly.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-04-15 19:01:38 -04:00
Theodore Ts'o 0fad49b50d Fix missing prototype warnings caused by missing header files
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-26 23:18:34 -04:00
Marcus Huewe a7ac9c222d libext2fs: fix offset support in unix_io.c
Added offset support to the following functions:
- unix_cache_readahead
- unix_discard
- unix_zeroout

Signed-off-by: Marcus Huewe <suse-tux@gmx.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-26 22:26:02 -04:00
Jeff Sharkey 62bc8d19bd blkid: fix blkid time diff bug
When calculating time diffs, use difftime() instead of risking
integer overflow.  Also build a "blkid" binary.

Addresses-Google-Bug: #11175082
Change-Id: I23521f45204574bb32f152926401c2cbad93175b

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-25 12:07:48 -04:00
JP Abgrall 5efe492d19 llseek: setup the correct seek for ext2fs_llseek
After
  http://git.kernel.org/cgit/fs/ext2/e2fsprogs.git/commit/lib/ext2fs/llseek.c?id=274d46e1d35af423d0292d63c4d0ad7a03be82ba

with
  __linux__
  defined(HAVE_LSEEK64) && defined(HAVE_LSEEK64_PROTOTYPE)
  SIZEOF_OFF_T >= SIZEOF_LONG_LONG
it leads to ext2fs_llseek() doing a "return lseek(fd, offset, origin);"
Which  fails for offsets > 32bit.

Also, with
  __linux__
  !(defined(HAVE_LSEEK64) && defined(HAVE_LSEEK64_PROTOTYPE))
  defined(HAVE_LLSEEK)
  SIZEOF_OFF_T == SIZEOF_LONG_LONG
my_llseek is not defined at all. And there is no need to define
llseek as lseek, as llseek is never used.
Luckily ext2fs_llseek() then does "return lseek(...);"
It would seem that my_llseek should be used in both places.

Addresses-Google-Bug: #13340735
Change-Id: Ie7330300c9c1ca103eaaef97536dcf10adbbba02
Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-25 12:00:18 -04:00
Theodore Ts'o ca82d22bed Fix FreeBSD portability problems
FreeBSD doesn't have libintl support built into the libc, and
libsupport requires libintl support.  So we need to make sure it is
available when we link against the libsupport library.

Also, work around *BSD's interesting interpretation of how
_XOPEN_SOURCE is supposed to work.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-21 23:43:41 -04:00
Theodore Ts'o b42b7bae73 Merge branch 'maint' into next 2016-03-21 13:21:03 -04:00
Theodore Ts'o 8f6f8602dc libext2fs: make sure ismounted.c explicitly pulls in <sys/types.h>
The major() cpp macro is defined as requiring sys/types.h to be
included with _BSD_SOURCE defined.  However, in older glibc's this
hasn't been strictly required and the stdlib.h header file included
sys/types.h implicitly.  Fix this so that more aggressive
distributions run into build errors.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>

in with andchanges. Lines starting
2016-03-21 13:09:54 -04:00
Theodore Ts'o 31ddef52ba Fix warnings caused by glibc 2.20
Glibc has depcreated _SVID_SOURCE and _BSD_SOURCE in favor of
_DEFAULT_SOURCE.  So define _DEFAULT_SOURCE to shut up glibc 2.20

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-21 13:05:25 -04:00
Theodore Ts'o 37000b0245 libsupport: fix potential resource leaks in the profile code
These were found by Coverity.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-18 17:14:15 -04:00
Theodore Ts'o e1eee3e13e Android.mk: add missing source files from lib/e2p/Android.mk
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-18 16:24:53 -04:00
Theodore Ts'o a96aa32505 libsupport: fix function prototype for parse_quota_opts
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-18 16:11:53 -04:00
Theodore Ts'o f5b69d4ad1 Android.mk: fix up the library -host naming convention change
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-18 15:24:39 -04:00
Theodore Ts'o 82e48fb163 Fix various clang and gcc -Wall warnings
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-18 12:45:19 -04:00
Theodore Ts'o 17ea174a75 libext2fs: fix build failure in lib/ext2fs/swapfs on big-endian systems
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-17 22:39:10 -04:00
Theodore Ts'o e3760b72c6 Update lib/ext2fs/Makefile.in using "make depend"
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-15 01:50:40 -04:00
Alex Deymo 205593f65b Android.mk: Replace _host suffix with more standard -host suffix
Most libraries use the "-host" suffix when building for the host. This
patch renames all the libraries to use -host instead of _host.

Addresses-Google-Bug: #24619596
TEST=make dist

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-15 01:25:11 -04:00
James Hawkins 1598731833 libuuid: Silence warnings in lib/uuid when building on Android
-Wno-unused-function
-Wno-unused-parameter

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-14 19:04:48 -04:00
Mark Salyzyn cd26dc101c Android.mk: export uuid/uuid.h
Addresses-Google-Bug: #23181629
Addresses-Google-Bug: #24133481

Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-14 18:41:45 -04:00
Alex Deymo 5eeb0cca33 libext2fs: export the library include path
When adding 'libext2fs' as a library dependency from any other binary,
the binary needs to find the library headers. Users of this library
should not hard-code the include path themselves. This patch exports the
library headers on all three version of the libext2fs library and
removes the redundant include path from executables in e2fsprogs.

Addresses-Google-Bug: #23084776
TEST=mma

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-14 18:39:48 -04:00
Jeff Sharkey 7c33c8899f blkid: add support to recognize f2fs to blkid
We can now identify f2fs filesystems and extract the UUID.

Addresses-Google-Bug: #20275581

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-14 18:39:13 -04:00
Ying Wang d8d67ec7d9 Cleanup Obsolete LOCAL_PRELINK_MODULE
Addresses-Google-Bug: #18675947

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-14 18:38:43 -04:00
David Turner 082ed5dcd9 e2fsck: correct ext4 dates generated by old kernels
Older kernels on 64-bit machines would incorrectly encode pre-1970
ext4 dates as post-2311 dates.  Detect and correct this (assuming the
current date is before 2242).

Include tests for this, as well as changes to debugfs to correctly
set crtimes.

Signed-off-by: David Turner <novalis@novalis.org>
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-14 13:57:33 -04:00
Eric Sandeen f3745728bc resize2fs: clear uninit BG if allocating from new group
If resize2fs_get_alloc_block() allocates from a BLOCK_UNINIT group, we
need to make sure that the UNINIT flag is cleared on both file system
structures which are maintained by resize2fs.  This causes the
modified bitmaps to not get written out, which leads to post-resize2fs
e2fsck errors; used blocks in UNINIT groups, not marked in the block
bitmap.  This was seen on r_ext4_small_bg.

This patch uses clear_block_uninit() to clear the flag,
and my problem goes away.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-06 21:51:23 -05:00
Theodore Ts'o 6d4bb11487 Merge branch 'maint' into next 2016-03-06 21:30:07 -05:00
Andreas Dilger 539d3ae3da misc: replace comparison macros with inline functions
Replace the EXT2FS_RB_EMPTY_ROOT(), EXT2FS_RB_EMPTY_NODE(),
EXT2FS_RB_CLEAR_NODE(), IS_BLOCK_BM(), IS_INODE_BM(), and
IS_INODE_TB() macros with static inline functions to avoid
suprious compiler warnings with clang:

	pass1.c:618:28: warning: equality comparison with extraneous
		parentheses [-Wparentheses-equality]
	if ((*((__u32 *)(entry)) == 0UL)) {
             ~~~~~~~~~~~~~~~~~~~~^~~~~~
	pass1.c:618:28: note: remove extraneous parentheses
		around the comparison to silence this warning
	if ((*((__u32 *)(entry)) == 0UL)) {
				 ^~
	pass1.c:618:28: note: use '=' to turn this equality
		comparison into an assignment
	if ((*((__u32 *)(entry)) == 0UL)) {
				 ^~
				 =

The static inline functions should compile identically, and allow
some extra compile-time checking for the arguments over macros.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-06 21:23:40 -05:00
Theodore Ts'o dcb8e1fa04 Merge branch 'maint' into next 2016-03-06 20:37:49 -05:00
Darrick J. Wong ba380eea99 libext2fs: sort keys for xattr blocks
Richard Purdie reports that libext2fs doesn't sort attribute keys in
the xattr block correctly, causing the kernel to return -ENODATA when
querying attributes that should be there.  Therefore, sort attributes
so that whatever ends up in the xattr block is sorted according to
what the kernel expects.

Cc: Darren Hart <dvhart@linux.intel.com>
Reported-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Tested-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-06 20:08:53 -05:00
Darrick J. Wong 2b8772f522 tests: check proper operation of metadata_csum_seed
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-06 20:08:53 -05:00
Darrick J. Wong 2ed0adbce6 libext2fs: store checksum seed in superblock
Allow the filesystem to store the metadata checksum seed in the
superblock and add an incompat feature to say that we're using it.
This enables tune2fs to change the UUID on a mounted metadata_csum
FS without having to (racy!) rewrite all disk metadata.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-06 20:08:52 -05:00
Theodore Ts'o ccf028f2e7 libe2p: add missing f[gs]etproject.c files
Li Xi's patch was missing the sources for fgetproject.c and
fsetproject.c.  I've created replacement files which will service the
purpose.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-06 20:08:52 -05:00
Li Xi 3627e83830 Add project ID support for chattr/lsattr
Chattr and lsattr can be used to set or get project ID:
chattr -p <project id> file
lsattr -p file

Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-06 20:08:45 -05:00
Andreas Dilger 1e3f5c889d lsattr: treat inode generation as an unsigned int
The EXT2_GETVERSION ioctl is defined to take a "long" parameter, but
fgetversion() calls ioctl() with an "int" parameter instead.  This is
handled in the kernel correctly, but the generation is sign-extended
in fgetversion() before return on 64-bit systems and lsattr prints
it as a huge positive number for inode generation above 0x80000000:

        1635574212 -------------e-- /mnt/ost0/O/0/d0/12928
        18446744073045131735 -------------e-- /mnt/ost0/O/0/d0/166240
        782808861 -------------e-- /mnt/ost0/O/0/d0/31744
        18446744072181134840 -------------e-- /mnt/ost0/O/0/d0/135008

Correctly assign the returned generation number as an unsigned value,
and print it with a 10-character field width.  The version is printed
left-aligned for consistency with the old code and to ensure it is
always printed in the first column for use with tools like "cut":

        1635574212 -------------e-- /mnt/ost0/O/0/d0/12928
        3630547415 -------------e-- /mnt/ost0/O/0/d0/166240
        782808861  -------------e-- /mnt/ost0/O/0/d0/31744
        2766550520 -------------e-- /mnt/ost0/O/0/d0/135008

Do not return a random value from the stack as the version on error.
Clean up some style issues and consolidate some duplicate code.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-06 18:12:57 -05:00
Andreas Dilger 865dc0d753 blkid: fix ZFS device detection
While the main blkid functionality is in util-linux, there is still
use for blkid on non-Linux platforms.

Fix the ZFS device detection by looking at multiple uberblocks to
see if any are present, rather than looking for the ZFS boot block
which is not always present.

There are slots for up to 128 uberblocks, but the first 4 are not
written to disk on a newly-formatted filesystem, so check several
of them at different offsets within the uberblock array.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-06 18:11:47 -05:00
Li Xi e1cec4464b Add inherit flags for project quota
This patch add EXT4_PROJINHERIT_FL to enable inherit feature for
project ID. If an directory has its inherit flag set, all its
newly created children will inherit its project ID. Conversely,
new inodes will get a default project ID (i.e. zero). Also, no
hard link or rename is permitted if the directory and child has
different project ID.

Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-06 17:33:45 -05:00
Li Xi 080e09b46f Add project quota support
This patch adds project quota support. An new quota type PRJQUOTA(2)
is added. EXT4_PRJ_QUOTA_INO(11) is reserved for project quota inode.
The super block reservers an field s_prj_quota_inum for saving
project quota inode. And each inode adds an internal field i_projid
for saving its project ID.

Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-06 17:33:39 -05:00
Li Xi 0c18d0368a Add project feature flag EXT4_FEATURE_RO_COMPAT_PROJECT
This patch add project feature flag EXT4_FEATURE_RO_COMPAT_PROJECT.
Project feature is a read-only compat feature. Thus, an ext4 file
system with project feature enabled could only be read by ext4
kernel module without project feature support.

Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-06 15:56:28 -05:00
Li Xi 2d2d799c72 Clean up codes for adding new quota type
Project quota related fields are reserved in Linux kernel.
As a preparation for it, this patch cleans up quota codes
of e2fsprogs so as to make it easier to add new quota type(s).

Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-06 15:56:24 -05:00
Theodore Ts'o d030908bfc ext2fs: work around FreeBSD header breakage
FreeBSD 10.2 will blow up compiling its own header files in sys/file.h
if _XOPEN_SOURCE is defined.

In file included from tdb.c:59:
/usr/include/sys/file.h:209:2: error: unknown type name 'u_int'
        u_int   xf_flag;        /* flags (see fcntl.h) */
                ^
1 error generated.

This is despite the fact that POSIX.1 requires comforming applications
to define _XOPEN_SOURCE (to different numbers depending on the version
of POSIX.1 the program is expecting to work against).  See section
2.2.1 in POSIX.1 for chapter and verse.

Work around this by removing the _XOPEN_SOURCE declaration.  This will
cause compiler warnings (and will cause builds against some versions
of Solaris to break), so only do this for FreeBSD.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-01-01 20:12:22 -05:00
Theodore Ts'o 94676ef2b3 Merge branch 'maint' into next 2015-11-30 18:16:36 -05:00
Andreas Dilger e158db5377 libext2fs: fix block-mapped file punch
If ext2fs_punch() was called with "end = ~0ULL" to indicate truncate
to the end of file it tried to compute "count" for ext2fs_punch_ind()
based on "start" and "end", but incorrectly passed "count = ~0U" even
when "start" was non-zero, causing an overflow in some cases.

The calling convention for ext2fs_punch_ind() was also gratuitously
different from ext2fs_punch() and ext2fs_punch_extent(), passing
"count" instead of "end" as the last parameter.  Fix this by passing
it "end" like the other functions, and handle "count" internally.

Add checks to ext2fs_punch_ind() if "end" is at or beyond the 2^32
indirect block limit so the 32-bit internal variables don't overflow.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-11-30 15:26:21 -05:00
Andreas Dilger f449486d63 libext2fs: fix tst_badblocks buffer overrun
The test2[] array is not 0-terminated and the create_test_list() for
loop does not terminate properly at the end of this array, but
continues until it hits the 0 at the end of test3[].

Reported-by: Hanno Boeck <hanno@hboeck.de>
Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=104311
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-11-30 12:09:44 -05:00
Theodore Ts'o 188960ea4b debugfs: add support to properly set and display extended timestamps
This code is partially derived from patches from David Turner to allow
debugfs to properly support extended timestamps.

Cc: David Turner <novalis@novalis.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2015-11-30 11:42:00 -05:00
Darrick J. Wong 7dce0c06e5 libext2fs: fix parents when modifying extents
In ext2fs_extent_set_bmap() and ext2fs_punch_extent(), fix the parents
when altering either end of an extent so that the parent nodes reflect
the added mapping.

There's a slight complication to using fix_parents: if there are two
mappings to an lblk in the tree, the value of handle->path->curr can
point to either extent afterwards), which is documented in a comment.

Some additional color commentary from Darrick:

  In the _set_bmap() case, I noticed that the "remapping last block in
  extent" case would produce symptoms if we are trying to remap a
  block from "extent" to "next_extent", and the two extents are
  pointed to by different index nodes.  _extent_replace(...,
  next_extent) updates e_lblk in the leaf extent, but because there's
  no _extent_fix_parents() call, the index nodes never get updated.

  In the _punch_extent() case, we conclude that we need to split an
  extent into two pieces since we're punching out the middle.  If the
  extent is the last extent in the block, the second extent will be
  inserted into a new leaf node block.  Without _fix_parents(), the
  index node doesn't seem to get updated.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2015-11-16 06:08:17 -05:00