Commit Graph

4016 Commits (bbcd91bb0de943b364670373957a5658c4487692)

Author SHA1 Message Date
Theodore Ts'o 26c09eb814 e2fsck: check for zero length extent
If an extent has e_len set to zero, the kernel will oops with a
BUG_ON.  Unfortunately, e2fsck wasn't catching this case.  The kernel
needs to be fixed to notice this case and call ext4_error() instead of
failing an assertion check, but e2fsck should catch this case and
repair it (by deleting the errant extent).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-03-11 23:31:38 -04:00
Lukas Czerner c15386cdee e2fsck: do not discard itable if discard doen't zero data
We do not want to discard inode table if the underlying device does not
return zeros when reading non-provisioned blocks. The reason is that if
the inode table is not zeroed yet, then discard would not help us since
we would have to zero it anyway. In the case that inode table was
already zeroed, then the discard would cause subsequent reads to contain
non-deterministic data so we would not be able to assume that the inode
table was zeroed and we would need to zero it again, which does not
really make sense.

This commit adds check to prevent inode table from being discarded if
the discard does not zero data.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-03-11 15:38:40 -04:00
Lukas Czerner f0fe5daecd e2fsck: do not discard when in read only mode
When argument '-n' was specified and should run in read-only mode, we
should not attempt to discard anything. In order to do that we have to
check for E2F_OPT_NO flag and clear E2F_OPT_DISCARD flag if E2F_OPT_NO
is set.

This commit fixes the problem when we would mark inode tables as zeroed
(EXT2_BG_INODE_ZEROED) even when e2fsck is running in read-only mode. We
also move the check for E2F_OPT_NO so we can clear E2F_OPT_DISCARD as
early as possible.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-03-11 15:38:28 -04:00
Theodore Ts'o d2c9c42a0b e2fsck: optimize CPU usage in check_{block,inode}_bitmaps()
The boolean expression (!skip_group || csum_flag) is always true,
since if csum_flag is FALSE, skip_group must also be FALSE.  Hence, we
can just remove the expression from the conditional altogether, thus
simplifying the code and making it easier to read/understand.

Also, in the case where the bit is set in the bitmap, there's no point
repeatedly setting first_free to be ext2fs_block_count(fs->super).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-03-11 15:38:23 -04:00
Lukas Czerner deae60a087 e2fsck: do not forget to discard last block group
Previously when running e2fsck with '-E discard' argument the end of
the last group has not been discarded. This patch fixes it so we
always discard the end of the last group if needed.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-03-11 15:38:23 -04:00
Lukas Czerner 467953263e e2fsck: remove last argument from e2fsck_discard_blocks()
Simple code cleanup.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-03-11 15:38:23 -04:00
Lukas Czerner 57581c1064 e2fsck: discard only unused parts of inode table
When calling e2fsck with '-E discard' option it might happen that
valid inodes are discarded accidentally. This is because we just
discard the part of inode table which lies past the free inode count.
This is terribly wrong (sorry!).

This patch fixes it so only the free parts of an inode table
is discarded, leaving used inodes intact. This was tested with highly
fragmented inode tables with block size 4k and 1k.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reported-by: Phillip Susi <psusi@ubuntu.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-03-11 15:38:00 -04:00
Mike Frysinger 800766ee4a libext2fs: check for fallocate symbol before using it
If we have newer kernel headers which define FALLOC_FL_PUNCH_HOLE, but we
are on an older glibc which lacks fallocate, we end up trying to use the
func anyways.  Check the ifdef that autoconf already set up for us.

Reported-by: Ortwin Glueck <odi@odi.ch>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-03-06 20:21:39 -05:00
Mike Frysinger 677fc9169c configure: sort the lists for AC_CHECK_FUNCS and AC_CHECK_HEADERS
By using m4_flatten, should be easier to maintain these lists.

Regen configure and config.h.in after doing this.

