If realloc() fails in path_append() we will lose a memory pointed to by
target->path. Fix it.
path_append() is used by mke2fs and e2fsdroid.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If we are using the system-provided blkid, check for the newer blkid
functions without adding -lblkid to @LIBS@. This prevents programs
(like badblocks) which don't use the blkid library getting linked
against it.
Addresses-Debian-Bug: #919958
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Do not use whole_static_libs and shared_libs at the same time. Fix
up clients.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Bug: 123590866
Test: mmma external/e2fsprogs
Change-Id: I36d184dd878de2beacbb17c306e47076b44d68bb
From AOSP commit: fece156b105719c782351e447298de073d4dab04
Methods returning 0 or -1 should not pass their return value to com_err.
Also, errno values should not be negated when passed to com_err or
through errcode_t.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Bug: N/A
Test: manual test
Change-Id: I5e25cf2deeee72668bf0ab58337ee582bf14bbc1
From AOSP commit: 0468e33fba75dbf60877ef14ecee7b0b60f756df
When copying large files into a ext filesystem at mkfs time the copy
fails at 2^31 bytes in. There are two problems:
copy_file_chunk() passes an offset (off_t, 64-bit typically) to
ext2fs_file_lseek() which expects a ext2_off_t (typedef to __u32) so
the value is truncated. Solve by calling ext2fs_file_llseek() which
takes a u64 offset instead.
try_lseek_copy() rounds the data and hole offsets as found by lseek()
to block boundaries, but the calculation gets truncated to 32-bits.
Solve by casting the 32-bit blocksize to off_t to ensure this doesn't
happen.
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
large_dir option allows to create directory with size > 2GB.
debugfs utility outputs negative size value for large directories
and ignores high part of directory size.
Fix debugfs to use high part of directory size in debugfs output
and use appropriate output format.
Signed-off-by: Artem Blagodarenko <artem.blagodarenko@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
After large_dir feature has been added, e2fsprogs is
ready for directories > 2GB, so we can remove e2fsck
directory size check.
Signed-off-by: Artem Blagodarenko <artem.blagodarenko@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
This fixes potential seg faults when opening a fuzzed file system with
block group descriptors containing a bogus inode table location.
Google-Bug-Id: 119929050
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
For certain sizes mke2fs's hugefile creation would fail with the error:
mke2fs: Could not allocate block in ext2 filesystem while creating huge file 0
This would happen because we had failed to reserve enough space for
the metadata blocks for the hugefile. There were two problems:
1) The overhead calculation function failed to take into account the
cluster size for bigalloc file systems.
2) In the case where num_blocks is 0 and num_files is 1, the overhead
calculation function was passed a size of 0, which caused the
calculated overhead to be zero.
Google-Bug-Id: 123239032
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If files are created while e4defrag is running, it's quite possible
for succeed_cnt to be larger than total_count, in which case the
number of failures (calculated via total_count - succeed_cnt) will
overflow and become a very large unsigned number.
The way we calculate statistics is a bit silly, since when recurse
into directories is counted, it's counted as a "failure". But we'll
ignore this from now, and avoid the unsigned overflow.
Address-Debian-Bug: #888899
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This reverts commit 3293ea9ecb.
This wasn't really the right fix, since there can't be more than 2**32
files in a file system. The real issue is when the number of files in
a directory change during the e4defrag run.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Even if the debugfs executable is not sparse, it might contain a 1k
aligned block which is all zeros, which when written into a 1k block
file system by a test like d_loaddump will result in a sparse file and
causing one or more test failures.
Google-Bug-Id: 122085761
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Port of commit 3271c69c97f486914fea833a36eaf5d86938c76d as applied to
e2fsck, but to tune2fs.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Bug: 112062612
Bug: 111302946
Test: $ m SANITIZE_HOST=address out/host/linux-x86/bin/tune2fs
$ out/host/linux-x86/bin/tune2fs --help
Change-Id: If49d367d96b7bfd0b8b79c6bde23c0ded52ca683
From AOSP commit: 1cb5de330e5d1e0c6f587945ec065b995cc1c84b
If e2fsck can optimize an inode's extent tree, it should ask for
permission to optimize it, not to "fix" it. This was causing some
confusion, since some users interpreted this prompt as an indication
that the file system was inconsistent.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Previously, setting the inode field was a no-op, since the library
function ext2fs_write_inode_full() would override whatever value was
set by debugfs. Use the new ext2fs_write_inode2() interface so we can
in fact set the checksum to a potentially wrong value. Also, ignore
the inode checksum failures if we are setting the checksum, and if the
checksum value is "calc", set the inode checksum to the correct value.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Add new library interface which allows the caller to control whether
the inode checksum should be checked on inode read, or set on inode
write.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Change a two-fonts macro to a one-font one, when there is only one
genuine argument.
Separate a punctuation mark or a section number from the only argument
to make two for a two-fonts macro.
Remove an unneeded escape in front of a horizontal tab character.
Correct the unit for distance from 'in' to 'i'.
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The mkutf8data program was written by SGI for the kernel. We integrate
it here, but it should be kept in sync with the kernel code, when
applicable. The header generated by this script is also included in
this repository, such that we don't have to carry the UCD files too.
They are only necessary when the header has to be recreated (for
instance, to update the Unicode version supported)
The mkutf8data is not a dependency of utf8data.h because we don't want
the utf8data.h rule to be called after a make clean that would remove
mkutf8data. It is simpler to call it from inside the rule, and make
sure we only trigger the utf8data.h rule if we really need to,
particularly if we decide not to integrate the ucd files in the tree.
The UCD files are not distributed along with this commit, but we add
information on how to fetch them.
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The commit 50d0998cfe ("libext2fs: add ea_inode support to set
xattr") broke the fix that was addressed in commit 0ee1eaf70c
("libext2fs: translate internal ext4 acl to Posix ACL in
ext2fs_xattr_[sg]et()"). This was because although we calculated what
the correct on-disk ACL representation would be, we didn't actually
*store* it, but instead stored the passed-in Posix ACL memory
representation instead.
Addresses-Launchpad-Bug: #1807288
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
We need this such that we can do normalization and casefolding
compatible with the kernel, in order to properly support fsck
verification and rehashing.
The UTF-8 11.0 implementation is copied and adapted from the kernel code
to ensure maximum compatibility. The decode trie in utf8data.h is
generated using a script and the UCD sources in the kernel code.
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The kernel will refuse to mount filesystems with the encryption and
encoding features enabled at the same time. The encoding feature can
only be set at mke2fs time, so we can just prevent encryption from being
set at a later time by tune2fs.
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Implement two parameters -e and -c, to specify encoding and casefold
when printing the hash of a given file.
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fsck must be aware of the superblock encoding and the casefold directory
setting, such that it is able to correctly calculate the dentry hashes.
[ Changed to use a stack-allocated buffer instead of a calling
calloc() with a fixed size -- TYT ]
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Basic NLS support is required in e2fsprogs because of fsck, which
needsto calculate dx hashes for encoding aware filesystems. this patch
implements this infrastructure as well as ascii support.
We don't need to do all the dance of versioning as we do in the kernel,
because we know before-hand which encodings and versions we
support (those we know how to store in the sb), so it is simpler just to
create static tables.
This version only has support for ASCII; we'll add support for Unicode
later.
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This flag can be set on directories to request insensitive file name
lookups.
I used the letter 'F', referring to "caseFold" for lack of a better
option.
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This patch implements two new extended options to mkefs, allowing the
user to specify an encoding for file name operations and encoding flags
during filesystem creation. We provide default flags for each encoding,
which the user can overwrite by passing -E fname_encoding-flags to mkfs.
If the user doesn't specify an encoding, the default value from
options.fname_encoding in mke2fs.conf.in file will be used.
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Implement helper functions to convert the encoding name and specific
parameters requested by the user on the command line into the format
that is written to disk.
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
In e2freefrag live scan mode, we take the free block count from the
ondisk superblock. This leads to screwy histogram percentages:
Extent Size Range : Free extents Free Blocks Percent
4M... 8M- : 5 8234 1.05%
64M... 128M- : 2 52279 6.64%
512M... 1024M- : 1 202752 25.74%
...because there could be superblock updates in the journal that haven't
yet been checkpointed. The online scan is perfectly capable of tallying
the free blocks on its own, so teach it do that and make a more accurate
report.
Reported-by: Elana Hashman <Elana.Hashman@twosigma.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If the file system only has the flex_bg feature enabled (with out the
metadata_csum feature enabled), it won't take a long time time fix up
the checksums after changing the UUID. While it does need to
recalculate all of the checksums in the block group descriptors, that
doesn't take a long time.
Also, if the ea_data feature is enabled, changing the UUID will also
take a long time, and we weren't warning the user about that case.
Fix up the warning message so it doesn't mislead people, and is more
accurate.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
$AWK doesn't use an explicit pathname, and it's perfectly fine to
assume that awk and sed are in the user's PATH. The problem with
using an explicit pathname is that Debian currently allows merged and
non-merged /usr. Avoid using an explicit pathname to prevent
potential problems.
Addresses-Debian-Bug: #914087
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
New superblock fields must be byte swapped before being accessed in Big
Endian machines.
Not tested on an actual BE machine.
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>