Commit Graph

4263 Commits (70f4632b626e3db94dd02c9dc9b4e643ffb0d048)

Author SHA1 Message Date
Jan Kara 70f4632b62 libext2fs: provide functions to safely access name_len and file_type
Accessing name_len (and file_type) in ext4_dir_entry structure is
somewhat problematic because on big endian architecture we need to now
whether we are really dealing with ext4_dir_entry (which has u16
name_len which needs byte swapping) or ext4_dir_entry_2 (which has u8
name_len which must not be byte swapped).

Currently the code is somewhat surprising and name_len is always
treated as u16 and byte swapped (flag EXT2_DIRBLOCK_V2_STRUCT isn't
ever used) and then masking of name_len is used to access real
name_len or file_type. Doing things this way in applications using
libext2fs is unexpected to say the least (more natural is to type
struct ext4_dir_entry * to struct ext4_dir_entry_2 * but that gives
wrong results on big endian architectures. So provide helper functions
that give endian-safe access to these fields. Also convert users in
e2fsprogs to use these functions.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-06-08 17:03:05 -04:00
Darrick J. Wong bd78b1dae9 e2fsck: fix journal block tag checksum verification
Al Viro complained of a ton of bogosity with regards to the jbd2 block tag
header checksum.  This one checksum is 16 bits, so cut off the upper 16 bits
and treat it as a 16-bit value and don't mess around with be32* conversions.
Fortunately metadata checksumming is still "experimental" and not in a shipping
e2fsprogs, so there should be few users affected by this.

This is the e2fsprogs version of the kernel patch.

Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-06-08 17:03:04 -04:00
Theodore Ts'o e07b71f294 Merge branch 'maint' 2013-06-08 17:02:54 -04:00
Theodore Ts'o e2e389a1d5 tests: add new test f_extent_oobounds
This tests creates a file system where the last entry in one leaf
block overlaps with logical block range in the first entry of the next
leaf block.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-06-06 23:53:31 -04:00
David Jeffery d3f32c2db8 e2fsck: detect invalid extents at the end of an extent-block
e2fsck does not detect extents which are outside their location in the
extent tree.  This can result in a bad extent at the end of an extent-block
not being detected.

From a part of a dump_extents output:

 1/ 2  37/ 68 143960 - 146679 123826181               2720
 2/ 2   1/  2 143960 - 146679 123785816 - 123788535   2720
 2/ 2   2/  2 146680 - 147583 123788536 - 123789439    904 Uninit <-bad extent
 1/ 2  38/ 68 146680 - 149391 123826182               2712
 2/ 2   1/  2 146680 - 147583     18486 -     19389    904
 2/ 2   2/  2 147584 - 149391 123789440 - 123791247   1808

e2fsck does not detect this bad extent which both overlaps another, valid
extent, and is invalid by being beyond the end of the extent above it in
the tree.

This patch modifies e2fsck to detect this invalid extent and remove it.

Signed-off-by: David Jeffery <djeffery@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
2013-06-06 22:53:31 -04:00
Theodore Ts'o 4cf7a7014a misc: fix gcc -Wall nits
[For 1.43 branch]

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-05-20 09:21:34 -04:00
Theodore Ts'o fd9ca82599 e2fsck: fix gcc -Wall nits
[For 1.43 branch]

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-05-20 09:17:02 -04:00
Theodore Ts'o 894eaf8506 libext2fs: fix gcc -Wall nits
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-05-19 22:12:36 -04:00
Theodore Ts'o 581ecb6d88 Merge branch 'maint' into next
Conflicts:
	e2fsck/pass1b.c
	e2fsck/rehash.c
	lib/ext2fs/crc32c.c
	lib/ext2fs/gen_bitmap64.c
	misc/tune2fs.c
2013-05-19 21:45:16 -04:00
Theodore Ts'o 68477355a9 e2fsck: fix gcc -Wall nits
Perhaps the most serious fix up is a type-punning warning which could
result in miscompilation with overly enthusiastic compilers.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-05-19 21:36:31 -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
Theodore Ts'o e48bf256e9 libext2fs: fix gcc -Wall warnings
Primarily signed vs unsigned and const warnings.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-05-19 18:50:10 -04:00
Theodore Ts'o 29f6dfea52 Merge branch 'maint' into next 2013-05-16 11:05:37 -04:00
Theodore Ts'o 25399080c5 chattr: clarify that the compression flags are not supported by ext4
... or indeed by any mainline kernel, since the compression patches
were never stablized.

Addresses-Debian-Bug: #707609

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reported-by: "Creidieki M. Crouch" <creidieki@gmail.com>
2013-05-13 09:10:16 -04:00
Theodore Ts'o 26991d026e e2fsck: don't use IO_FLAG_EXCLUSIVE for read-only root file systems
When opening the external journal, use the same logic to decide
whether or not to open the file system with EXT2_FLAG_EXCLUSIVE found
in main().

Otherwise, it's not posible to use e2fsck when the root file system is
using an external journal.

Reported-by: Calvin Owens <jcalvinowens@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-05-04 19:07:18 -04:00
Theodore Ts'o cc68e8a69a configure: update configure script to be in sync with the configure.in file
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-05-04 19:01:09 -04:00
Theodore Ts'o 5dfd5ef88d tests: add new test f_zero_xattr
E2fsck previously was complaining with zero-length extended attributes
if they appeared in the in-inode xattr space.  Test to make sure
e2fsck is now happy with such xattrs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-04-25 00:29:09 -04:00
Eric Sandeen 10fc3a63d9 e2fsprogs: allow 0-length xattr values in e2fsck
e2fsck thinks that this:

# touch mnt/testfile1
# setfattr -n "user.test" mnt/testfile1

results in a filesystem with corruption:

Pass 1: Checking inodes, blocks, and sizes
Extended attribute in inode 12 has a value size (0) which is invalid
Clear? yes

but as far as I can tell, there is absolutely nothing wrong with
a 0-length value on an extended attribute.  Just remove the check.

Reported-by: David Shaw <dshaw@jabberwocky.com>
Reported-by: Harald Reindl <h.reindl@thelounge.net>
Addresses-Red-Hat-Bugzilla: #557959
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-04-25 00:14:33 -04:00
Theodore Ts'o 07bcd90f3d Merge branch 'maint' into next 2013-04-22 00:07:08 -04:00
Theodore Ts'o 9bd95a472c crcsum: remove the -b option since ext2fs_crc32c_be is dropped in 1.43.x
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-04-22 00:04:36 -04:00
Theodore Ts'o 572ef60b89 libext2fs: only use override function when reading an 128 byte inode
The ext2fs_read_inode_full() function should not use fs->read_inode()
if the caller has requested more than the base 128 byte inode
structure and the inode size is greater than 128 bytes.  Otherwise the
caller won't get all of the bytes that they were asking for, since
there's no way for the fs->read_inode override function can know what
the size of the buffer passed to ext2fs_read_inode_full().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-04-21 23:53:26 -04:00
Tomas Racek 8034d9fa0f e2image: fix flag settings in e2image.h
This prevents from SIGSEGV when -s options is used.

Signed-off-by: Tomas Racek <tracek@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
2013-04-21 23:49:04 -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 ef21356fc0 e2image: man: fix typo
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
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
Akira Fujita fab0d286ec tune2fs: disallow tune2fs to set inode size larger than block size
Disallow tune2fs command to set the inode size to be larger than the
block size.  Without this patch, tune2fs makes the file system to be
unmountable.

Steps to reproduce:

1.Create ext4 without flex_bg (or just create ext3)
  # mke2fs -t ext4 -O ^flex_bg DEV

2.Set inode size larger than block size
  # tune2fs -I 8192 DEV

3. We failed to mount FS
  # mount DEV MP
    mount: wrong fs type, bad option, bad superblock on /dev/sda7,
           missing codepage or helper program, or other error
           In some cases useful info is found in syslog - try
           dmesg | tail  or so

Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-04-21 23:14:28 -04:00
Theodore Ts'o e79a9395b3 tests: add more tests for off-line resizing
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-03-31 20:41:23 -04:00
Theodore Ts'o 28e6662403 tests: create crcsum progam to support resizing tests
The only checksum program which we can reliably count upon being
installed on all systems is "sum", which is not a particular robust
checksum.  The problem with using md5sum or sha1sum is it hat it may
not be installed on all systems.  So create a crcsum program which is
used so we can validate that a data file on a resized file system has
not been corrupted.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-03-31 20:41:23 -04:00
Theodore Ts'o 447da244eb mke2fs: don't display bigalloc/quota fs feature warnings in quiet mode
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-03-31 20:41:22 -04:00
Theodore Ts'o f026f1a370 resize2fs: fix off-line resize of file systems with flex_bg && !resize_inode
When doing an off-line resize2fs of an initially very small file
system, it's possible to run out of reserved gdt blocks (which are
reserved via the resize inode).  Once we run out, we need to move the
allocation bitmaps and inode table out of the way to grow the gdt
blocks.  Unfortunately, when moving these metadata blocks, it was
possible that a block that had been just been newly allocated for a
new block group could also get allocated for a metadata block for an
existing block group that was being moved.