(Modified by tytso to use m4_flatten for the list of header files
checked by AC_CHECK_HEADERS)

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-03-06 20:19:02 -05:00
Andreas Dilger 7270fbe7fa build: fix compile warnings on OSX
Clean up some compile warnings related to fstat64(), which is
verbosely deprecated on OSX.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-27 01:28:23 -05:00
Andreas Dilger 0df8a27bba libquota: don't include system quota.h header
Don't use the system <sys/quota.h> header in mkquota.c, since there
is a local e2fsprogs version of quota.h that is already included and
has the desired quota constants, and avoids symbol conflicts with the
system <sys/quota.h> on other platforms (in particular OSX).

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-27 01:28:23 -05:00
Mike Frysinger 997a0cf34e libext2fs: include config.h for HAVE_xxx defines
We check HAVE_UNISTD_H but haven't included config.h yet, so we end up
hitting warnings about missing prototypes for close/read/etc... funcs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-27 01:12:53 -05:00
Mike Frysinger b96365f8c2 libext2fs: include sys/time.h for gettimeofday()
Building on my glibc-2.15 system hits a warning:
	gen_bitmap64.c: In function 'ext2fs_alloc_generic_bmap':
	gen_bitmap64.c:127:2: warning: implicit declaration of function
		'gettimeofday' [-Wimplicit-function-declaration]

Include sys/time.h if it's available for the prototype.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-27 01:12:53 -05:00
Phillip Susi 6c9ce8a9b0 e2image: skip uninitialized bitmaps and inode tables
When the block bitmap is uninitialized, skip copying it.
When the inode bitmap is uninitialized, skip copying it,
as well as the inode table.  When there are unused inodes
towards the end of the table, skip those blocks too.

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-27 00:56:49 -05:00
Theodore Ts'o 30ac1ce7df mke2fs: make sure bg 0's unused inode count field is zero'ed for mke2fs -S
There was a bug/typo in commit ba9e0afc5 which caused the first block
group (bg #0) to not have its unused inode count field to get set to
zero in the case of mke2fs -S.  This caused inodes in the first block
group to not be recoverable via mke2fs -S.  Oops.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-27 00:51:39 -05:00
Theodore Ts'o d9a5d37535 libext2fs: support O_DIRECT functionality for Mac OS X
Darwin uses fcntl(fd, F_NOCACHE, 1) instead of the O_DIRECT flag.

Addresses-SourceForge-Bug: #3140289

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-20 20:45:52 -05:00
Theodore Ts'o 48b8910820 libext2fs: don't mark the superblock as dirty if the fs was opened r/o
If the file system is read/only opened with a backup superblock, and
the file system has uninit_bg enabled, the super block must not be
marked as dirty; otherwise, ext2fs_close() will call ext2fs_flush(),
which will fail, since the file descriptor for the block device was
opened read/only, and then the file descriptor won't actually be
closed.

This is normally not a problem since most of the time the program will
exit shortly after calling ext2fs_close(), and many programs don't
bother checking the error return from ext2fs_close(), especially if
the file system was opened read/only.

A big exception to this is e2fsck, since it opens and close the file
systems during its startup, and to make matters worse, registers an
error handler which will noisly complain about the failed writes
caused by ext2fs_flush().

Fix this by not marking the superblock as dirty if the file system was
opened read/only.  The changes to the block group descriptors to clear
the uninit bits will still happen, so that e2fsck -n will properly
scan the whole file system.  However, those changes will get dropped
when the file system handle is closed.

Addresses-SourceForge-Bug: #3444351

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-20 20:27:58 -05:00
Theodore Ts'o bbdb7a5f28 Update for Debian 1.42.1-2 release
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-20 19:41:17 -05:00
Theodore Ts'o ad880a0e2b e2fsck: check new sysfs interface to determine if we are on battery
...since the old way is deprecated.

Addresses-SourceForge-Bug: #3439277

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-20 19:10:19 -05:00
Theodore Ts'o 12b25067ab libquota: fix invalid return in non-void function
quota_inode_truncate() returns an errcode_t, not void.

Addresses-SourceForge-Bug: #3468423

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-20 18:24:31 -05:00
Theodore Ts'o 5d0e1f99bc debian: fix dpkg-buildflags so it works when the shell is dash
The buildd's use dash as the shell, so we can't use >& in the rules
file.  This was causing the buildd-built e2fsprogs binary packages to
be built without the hardening flags.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-20 18:18:13 -05:00
Theodore Ts'o f921eda1ab debian: build with V=1 for more information in buildd logs
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-20 18:17:37 -05:00
Theodore Ts'o 5ab3487232 Fix missing version.h update
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-17 22:58:30 -05:00
Theodore Ts'o 91b9eadeab Update for e2fsprogs 1.42.1 release
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-17 15:54:37 -05:00
Theodore Ts'o 70218a0381 Update e2fsprogs.pot file for translators
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-17 15:28:22 -05:00
Gran Uddeborg 0afb7fa595 po: update sv.po (from translationproject.org)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-17 15:28:22 -05:00
Jakub Bogusz 309b1c254b po: update pl.po (from translationproject.org)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-17 15:28:21 -05:00
Benno Schulenberg 561809aceb po: update nl.po (from translationproject.org)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-17 15:28:21 -05:00
Samuel Thibault 6369f689e8 po: update fr.po (from translationproject.org)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-17 15:28:21 -05:00
Petr Pisar b248a68aaf po: update cs.po (from translationproject.org)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-17 15:28:21 -05:00
Theodore Ts'o 4a4a44d7b1 badblocks: honor the -s option when in read-only -t mode
Addresses-Debian-Bug: #646629

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-17 15:28:21 -05:00
Theodore Ts'o 991211f676 libext2fs, libe2p: Reserve RO_COMPAT_REPLICA feature
The replica is a feature which stores multiple copies of the key
metadata blocks so a single block failure in failure-prone media
(read: certain types of flash storage) doesn't take out the entire
file system.

Discussion on the upstream list proved not to be very positive on this
feature; the arguments were that it added complexity that wasn't
warrented, since common practice in industry is to insist on reliable
media, and if media is unreliable, you're kind of toast anyway (unless
the file system is being used as the back-end store of a cluster file
system where checksuming and data replication is happening above the
local disk file system level).  So, this feature is being developed
out of tree.

