This is only an issue for programs compiled against e2fsprogs 1.41
that manipulate bitmaps directly. Fortunately there are very few
programs which do that, especially those that try to clear a bitmap.
Addresses-Sourceforge-Bugs: #3451486
Reported-by: robi6@users.sourceforge.net
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Optimize how the tdb library so that running with [scratch_files] in
/etc/e2fsck.conf is more efficient. Use a better hash function,
supplied by Rogier Wolff, and supply an estimate of the size of the
hash table to tdb_open instead of using the default (which is way too
small in most cases). Also, disable the tdb locking and fsync calls,
since it's not necessary for our use in this case (which is
essentially as cheap swap space; the tdb files do not contain
persistent data.)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Turns out the Hurd defines MS_SYNC but doesn't define msync(). Go
figure. So check for both.
Reported by Svante Signell.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
We need to do an accounting of duplicate clusters on a per-cluster
instead of a per-block basis so we know when we've correctly accounted
for all of the multiply claimed blocks in a particular inode.
Thanks to Robin Dong for reporting this bug.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
PATH_MAX is not portable (for example, it doesn't exist on the Hurd).
So replace it with a new define, which defines the maximum length of
the base quota name. As it turns out, this is substantially smaller
than PATH_MAX.
Also move the definitions relating to quotaio.c from mkquota.h to
quotaio.h, as a cleanup.
Addresses-Debian-Bug: #649689
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
When I create a non-extent file with the maximum size in ext4,
e2fsck detects the following error:
Pass 1: Checking inodes, blocks, and sizes
Inode 12, i_size is 4402345721856, should be 4402345721856. Fix?
As we know, e2fsck checks the size field of the inode in pass 1.
However, in case of the ext4 with the feature of ^extent and huge_file,
the maximum file size calculated in e2fsck is less than the real one.
The patch fixes this problem.
Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Linux's compat_sys_ioctl() function, which is run when executing a
ioctl using a 32-bit binary on a 64-bit kernel, returns EINVAL when an
inode does not exist. Sigh. See /usr/src/linux/fs/compat_ioctl.c.
This is probably a kernel bug, but work around it for now.
Addresses-Debian-Bug: #644989
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If we abort fsck (due to ENOMEM for example) we exit
with only the FSCK_ERROR flag. It seems useful
to do the same sorts of checks as we do on normal
exit, and return whether the filesystem was modified,
whether there are still uncorrected errors, etc, even
in the abort case.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The htree dump code overflows a char buffer if the directory has a long
filename because the buffer is not large enough to hold the characters that are
not part of the filename. Make the buffer larger and use snprintf instead.
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Define EXT2FS_MAX_NESTED_LINKS as 8, and check the link count to make
sure we don't exceed it in ext2fs_find_block_device() and
follow_link(). This fixes a potential infinite loop in
ext2fs_find_block_device() if there are symbolic loop links in the
device directory.
Signed-off-by: Niu Yawei <niu@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
A 32-bit s390 build was failing on a 64-bit s390x host, when
make check failed e2undo tests, like this:
md5sum before mke2fs 922c8a591c882dbdd1a381d18547cfd5
using mke2fs to test e2undo
Overwriting existing filesystem; this can be undone using the command:
e2undo /tmp/mke2fs-tmp.EM9XjmTA81.e2undo /tmp/tmp.EM9XjmTA81
md5sum after mke2fs cbf32fb6c3db45280ad013f42ac294f1
Replayed transaction of size 32768 at location 0
Replayed transaction of size 32768 at location 0
Replayed transaction of size 32768 at location 0
Replayed transaction of size 32768 at location 0
Replayed transaction of size 0 at location 0
md5sum after e2undo 31b4e14307c5b7ccce5b8d300c2ad5f1
Note the "at location 0" for the block number.
A proper cast in e2undo.c fixes this up.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
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>
Create a version of debugfs which only supports read-only examination
of the file system metadata (but not the data blocks). The idea is
that this version of debugfs might be suitable to be setuid root, and
executable only by members of a particular group, or setgid disk, and
globally executable, depending on the security/privacy policies in
force at a particular site.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
In quota_compute_usage(), the space usage should be in bytes but
not quota block.
Signed-off-by: Niu Yawei <niu@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
When turn on quota by tune2fs, if the old quota file exist, the quota
usage should be recomputed but the old limits should be preserved.
Signed-off-by: Niu Yawei <niu@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
mke2fs was creating both user and group quota inodes on enabling
the quota feature. This patch adds the extended option 'quotatype'
that can be used to exclusively specify the quota type that the
user wants to initialize.
# Ex: Default behavior without extended option creates both
# user and group quota inodes:
$ mke2fs -t ext4 -O quota /dev/ram1
# To enable only user quotas:
$ mke2fs -t ext4 -O quota -E quotatype=usr /dev/ram1
# To enable only group quotas:
$ mke2fs -t ext4 -O quota -E quotatype=grp /dev/ram1
Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
When turning on the quota feature, tune2fs would create empty quota inodes and
set their inode numbers in superblock. This required e2fsck to be ran before
using the quota feature. This patch adds adds call to compute_quota() and make
sure that we write correct quota information in the quota files at tune2fs time
itself. This gets rid of the necessity for running e2fsck after setting the
quota feature. Also, tune2fs now does not use existing old quota files
(aquota.user and aquota.group) even if they exist.
Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This patch cleans up the quota code as suggested in previous reviews. This
includes
* remove BUG_ON()s and 'exit()' calls from library code
* remove calls to malloc/free and instead use ext2fs_get/free_mem functions.
* lib/quota/common.c file in not needed anymore and is removed.
* rename exported functions to start with quota_
(ex: init_quota_context --> quota_init_context)
* better error handling in quota library
Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Quota support can be enabled using --enable-quota. There are still
some buglets that we need to fix up before it can be considered 100%
supported, so let's disable it for the 1.42 release.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
After:
# mke2fs -O ^has_journal,^resize_inode,^uninit_bg,extent,meta_bg,flex_bg,bigalloc /dev/sda
# e2freefrag /dev/sda
It will report error message like:
Illegal block number passed to ext2fs_test_block_bitmap #1732133 for block bitmap for /dev/sda
Illegal block number passed to ext2fs_test_block_bitmap #1732134 for block bitmap for /dev/sda
Illegal block number passed to ext2fs_test_block_bitmap #1732135 for block bitmap for /dev/sda
One bit in bitmap of bigalloc-ext4 means a cluster not a block,
therefore ext2fs_fast_test_block_bitmap2 should check cluster.
Signed-off-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Several of the mmp tests were failing on an s390 guest because
direct IO cannot be done on sub-sector sizes, and they were
doing 1k IOs to files on a 4k logical/physical device.
A few tests could just be changed to 4k, but others
needed fixed up output as well.
With this I have all tests passing on s390 again.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Without this change, we will write data past the end of the
mmp buf. Valgrind catches this:
==6373== Syscall param write(buf) points to unaddressable byte(s)
==6373== at 0x362260E470: __write_nocancel (in /lib64/libpthread-2.12.2.so)
==6373== by 0x41CF83: raw_write_blk (unix_io.c:255)
==6373== by 0x41D2BC: unix_write_blk64 (unix_io.c:757)
==6373== by 0x41A05D: ext2fs_mmp_write (mmp.c:130)
==6373== by 0x40B0C9: do_set_mmp_value (set_fields.c:806)
==6373== by 0x421B61: really_execute_command (execute_cmd.c:108)
==6373== by 0x421C54: ss_execute_line (execute_cmd.c:234)
==6373== by 0x403743: main (debugfs.c:2339)
==6373== Address 0x63f000 is not stack'd, malloc'd or (recently) free'd
and in my testing it led to silent failures while writing the mmp
block in debugfs:
write(3, "xV4\22PMM\342\325V\274N\0\0\0\0host.name."..., 4096) = -1 EFAULT (Bad address)
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Several small fixes:
* Gracefully fail mmp commands if fs is not open
* Show magic number in dump_mmp command
* Fix header in output for set_mmp_value -l
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Document the dump_mmp and set_mmp_value commands in
the debugfs manpage.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Commit 6b56f3d92d introduced the use of HAVE_STAT64 without arranging
that it be defined in configure.in. Previously ext4.h used
HAVE_OPEN64, but apparently there are (broken) platforms that have
open64() but not stat64(). Go figure.
We do need to consistently use a single test for ext2fs_stat(),
ext2fs_fstat(), and struct ext2fs_struct_stat, or we could end up
passing a struct stat64 to a fstat() system call, or some such. I've
elected to use HAVE_FSTAT64 because: (a) it's already defined in the
configure script, and (b) if we ever come across a really broken
platform that defines fstat64() but not stat64(), we can always
emulate stat64() using open64() followed by a fstat64().
This commit fixed a bug whose symptoms were that mke2fs would not work
if given a file > 2GB on 32-bit platforms.
Addresses-Debian-Bug: #647245
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Without this change, we go back to getting group descriptor
"0" each time we go around the "for i" loop. It must properly
advance through the filesystem.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit reverts commit aff534958b and transfers the
responsibility of rebuilding the .gmo files to the debian/rules file,
as updating the gmo files can cause problems for other distribution's
building systems. (We do this because we don't update the .gmo files
when doing a mid-release snapshot, since binary files can't be
represented in diff files. So we only update the .po files, and let
the package build process take care of the .gmo files.)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>