To prevent this, after we grow the gdt blocks and allocate the
metadata blocks for the new block groups, make sure all of these
blocks are marked as reserved.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reported-by: John Jolly <john.jolly@gmail.com>
2013-03-31 20:40:57 -04:00
Theodore Ts'o 8c236c62c9 Merge branch 'maint' into next 2013-03-13 16:17:34 -04:00
Theodore Ts'o 871ad94264 blkid: remove no-op statement which caused a clang warning
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-03-13 14:34:08 -04:00
Theodore Ts'o 16b1fcf87d debugfs: fix command failures for extent_inode commands that take arguments
The extent_inode commands split_node, replace_node, and insert_node
take arguments which resulted in confusing error messages after
succeeding.  Fix this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-03-13 14:19:16 -04:00
Theodore Ts'o d3f58ef166 e2fsck: fix build failure with --enable-jbd-debug
Commit e3507739e4 introduced a build failure if e2fsprogs is
configured with --enable-jbd-debug.  Fix this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-03-13 14:02:53 -04:00
Jan Kara 5084088215 libext2fs: Provide prototype for ext2fs_symlink()
New function ext2fs_symlink() doesn't have a prototype in ext2fs.h and
thus debugfs compilation gives warning:

debugfs.c:2219:2: warning: implicit declaration of function 'ext2fs_symlink'

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-02-28 20:12:30 -05:00
Jan Kara 9e20cf223a e2p: Fix 's' handling in parse_num_blocks2()
parse_num_blocks2() wrongly did:
	num << 1;