We reserve the code points so that other people won't accidentally
step on them.  Since it's not upstream, it's a soft reservation, but
it's not like we have any shortage of RO_COMPAT features.  We are a
bit more tight on reserved inodes, but EXT2_BOOT_LOADER_INO and
EXT2_UNDEL_DIR_INO are not currently used anywhere, and
EXT2_EXCLUDE_INO is a reservation for another out-of-tree feature.
There are no features currently being discussed which require a
reserved inode, but if a need were to arise, we can claw back code
point reservations that were never used or not in tree, as those will
always be considered lower priority than in-tree features.

Cc: Aditya Kali <adityakali@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-17 15:28:21 -05:00
Darrick J. Wong 3ae682bb0a libext2fs: Add ext2fs_file_get_inode_num call (for fuse2fs)
Add a function to return the inode number of an open file.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-17 15:28:21 -05:00
Theodore Ts'o 50a676e944 e2image: attempt to use ftruncate64 to set i_size for raw images
If ftruncate64() exists, try to use it to set i_size.  This isn't
guaranteed to work, per SuSv3, but if it doesn't work, it's guaranteed
to return an error.  So for file systems and/or operating systems that
don't support extending i_size via ftruncate64(), fall back to writing
the trailing null.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-17 15:28:21 -05:00
Theodore Ts'o 2b7a30cc52 e2image: fix logic bug which could cause a raw image not to be extended
If the size of the last "hole" in the raw file was an exact multiple
of a megabyte, then we wouldn't write a null at the end of the file in
order to extend the size of the raw image to correspond with the file
system size.  Thanks to Lukas Czerner for suggesting the fix, and
Phillip Susi for pointing out the problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-17 15:28:20 -05:00
Theodore Ts'o ba9e0afc5a mke2fs: allow file systems w/ uninit_bg to be recovered with mke2fs -S
The command mke2fs -S is used as a last ditch recovery command to
write new superblock and block group descriptors, but _not_ to destroy
the inode table in hopes of recovering from a badly corrupted file
system.  If the uninit_bg feature is enabled, we need to make sure to
clear the unused inodes count field in the block group descriptors or
else e2fsck -fy will leave the file system completely empty.

Thanks to Akira Fujita for reporting this problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-17 15:28:20 -05:00
Theodore Ts'o 564826e284 util: add build.profiled to list of files/directories to ignore
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-17 15:28:12 -05:00
Jan Kara ba8bfa1a6d resize2fs: take s_first_data_block into account for resize2fs -M
calculate_minimum_resize_size() forgot to account s_first_data_block
into minimum filesystem size. Thus in case the size of filesystem was
such that the last group had the minimal size (50 blocks + metadata
overhead), the code in adjust_fs_info() decided the group is unneeded,
removed it, and in some cases the resizing then failed with ENOSPC.

Fix the issue by properly accounting for s_first_data_block in
calculate_minimum_resize_size().

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-17 14:32:18 -05:00
Theodore Ts'o 910fae94a5 debian: enable use of dpkg-buildflags if present
On newer Debian-based distributions, dpkg-buildflags should be called
by the debian rules file to get the appropriate values for CFLAGS,
LDFLAGS, etc.  This will also allow Debian to build with security
hardened build flags, which is a release goal for Debian Wheezy.

