In flush_l2_cache() we are using ext2fs_llseek() however we do not
properly detect the error code returned from the function, because we
are assigning it into ULL variable, hence we will not see negative
values.
Fix this by changing the type of the variable to ext2_loff_t which is
signed and hence will store negative values.
We are doing ext2fs_flush() twice right now at the end of the mke2fs.
First by directly calling ext2fs_flush() which is intended to write
superblock and fs accounting information. And then it is invoked again
when we are calling ext2fs_close(), only this time, because the fs is
not dirty, we are writing out only superblock.
I think it is bad to call it twice because even when writing only super
block it takes some time on bigger file systems and moreover
ext2fs_close() can fail without any reasonable explanation for the user.
Also ext2fs_flush() is printing out progress and it is confusing for the
users.
Fix all this by removing the ext2fs_flush() and leaving it all to
ext2fs_close(). However we need to introduce new variables to store
check interval and max mount count, because fs structure is freed on
ext2fs_close() and we really want to print those information as the last
info for the user.
[ Fixed type mismatch in a printf format statement -tytso]
Since e2image can be optionally compiled out, we tested to see if
e2image was built; but using "test -x $E2IMAGE" fails if e2image is
something like "valgrind --simhints=lax-ioctls ../misc/e2image".
Define and use $E2IMAGE_EXE, much like we have done with e2undo and
resize2fs.
Aditya Kali [Wed, 20 Jul 2011 18:40:05 +0000 (11:40 -0700)]
tune2fs: Add support for turning on quota feature
This patch adds support for setting the quota feature in superblock
and allows selectively creating quota inodes (user or group or both)
in the superblock. Currently, modifying the quota feature is only
supported when the filesystem is unmounted.
Also, when setting the quota feature, tune2fs will use aquota.user or
aquota.group file inode number in superblock if these files exist.
Otherwise it will initialize empty quota inodes #3 and #4 and use them.
Here is how it works:
# Set quota feature and initialize both (user and group) quota inodes
$ tune2fs -O quota /dev/ram1
# Enable only one type of quota
$ tune2fs -Q usrquota /dev/ram1
Aditya Kali [Wed, 20 Jul 2011 18:40:04 +0000 (11:40 -0700)]
mke2fs: support creation of filesystem with quota feature
mke2fs also creates quota inodes (userquota: inode# 3 and
groupquota: inode #4) inodes while creating a filesystem when 'quota'
feature is set.
# To set quota feature and initialize quota inodes during mke2fs:
$mke2fs -t ext4 -O quota /dev/ram1
Signed-off-by: Aditya Kali <adityakali@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Aditya Kali [Wed, 20 Jul 2011 18:40:06 +0000 (11:40 -0700)]
e2fsck: add support for checking the built-in quota files
This patch adds support for doing quota accounting during full
e2fsck scan if the 'quota' feature was set on the superblock.
If user-visible quota inodes are in use, they will be hidden
and converted to the reserved quota inodes.
Signed-off-by: Aditya Kali <adityakali@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Aditya Kali [Wed, 20 Jul 2011 18:40:02 +0000 (11:40 -0700)]
e2fsprogs: add quota library to e2fsprogs
This patch adds the quota library (ported form Jan Kara's quota-tools) in
e2fsprogs in order to make quotas as a first class supported feature in Ext4.
This patch also provides interface in lib/quota/mkquota.h that will be used by
mke2fs, tune2fs, e2fsck, etc. to initialize and update quota files.
This first version of the quota library does not support reading existing quota
files. This support will be added in the near future.
Thanks to Jan Kara for his work on quota-tools. Most of the files in this patch
are taken as-is from quota tools and were simply modified to work with
libext2fs in e2fsprogs.
Signed-off-by: Aditya Kali <adityakali@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Theodore Ts'o [Wed, 31 Aug 2011 18:27:21 +0000 (14:27 -0400)]
libext2fs: fix binary search for the icount and badblocks stores
Remove the interpolation because there is a bug in icount which can
cause a core dump if calculated range gets turned into a NaN and then
do an out-of-bounds array access. We could fix this with some more
tests, but the complexity is such that nuking all of the interpolation
code will be faster than fixing the interpolation.
Eric Sandeen [Wed, 10 Aug 2011 19:07:41 +0000 (14:07 -0500)]
libext2fs: copy cluster_bits in ext2fs_copy_generic_bmap
The f_lotsbad regression test was failing on some systems
with:
Restarting e2fsck from the beginning...
Pass 1: Checking inodes, blocks, and sizes
+Illegal block number passed to ext2fs_test_block_bitmap #0 for in-use block map
Pass 2: Checking directory structure
Entry 'termcap' in / (2) has deleted/unused inode 12. Clear? yes
Running with valgrind (./test_script --valgrind f_lotsbad) we
see:
+==31409== Conditional jump or move depends on uninitialised value(s)
+==31409== at 0x42927A: ext2fs_test_generic_bmap (gen_bitmap64.c:378)
among others.
Looking at gen_bitmap64.c:
376: arg >>= bitmap->cluster_bits;
377:
378: if ((arg < bitmap->start) || (arg > bitmap->end)) {
A little more debugging showed that it was actually
bitmap->cluster_bits which was uninitialized, because it never
gets copied over in ext2fs_copy_generic_bmap()
Patch below resolves the issue.
Reported-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Mon, 18 Jul 2011 03:13:47 +0000 (23:13 -0400)]
mke2fs: document stripe_width, not stripe-width
For consistency with other multi-word options, document the extended
option stripe_width instead of stripe-width. This also avoids the
complexity of parsing options that have an embedded '-'.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck: teach e2fsck how to deal with bigalloc in non-extent-mapped inodes
Currently the bigalloc implementation in the kernel requires extents,
but this restriction might get relaxed in the future. Also, old
versions of mke2fs that supported bigalloc during early testing
created the root and lost+found directories without using
extent-mapped inodes. This makes it possible for e2fsck to better
support these old legacy file systems if it comes across them.
libext2fs: fix block iterator when the callback function modifies an extent
If the callback interator modifies a block in the middle of an extent
during a call to the block iterator, causing the extent to be split,
ext2_block_iterate3() will end up calling the callback function twice
for some number of blocks. Fix this.
libext2fs: teach ext2fs_block_alloc_stats2() about bigalloc
Change ext2fs_block_alloc_stats2() so that when a cluster is
allocated, the free blocks counter in the superblock is appropriately
decremented by the cluster size.
libext2fs: replace missing flexbg initialization in flexbg_offset
Commit 25567a7b0fa9 accidentally removed the initialization for flexbg
and flexbg_size, which affected ext2fs_allocate_group_table() and
ext2fs_allocate_tables(). Replace them.
e2fsck, libext2fs: support for bigalloc file systems with a blocksize of 1024
Filesystems with a blocksize of 1024 have the superblock starting at
block #1. However, the first data block in the superblock is 0 to
simplify the cluster calculations. So we must compensate for this in
a number of places, mostly in the ext2fs library, but also in e2fsck.
mke2fs: allow setting the stride and stripe width to zero
Mke2fs previously would give an error if the user tried setting the
stride and stripe-width parameters to zero; but this is necessary to
override the stride and stripe-width settings which get automatically
set from the block device's geometry information in sysfs. So allow
setting these parameters to zero.
The extended options parsing for mount_opts was horribly buggy.
Invalid mount options that had an argument would get interpreted as an
extended mount options. Fix this.
tune2fs: allow setting the stride and stripe width to zero
Tune2fs previously would give an error if the user tried setting the
stride and stripe-width parameters to zero; but this is necessary to
disable the stride and stripe-width settings. So allow setting these
superblock fields to zero.
Disable the compression flag, and enable symlinks for the install
(this is the same as previous debian packages; debian recommends
against using hard links across different directories)
Theodore Ts'o [Mon, 20 Jun 2011 01:58:20 +0000 (21:58 -0400)]
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.
Theodore Ts'o [Thu, 16 Jun 2011 05:13:42 +0000 (01:13 -0400)]
e2fsck: fix mysterious "FILE SYSTEM WAS MODIFIED" with no changes
Commit 2a77a784a3 (firest released in e2fsprogs 1.33) compared
superblock summary free blocks and inode counts with the allocation
bitmap counts before starting the file system check proper, and if
they differed, set the superblock and marked it as dirty. If no other
file systme changes were required, this would cause a "*** FILE SYSTEM
WAS MODIFIED ***" message without any explanation of what e2fsck had
changed.
We fix this by only setting the superblock summary free block/inodes
counts if we are skipping a full check, and in non-preen mode, e2fsck
will now print an explicit message stating how the superblock had been
updated.
In a full check, any updates to the superblock free blocks/inodes
fields will be noted in pass5.
This change requires changing a few test results (essentially
reversing the changes made in commit 2a77a784a3).
Andreas Dilger [Thu, 16 Jun 2011 02:17:38 +0000 (22:17 -0400)]
check: build all dependencies before "make check"
If "make check" is run on a clean repository, it fails due to missing
dependencies for building the test programs. Have "make check" build
all dependencies before starting the tests to ensure that it can finish
without error.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Theodore Ts'o [Thu, 16 Jun 2011 02:11:59 +0000 (22:11 -0400)]
libext2fs: fix regression in ext2fs_new_block2() for uninit_bg file systems
Commit b0ecb787ef introduced a bug in check_block_uninit(), which is
used by ext2fs_new_block2(). This bug resulted in the block bitmap
for the block group in question not having space reserved for the file
system metadata blocks.
Andreas Dilger [Sat, 11 Jun 2011 16:51:44 +0000 (12:51 -0400)]
e2fsprogs: ignore generated files for "git status"
Ignore files generated by "make" or "make check" in "git status".
Ignore backup files from editing files and generated tags files.
Delete a temporary file in tests/d_loaddump/script at test cleanup.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Sat, 11 Jun 2011 16:51:21 +0000 (12:51 -0400)]
ext2fs: fix error handling in ext2fs_add_dir_block
In ext2fs_add_dir_block() the dblist allocation size was changed to
grow as the number of items in the dblist increases. However, the
error handling in case of allocation failure wasn't changed to match.
Fix the error case to revert to the old allocation size on failure.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Sat, 11 Jun 2011 16:22:36 +0000 (12:22 -0400)]
mke2fs: add extent-mapped journal regression test
All of the regression tests in e2fsprogs still use a block-mapped
journal (if any journal at all). Add a simple regression test that
tests extent-mapped journals for both mke2fs and e2fsck.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Sat, 11 Jun 2011 16:17:29 +0000 (12:17 -0400)]
mke2fs: add test for large journal with lazy init
Add test for internal journal over 4GB in size, using the
lazy_journal_init and lazy_itable_init features. Otherwise
the filesystem metadata would be too large to reliably run on
test systems, and take too long to create/check the filesystem.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Sat, 11 Jun 2011 16:17:29 +0000 (12:17 -0400)]
mke2fs: skip zeroing journal blocks
Add the ability to skip zeroing journal blocks on disk. This can
significantly speed up mke2fs with large journals. At worst the
uninitialized journal is only a very short-term risk (if at all),
because the journal will be overwritten on any new filesystem as
soon as any significant amount of data is written to disk, and
the new journal TID would need to match the offset/TID of an old
commit block still left on disk.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Sat, 11 Jun 2011 16:17:29 +0000 (12:17 -0400)]
ext2fs: Handle internal journal over 2^32 bytes
The write_journal_inode() code is only setting the low 32-bit i_size
for the journal size, even though it is possible to specify a journal
up to 10M blocks in size. Trying to create a journal larger than 2GB
will succeed, but an immediate e2fsck would fail. Store i_size_high
for the journal inode when creating it, and load it upon access.
Use s_jnl_blocks[15] to store the journal i_size_high backup. This
field is currently unused, as EXT2_N_BLOCKS is 15, so it is using
s_jnl_blocks[0..14], and i_size is in s_jnl_blocks[16].
Rename the "size" argument "num_blocks" for the journal creation functions
to clarify this parameter is in units of filesystem blocks and not bytes.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Sat, 11 Jun 2011 15:50:01 +0000 (11:50 -0400)]
ext2fs: don't use O_DIRECT if not available
O_DIRECT is not defined on OSX. Since direct IO is only a new
optimization and not needed for correct functionality, disable
it if O_DIRECT is unavailable.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Sat, 11 Jun 2011 15:50:01 +0000 (11:50 -0400)]
misc: fix compile warnings on OSX
The BLKFLSBUF and FDFLUSH ioctls are Linux specific, and do not
really have anything to do with __GNUC__ (which is also used on
OS/X and Solaris). Only print these warnings on Linux systems.
statfs64() is deprecated on OSX and generates a deliberate warning.
Fix some other warnings that show up on OSX builds.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Sat, 11 Jun 2011 15:33:02 +0000 (11:33 -0400)]
ext2fs: fix ext2fs_warn_bitmap32() return warning
This was reported as "control reaches end of non-void function",
but comparing to other similar functions it should be a void
function. Since it is only declared in the "private" ext2fsP.h
header, it should be OK to change the function prototype.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Sat, 11 Jun 2011 15:29:54 +0000 (11:29 -0400)]
debugfs: fix icheck finding blocks used for xattrs
This was an "uninitialized variable" warning, but it turns out to be
a real bug. Without this change, it is not possible to use "icheck"
to find blocks that are used for the i_file_acl (xattr) block.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Sat, 11 Jun 2011 15:04:42 +0000 (11:04 -0400)]
ext2fs: fix undeclared posix_memalign() warning
Older distros do not define posix_memalign() by default in the
headers. If ext2fs.h is included early in the headers, it is
possible to "#define _XOPEN_SOURCE 600" so that the stdlib.h
header will define it, but if ext2fs.h is included after stdlib.h
there is no posix_memalign() declaration.
Add a posix_memalign() declaration if stdlib.h didn't do it. This
is a bit of a hack for GNU headers, but it works on Linux and OS/X
without problems.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Theodore Ts'o [Fri, 10 Jun 2011 22:51:58 +0000 (18:51 -0400)]
libext2fs: teach block allocation functions about bigalloc/clusters
Optimize ext2fs_new_block2() and ext2fs_get_free_blocks2() when
bigalloc is enabled. Also fix the uninitialized block bitmap code so
that it correctly deals clustered allocation.
Theodore Ts'o [Fri, 10 Jun 2011 21:55:09 +0000 (17:55 -0400)]
libext2fs: teach bitmap functions about bigalloc/cluster
This patch makes the following changes:
* ext2fs_allocate_block_bitmap() now allocates a bitmap with cluster
granularity for bigalloc file systems. For mke2fs and e2fsck, a
newly added function, ext2fs_allocate_subcluster_bitmap() allocates
a bitmap with block granularity (even for bigalloc file systems).
The newly added function ext2fs_get_bitmap_granularity() will return
the number of bits (log2) of the granularity used by the bitmap.
* The ext2fs_{mark,unmark,test}_block_bitmap2() functions will shift
their passed-in argument by log2(cluster_ganularity) bits right.
This means that the arguments for the single-argument bitmap
functions will be interpreted with block granluarity, since this
minimizes code changes in the rest of the code base.
* The ext2fs_{get,set}_block_bitmap_range() functions will interpret
their arguments in cluster granularity. This is a bit inconsistent,
but the caller of those functions will need to be taught about the
subtleties of clusters for bigalloc file systems.
Andreas Dilger [Tue, 7 Jun 2011 16:22:29 +0000 (10:22 -0600)]
mke2fs: Don't erase flash device if "-n" is given
If "mke2fs -n" is used, there should be no changes to the underlying
device. Unfortunately, when the "discard" option was added in commit c7cd908be59f48c66b4f3ac9a631ffe3dde4f1ab, it did not check for the "-n"
flag, and will discard all data on a flash device even if "-n" is given.
Check for the "noaction" flag before discarding any filesystem data.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Theodore Ts'o [Sat, 4 Jun 2011 14:20:47 +0000 (10:20 -0400)]
libext2fs: change fs->clustersize to fs->cluster_ratio_bits
The log2 of the ratio of cluster size to block size is far more useful
than just storing the cluster size. So make this change, and then
define basic utility macros: EXT2FS_CLUSTER_RATIO(),
EXT2FS_CLUSTER_MASK(), EXT2FS_B2C(), EXT2FS_C2B(), and
EXT2FS_NUM_B2C().
Theodore Ts'o [Sat, 4 Jun 2011 20:40:26 +0000 (16:40 -0400)]
libext2fs: change EXT2_MAX_BLOCKS_PER_GROUP() to be cluster size aware
Change the EXT2_MAX_BLOCKS_PER_GROUP so that it takes the cluster size
into account. This way we can open bigalloc file systems without
ext2fs_open() thinking that they are corrupt.
Theodore Ts'o [Sat, 4 Jun 2011 20:36:19 +0000 (16:36 -0400)]
libext2fs: require cluster size == block_size when opening a !bigalloc fs
In ext2fs_open() check to make sure the cluster size superblock field
is the same as the block size field when the bigalloc feature is not
set. This is necessary since we will start introducing calculations
based on the cluster size field.
Eric Sandeen [Tue, 31 May 2011 23:59:56 +0000 (19:59 -0400)]
e2fsck: don't check/clone duplicate xattr blocks in fs without xattr feature
I had an extremely corrupted customer filesystem which, after thousands
of lines of e2fsck output, found one more problem on an immediately
subsequent e2fsck. In short, a file had had its i_file_acl block
cloned due to being a duplicate. That ultimately got cleared
because the fs did not have the xattr feature, and the inode
was subsequently removed due to invalid mode.
The 2nd e2fsck pass found the cloned xattr block as in use, but
not owned by any file, and had to fix up the block bitmaps.
Simply skipping the processing of duplicate xattr blocks on a
non-xattr filesystem seems reasonable, since they will be cleared
later in any case.
(also fix existing brace misalignment)
Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsprogs: Unify the upper limit of reserved blocks count
In e2fsprogs, the upper limit of reserved blocks count is a half of
filesystem's blocks count. This patch fixes the incorrect checks of
reserved blocks count.
Eric Sandeen [Mon, 4 Apr 2011 19:11:52 +0000 (15:11 -0400)]
mke2fs: don't set stripe/stride to 1 block
Block devices may set minimum or optimal IO hints equal to
blocksize; in this case there is really nothing for ext4
to do with this information (i.e. search for a block-aligned
allocation?) so don't set fs geometry with single-block
values.
Zeev also reported that with a block-sized stripe, the
ext4 allocator spends time spinning in ext4_mb_scan_aligned(),
oddly enough.
Lukas Czerner [Wed, 18 May 2011 11:36:55 +0000 (13:36 +0200)]
tests: New i_e2image test to validate image creation/conversion
This commit adds new regression test called i_e2image which should
validate expected behaviour of e2image raw and qcow2 image creation
and qcow2 -> raw image conversion. You can run it with "make check" as
the rest of regression tests.
Testing is performed on three filesystem images with different block
sizes (1024, 2048, 4096). It creates raw and qcow2 images from the
original and then convert qcow2 image back to raw image. The results are
checksummed and compared with pre-prepared results. All md5sums should
stay the same and raw image created from original and qcow2 image should
be the same as well (just for the record).
Lukas Czerner [Wed, 18 May 2011 12:20:47 +0000 (14:20 +0200)]
e2image: Support for conversion QCOW2 image into raw
This commit adds support for converting QCOW2 image created previously
with e2image into raw image. The QCOW2 image is detected automatically,
so there is not new option. Just use following command:
e2image -r image.qcow image.raw
No that this tool is aimed to quickly convert qcow2 image created with
e2image into raw image. In order to improve speed we are doing some
assumption I believe might not be true for regular qcow2 images. So it
was not tested with regular QCOW2 images and it might not work with
them. The intention of this tool is only convert images previously
created by e2image.
Note that there is nothing special with QCOW2 images created by e2images
and it can be used with tools like qemu-img, or qemu-nbd without any
problems.
Lukas Czerner [Wed, 18 May 2011 11:36:53 +0000 (13:36 +0200)]
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.
Lukas Czerner [Wed, 18 May 2011 12:19:52 +0000 (14:19 +0200)]
e2fsprogs: Add memory allocation and zero-out helpers
Add functions ext2fs_get_memzero() which will malloc() the memory
using ext2fs_get_mem(), but it will zero the allocated memory afterwards
with memset().
Add function ext2fs_get_arrayzero() which will use calloc() for
allocating and zero-out the array.
Aditya Kali [Tue, 10 May 2011 21:51:31 +0000 (14:51 -0700)]
mke2fs: Allow specifying reserved_ratio via mke2fs.conf
This patch adds support for specifying 'reserved_ratio' (percent blocks
reserved for super user, same as '-m' command line option) in mke2fs.conf.
It adds profile_get_double function in profile.c that allows reading
floating point values from profile files.
Signed-off-by: Aditya Kali <adityakali@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
It will cause segfault, but it is caused by another issue. See my
patch "mke2fs: Avoid segmentation fault in
ext2fs_alloc_generic_bmap". And with that patch, the mkfs.ext4 will
fail with the error: /dev/sdb3: Memory allocation failed while setting
up superblock
The reason is that in ext2fs_initialize, we align s_inodes_per_group
to 8, but fails to consider the case that s_inodes_per_group < 8.
So make at least 8 inodes for s_inodes_per_group.
Signed-off-by: Tao Ma <boyu.mt@taobao.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Lukas Czerner [Mon, 21 Mar 2011 10:14:00 +0000 (11:14 +0100)]
e2fsprogs: fix memory leak in ext2fs_free_generic_bmap()
In ext2fs_free_generic_bmap() when we are freeing 64-bit bitmap, we do
call free_bmap() to free backend specific bitmap structures, however we
should also free ext2fs_generic_bitmap structure as well.
Lukas Czerner [Mon, 21 Mar 2011 10:13:41 +0000 (11:13 +0100)]
e2fsprogs: fix freeing bitmap in allocation error path
In ext2fs_alloc_generic_bmap() error path, when new bitmap allocation
fails ext2fs_generic_bitmap should be freed, however in current state it
first frees ext2fs_generic_bitmap and then
ext2fs_generic_bitmap->description which is wrong. This commit fix the
free ordering.
Theodore Ts'o [Sun, 8 May 2011 03:14:06 +0000 (23:14 -0400)]
e2fsck: make the "fs is mounted; continue?" prompt more paranoid
A user received the "file system is mounted; do you really want to
continue" prompt, and then instead of typing "n" for no, forgot that
he hadn't declined to continuation question, and typed the up-arrow
key, which in his locale, the 'A' in "^[[A" was interpreted as "yes",
and he lost data.
This was clearly the user's fault, but to make e2fsck a bit safer
against user stupidity/carelessness, we will change the "fs is
mounted; continue?" prompt to default to no, and treat the escape
character (along with the return and space characters, currently) as a
request for the default answer.
Eric Sandeen [Thu, 5 May 2011 18:21:08 +0000 (13:21 -0500)]
filefrag: count 0 extents properly when verbose
/boot/a: 0 extents found
works properly, but
Filesystem type is: ef53
Filesystem cylinder groups is approximately 61
File size of a is 0 (0 blocks, blocksize 1024)
ext logical physical expected length flags
a: 1 extent found
yields 1 extent when it should be 0.
Fix this up by special-casing no extents returned in verbose
mode; skip printing the header for the columns too, since there
are no columns to print.
Also, in nonverbose mode we can set fm_extent_count to 0
so that FIEMAP will just query the extent count without gathering
details; clarify this with a comment.
Addresses-RedHat-Bugzilla: 653234 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>