when log_block_size < 0. That is obviously wrong as such statement has
no effect (and the compiler properly warns about it). Callers expect
returned value to be in bytes when log_block_size < 0 so fix the
statement accordingly.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-02-28 20:12:30 -05:00
Theodore Ts'o bb21ddf596 chattr: allow clearing the extent flag
In order to support kernels which support conversion of extent-mapped
files to direct/indirect mapped files, remove the sanity check which
prevented clearing the extent flag in chattr.  Kernels which don't
support this will simply give an Operation Not Supported error.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-02-22 22:23:05 -05:00
Theodore Ts'o 7c1384c324 debugfs: add sanity check to make sure we never shift 64 bits right
In the tables which are used to parse the fields for the set_fields
command, there should never be a entry which has a size set to 8
bytes, and two pointers defined.  Not only would it result in
undefined behavior in the compiled code, it doesn't make any sense and
is definitely a bug.

Reported-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-28 09:06:23 -05:00
Philipp Thomas 1bdc4f306a po: update de.po (from translationproject.org)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-01-27 22:44:56 -05:00
Philipp Thomas 0d89e5acea Fix warnings about functions not returning a value
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-27 22:41:50 -05:00
Andreas Dilger 1b8c4c1b45 build: quiet build warnings for "gcc -Wall"
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-27 22:31:03 -05:00
Andreas Dilger b55705e0ba build: quiet build warnings for "gcc -Wall"
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-27 22:29:01 -05:00
Zheng Liu dc18a3b305 contrib: add missing '-p' to fallocate's usage message
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-24 23:27:30 -05:00
Phillip Susi 274d46e1d3 libext2fs: fix ext2fs_llseek on i386
ext2fs_llseek() was using lseek instead of lseek64.  The
only time it would use lseek64 is if passed an offset that
overflowed 32 bits.  This works for SEEK_SET, but not
SEEK_CUR, which can apply a small offset to move the file
pointer past the 32 bit limit.

The code has been changed to instead try lseek64 first, and
fall back to lseek if that fails.  It also was doing a
runtime check of the size of off_t.  This has been moved to
compile time.

This fixes a problem which would cause e2image when built for
x86-32 to bomb out when used with large file systems.

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-24 23:04:01 -05:00
Theodore Ts'o fca8b1b241 Merge branch 'maint' into next
Conflicts:
	RELEASE-NOTES
	version.h
2013-01-21 22:06:16 -05:00
Theodore Ts'o 511ba985c0 Update Release Notes, Changelogs, version.h, for final 1.42.7 release
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-21 22:03:18 -05:00
Theodore Ts'o a713a7fe5a mke2fs, tune2fs, resize2fs: add warning messages for bigalloc and quota
The bigalloc and quota features have some known issues, so issue
warnings in case users try to use them.

More information can be found here:
	https://ext4.wiki.kernel.org/index.php/Bigalloc
	https://ext4.wiki.kernel.org/index.php/Quota

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-21 19:07:38 -05:00
Theodore Ts'o c64929d9c3 contrib: fix namespace leakage in spd_readdir
Declare the internal symbols alloc_dirstruct() and cache_dirstruct()
as static so they don't leak out into the global namespace.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-21 17:19:50 -05:00
Theodore Ts'o 0b64f50f71 contrib: add thread locking and readdir64_r support to spd_readdir
This is part of a series of improvements from a 2008 version of
spd_readdir.c that somehow didn't make it into the version which we
checked into e2fsprogs git tree.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-21 17:15:25 -05:00
Theodore Ts'o 635c7a57c0 contrib: add safe_getenv() support to spd_readdir
This is part of a series of improvements from a 2008 version of
spd_readdir.c that somehow didn't make it into the version which we
checked into e2fsprogs git tree.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-21 16:35:16 -05:00