If dpkg-buildflags is not present, then use some safe defaults (what
is currently being set by dpkg-buildpackage in Ubuntu 10.04 LTS, which
is a common enough ancient distribution that many people might still
care about).

Addresses-Debian-Bug: #654457

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-17 14:32:18 -05:00
Theodore Ts'o a204236eaf libext2fs: fix BLOCK_ABORT handling in the block iterator for extents
When processing files that contain extents, the block iterator
functions were not properly handling the BLOCK_ABORT bit.  This could
cause problems such as ext2fs_link() adding a directory entry multiple
times.

Thanks to Darrick Wong <djwong@us.ibm.com> for reporting this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-17 14:32:17 -05:00
Darrick J. Wong 9e89dbbd46 libext2fs: when truncating file, punch out blocks at end
Currently, ext2fs_file_set_size2 punches out data blocks between the
end of the file and infinity when truncate_block <= old_truncate
(i.e. when you've made the file longer).  This is not a useful
behavior, particularly since it *fails* to punch out the data blocks
when the file is shortened (i.e. truncate_block < old_truncate).  This
seems to be the result of the test being backwards, so fix the code to
punch only when the file is getting shorter.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-17 14:32:10 -05:00
Eric Sandeen 237b7b23fe mke2fs: recognize mke4fs program name
We shipped "mke4fs" alongside mke2fs in RHEL5, so that ext4-capable
utilities could be installed without disturbing the venerable e2fsprogs-1.39
shipped in RHEL5 from the beginning.  But it surprised some users that
"mke4fs" created ext2 filesystems by default rather than ext4.
While it was my intent to have the renamed binaries behave exactly
like the stock ones, it seems that there is some precedence for
handling "mkeNfs" in the code, so seems reasonable to add
mke4fs -> ext4 as well.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-15 16:18:50 -05:00
Theodore Ts'o 8a1da3c5ae debugfs: use ss_safe_getenv() instead of getenv()
In the case where debugfs (or rdebugfs) is installed setgid disk, or
some such, we need to disable the use of environment variables for the
obvious reasons.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-15 16:18:29 -05:00
Andreas Dilger 454ac9d56a libext2fs: quiet spurious group checksum errors
If we have to read the backup group descriptor checksums, the UNINIT
flags are cleared to ensure that all of the inodes in the filesystem
are scanned.  However, the code that reset the UNINIT flags did not
reset the group checksum, and this produced many spurious error
messages in e2fsck.

Group descriptor 0 checksum is invalid.  FIXED.
Group descriptor 1 checksum is invalid.  FIXED.
:
:

Recompute checksums after modifying group descriptors to avoid these
error messages.  Remove expected error messages in f_illitable_flexbg.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-07 21:11:21 -05:00
Theodore Ts'o 40b9cc5173 e2fsck: allow the block bitmap to be uninit when the inode bitmap is in use
Removing this check will allow us to eventually eliminate code from
the kernel which forcibly initialized the block bitmap when the inode
bitmap is first used.  This would eliminate a required journal credit
and extra disk write.

Addresses-Google-Bug: #5944440

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-06 13:47:48 -05:00
Yongqiang Yang 8dbcbe1c4a mke2fs: correct help text for option -G of mke2fs
The option '-G' is used to pass number of groups in a flex_bg, the
previous help text - 'meta-group-size' - could confuse users with
meta_bg.

Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-01-23 11:46:43 -05:00
Theodore Ts'o 622cee8833 debugfs: fix spelling typo in ncheck
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-01-23 11:33:33 -05:00
Theodore Ts'o 8bf1e9184e debugfs: add ncheck -c option
Add a -c option to ncheck will verifies the file type information in
the directory entry.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-01-17 17:08:39 -05:00
Theodore Ts'o 1f572d1f88 libext2fs: display partial path if fs corrupted in ext2fs_get_pathname()
The function ext2fs_get_pathname() used to return EXT2_ET_NO_DIRECTORY
if one of the directories in an inode's pathname is not a directory.
This is not very useful in an emergency, when the file system is
corrupted.  This commit will cause ext2fs_get_pathname() to return a
partial pathname, which should help system administrators trying to
use debugfs to investigate a corrupted file system.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-01-17 15:38:31 -05:00
Theodore Ts'o 2b1cae7a26 debugfs: optimize ncheck and improve its error checking
Don't call ext2fs_get_pathname() for every single directory; instead,
only call it if we find a matching directory entry.  In addition, if
ext2fs_get_pathname() fails, print the number of the parent directory
in angle parents so the user gets some additional information.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-01-16 17:49:46 -05:00