Theodore Ts'o [Tue, 10 Jun 2025 17:04:08 +0000 (13:04 -0400)]
debian: fix typo in fuse2fs.postrm which breaks a /usr-move mitigation
A space was accidenally introduced into the fuse2fs.postrm which
breaks the /usr-move replacement of fusext2 from an older legacy
package that had been abandoned upstream. Specifically, what was
broken was the cleanup of the protective diversions:
Theodore Ts'o [Fri, 6 Jun 2025 13:07:11 +0000 (09:07 -0400)]
libext2fs: fix a extent tree corruption bug in ext2fs_extent_set_bmap()
In the case where we are moving a particular logical block mapping
from a particular extent tree entry, to the immediately precending
entry (when the physical block or uninitialized flag is changing so it
can be coalesced with the precending entry) and the precending entry
is in a different extent tree block, the resulting extent tree can get
corrupted.
Fix this by removing the original logical block mapping before adding
the new logical block mapping. Per the warning in the comments before
ext2fs_extents_fix_parents():
Note a subtlety of this function -- if there happen to be two extents
mapping the same lblk and someone calls fix_parents on the second of
the two extents, the position of the extent handle after the call will
be the second extent if nothing happened, or the first extent if
something did. A caller in this situation must use
ext2fs_extent_goto() after calling this function. Or simply don't map
the same lblk with two extents, ever.
Theodore Ts'o [Tue, 3 Jun 2025 23:06:37 +0000 (23:06 +0000)]
debian: add a Built-Using field to the e2fsck-static package
We will probably want to eventually revert this commit and replace it
with a change using dh-builtusing, such as can be found in [1], but
dh-builtusing is only available in Debian 13 (trixie) and we don't
want to make life difficult for people who need to backport to Debian
Stable or Ubuntu LTS.
Theodore Ts'o [Mon, 26 May 2025 02:20:36 +0000 (22:20 -0400)]
e2fsck: fix e2fsck -E unshare_blocks when there are no shared blocks
If there are no shared blocks in a ext4 file system, e2fsck -E
unshare_blocks will not actually clear the shared_blocks feature flag
since e2fsck_pass1_dupblocks() is never called. Fix this by adding a
check in e2fsck_pass1() to clear the shared blocks flag.
Similar to 64-bit support, fs-verity support requires extents, so don't
allow to create a filesystem that has -O verity unless it also supports
extents.
Darrick J. Wong [Thu, 24 Apr 2025 21:44:25 +0000 (14:44 -0700)]
fuse2fs: disable renameat2
Apparently fuse munged rename and renameat2 together into the same
upcall, so we actually have to filter out nonzero flags because
otherwise we do a regular rename for a RENAME_EXCHANGE/WHITEOUT, which
is not what the user asked for.
Darrick J. Wong [Thu, 24 Apr 2025 21:42:52 +0000 (14:42 -0700)]
fuse2fs: clamp timestamps that are being written to disk
Clamp the timestamps that we write to disk to the minimum and maximum
values permitted given the ondisk format. This fixes y2038 support, as
tested by generic/402.
Darrick J. Wong [Thu, 24 Apr 2025 21:41:18 +0000 (14:41 -0700)]
fuse2fs: return -EOPNOTSUPP when we don't recognize a fallocate mode
If we don't recognize a set bit in the mode parameter to fallocate,
return EOPNOTSUPP to communicate that we don't support that mode instead
of EINVAL. This avoids unnecessary failures in generic/521 such as:
generic/521 - output mismatch (see /var/tmp/fstests/generic/521.out.bad)
--- tests/generic/521.out 2025-01-30 10:00:16.898276477 -0800
+++ /var/tmp/fstests/generic/521.out.bad 2025-04-03 14:46:20.019822396 -0700
@@ -1,2 +1,9 @@
QA output created by 521
+zero range: 0x407ca to 0x52885
+do_zero_range: fallocate: Invalid argument
Brian Foster [Thu, 23 Jan 2025 13:52:11 +0000 (08:52 -0500)]
debugfs: byteswap dirsearch dirent buf on big endian systems
fstests test ext4/048 fails on big endian systems due to broken
debugfs dirsearch functionality. On an s390x system and 4k block
size, the dirsearch command seems to hang indefinitely. On the same
system with a 1k block size, the command fails to locate an existing
entry and causes the test to fail due to unexpected results.
The cause of the dirsearch failure is lack of byte swapping of the
on-disk (little endian) dirent buffer before attempting to iterate
entries in the given block. This leads to garbage record and name
length values, for example. To resolve this problem, byte swap the
directory buffer on big endian systems.
Theodore Ts'o [Wed, 21 May 2025 02:53:41 +0000 (22:53 -0400)]
libext2fs: teach ext2fs_extent_set_bmap() to update extents more optimally
When programs like resize2fs or e2fsck relocates all of the blocks in
an extent one at a time, the ext2fs_extent_set_bmap() works by
initially adding a new extent and then moving mapping from the old
extent to the new extent. For example:
t=1 EXTENTS: (0-2) 1152-1154
t=2 EXTENTS: (0) 1136, (1-2) 1153-1154
t=3 EXTENTS: (0-1) 1136-1137, (2) 1154
Unfortunately, previously, when the last block is updated, the
resulting extent tree will have two extents instead of one, like this:
t=4 EXTENTS: (0-1) 1136-1137, (2) 1138
With this commit, the resulting extent tree will be more optimally
represented with a single extent:
t=4 EXTENTS: (0-2) 1136-1138
The optimization in this commit solves the prolem reproted at:
https://github.com/tytso/e2fsprogs/issues/146
In that case, the file had a very large, complex (fragmented) extent
tree, and resize2fs needed to relcate all of its blocks as part of a
off-line shrink, the lack of the optimization led to an extent block
overflowing, resulting in the old extent (the one which originally
mapped logical block 2507128 to physical block 389065080) and the new
extent landing in two different leaf blocks:
Theodore Ts'o [Sat, 22 Mar 2025 20:18:26 +0000 (16:18 -0400)]
test: fix expect files which changed after EA bugfix
The logic bug which was fixed in commit 92b6e93936d7 ("e2fsck: fix
logic bug when there are no references...") resulted in some silent
fixes that were never logged, and in some cases, corruption that was
not cleaned up. Fix the tests so that they pass as expected.
Fixes: 92b6e93936d7 ("e2fsck: fix logic bug when there are no references..." Signed-off-by: Theodore Ts'o <tytso@mit.edu>
(cherry picked from commit ddd4f796d9dfdb80e5639ca8411e8e4891d3c7f1)
Theodore Ts'o [Mon, 17 Mar 2025 14:38:44 +0000 (10:38 -0400)]
e2fsck: fix logic bug when there are no references to an EA inode
There was a boolean logic error which, among other things, could cause
an attempt to modify an inode in e2fsck -n mode:
e2fsck 1.47.2 (1-Jan-2025)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
ext2fs_write_inode: Attempt to write to filesystem opened read-only while writing inode 14 in pass4
e2fsck: aborted
Fixes: 849a9e6e133a ("e2fsck: add more checks for ea inode consistency") Signed-off-by: Theodore Ts'o <tytso@mit.edu>
(cherry picked from commit 92b6e93936d7a0f6d7ce7a9f142e2c0ee9afbeaf)
Theodore Ts'o [Wed, 1 Jan 2025 06:09:43 +0000 (01:09 -0500)]
po: update the binary gmo files
Also relax the msgfmt checking to avoid using --check-format, since
e2fsck's problem string's %-interpolation allows the ordering of
block, inode, etc. numbers to be moved around in translations. (And
the recent update to the Spanish po file takes advantage of this
feature.)
Theodore Ts'o [Mon, 16 Dec 2024 04:16:05 +0000 (23:16 -0500)]
debian: disable salsa CI on non-debian branches
The Salsa CI attempts to do a package build, and the debian/patches
directory is generally not set up correctly for a successful source
build on non-debian branches. So skip them to avoid failed builds and
to avoid wasting CI bandwidth.
Theodore Ts'o [Mon, 9 Dec 2024 22:19:26 +0000 (17:19 -0500)]
e2fsck: clear the orphan_file while processing it
Previously, we cleared the orphan file after pass 5. This was
unfortunate, because it means that the file system is left in a
corrupted state after running "e2fsck -E journal_only". By fixing
this, we can also remove a spurious "Orpan file... is not clean"
report from e2fsck.
Theodore Ts'o [Sun, 8 Dec 2024 04:31:43 +0000 (23:31 -0500)]
resize2fs: rewrite the checksums in the orphan file if necessary
The calculation of the metadata checksum located in each block of the
orphan file's inode includes the physical block number. So if any of
those blocks have been moved, the checksum needs to be updated.
The function ext2fs_orphan_file_block_csum_set() isn't used by
e2fsprogs, but it was embarassingly broken. Thanks to Darrick Wong
for pointing this out.
Fixes: 16534ff59444 ("e2fsck: fix big-endian support for orphan_file...") Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Theodore Ts'o [Thu, 5 Dec 2024 05:23:09 +0000 (00:23 -0500)]
dumpe2fs: add support for LABEL= and UUID= specifiers for the device
The e2mmpstatus man page claims that it will support LABEL= and UUID=
specifiers, and these days e2mmpstatus is implemented in terms of
dumpe2fs. So teach dumpe2fs to handle these specifiers so we can make
the e2mmpstatus man page be true.
Theodore Ts'o [Thu, 5 Dec 2024 01:25:32 +0000 (20:25 -0500)]
fix portability problem with uselocale(), et. al.
misc/create_inode_libarchive.c uses uselocale(), newlocale(), et. al.
These functions are defined in POSIX.1-2017, which isn't available
everywhere --- including MacOS and Windows.
We don't actually need to use these functions, since mke2fs already
calls setlocale() to initialize to use the default locale. So there
was no reason to set and restore the locale to use exactly the default
locale.
Fixes: ecfd4dd1217a ("Decouple --without-libarchive and HAVE_ARCHIVE_H") Fixes: 7e3a4f0a33e9 ("mke2fs: the -d option can now handle tarball input") Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Theodore Ts'o [Tue, 3 Dec 2024 23:23:51 +0000 (18:23 -0500)]
mke2fs: allow specifying the revision 1 via "-r 1"
The fsarchiver program unconditionally passes -r 1 even though it's
effectively a no-op. To avoid commit 3fffe9dd6be5 breaking
fsarchiver, we'll silently allow the "-r 1" option instead of printing
an error and exiting.
To aid bootstrapping, it would be useful to be able to build e2fsprogs
without archive.h as otherwise there is a build dependency loop with
libarchive. If archive.h is not present, add the missing forward
declarations (as opaque structs) and preprocessor definitions and
typedefs. Since this allows building e2fsprogs with libarchive support
even without the archive.h header present on the system, we cannot check
HAVE_ARCHIVE_H anymore to decide whether to build with libarchive
support or not. So if --without-libarchive is passed to ./configure,
CONFIG_DISABLE_LIBARCHIVE gets set and later checked to decide about
libarchive support.
наб [Thu, 28 Nov 2024 17:48:58 +0000 (12:48 -0500)]
debian: provide fuseext2 to replace src:fuse-umfuse-ext2
The fuse-umfuse-ext2 packaghas been abandoned by upstream, and a
follow-up fork at https://github.com/alperakcan/fuse-ext2 hasn't been
updated in five years. Both of these versions also warn against
mounting file systems read/write with fuse-ext2.
As proposed on debian-devel, let's replace fuse-umfuse-ext2 with a
compatibility shell script shipped with fuse2fs.
As a result `e2fsprogs` fails the build so only typedef int bool
for __STDC_VERSION__ <= 201710L (C17)
../../../lib/ext2fs/tdb.c:113:13: error: two or more data types in declaration specifiers
../../../lib/ext2fs/tdb.c:113:1: warning: useless type name in empty declaration
113 | typedef int bool;
| ^~~~~~~
Theodore Ts'o [Wed, 27 Nov 2024 18:03:38 +0000 (13:03 -0500)]
tune2fs: replace the -r option with -E revision=<fs-rev>
Revision 0 file systems are needed for compatibility with pre-1995
Linux kernels (older that version 1.2). Other for testing and
computer science archoelogy, there are no valid reasons for using this
feature. Revision 0 file systms do not support any file system
extensions beyond what was present in Linux 1.0 kernels, and only
support 128 byte inode sizes, which means that the file system will
only support file dates after the Unix epoch in 2038.
Users who use -r 0 are almost certainly doing so by mistake (for
example, perhaps they meant -m 0 but they typed -r 0 instead). As a
result they get a very badly cripped file system that won't support
SELinux, post-2038 dates, on-line resizing, etc. So remove the -r
option and replace it with the extended option "revision", to prevent
users from falling into this trap.
Theodore Ts'o [Tue, 26 Nov 2024 05:42:14 +0000 (00:42 -0500)]
tune2fs: update revision 0 file systems before changing the inode size
Revsion 0 file systems only support the fixed 128 byte inode size. So
before changing the inode size via tune2fs -I, we must first update
the file system to revision 1.
Jan Kara [Wed, 25 Sep 2024 17:19:26 +0000 (19:19 +0200)]
resize2fs: check number of group descriptors only if meta_bg is disabled
When meta_bg feature is enabled, the total number of group descriptors
is not really limiting the filesystem size. So there's no reason to
check it in that case. This allows resize2fs to resize filesystems past
256TB boundary similarly as the kernel can do it.
tests: new test to check that the orphan file is cleaned up
This test verifies that e2fsck clears the orphan file if it is present.
The filesystem was created by simply creating a bunch of empty files and,
while those files were open by an application, delete some of them in
order to add them to the orphan file. After this, the filesystem is
simply powered off. An e2fsck will need to clear the orphaned inodes but
also to clean the orphan file.
e2fsck: don't skip checks if the orphan file is present in the filesystem
If the filesystem supports the orphan file feature and that file is present
then don't skip the filesystem checks as that file may need to be cleaned
up.
Andreas Dilger [Wed, 5 Jun 2024 20:03:52 +0000 (14:03 -0600)]
tests: write f_badjour_encrypted output to log
Write the mke2fs and debugfs output from f_badjour_encrypted/script
into a log file instead of stdout/stderr, so that it doesn't mess
up the "make check" output, and is available if this test ever fails.
Darrick J. Wong [Wed, 29 May 2024 18:12:14 +0000 (11:12 -0700)]
fuse2fs: explicitly set _FILE_OFFSET_BITS again
In commit 3ab99d9b602, the build system was changed not to set
_FILE_OFFSET_BITS explicitly due to some weird error on mips64el.
Unfortunately, this breaks the aarch64 Debian build because libfuse
2.9.9 requires this value to be set explicitly. Restore this dumb
preprocessor symbol dependency with even more hackery as documented in
the commit.
Alyssa Ross [Mon, 27 May 2024 07:41:21 +0000 (09:41 +0200)]
configure: add SIZEOF_TIME_T to public_config.h
This has recently started being used by ext2fs.h. Other users of the
ext2fs.h header would always get the 32-bit versions of the
__encode_extra_time, __decode_extra_sec, and __sb_set_tstamp; and the
64-bit version of __sb_get_tstamp, due to the SIZEOF_TIME_T macro
being undefined and treated as zero.
Theodore Ts'o [Tue, 21 May 2024 02:52:47 +0000 (22:52 -0400)]
ext4.5: add preprocessor hint
This fixes a Lintian warning which is triggered by an arbtrary
MANROFFSEQ='' environment variable:
an.tmac:<standard input>:376: warning: tbl preprocessor failed, or it or soelim was not run; table(s) likely not rendered (TE macro called with TW register undefined)
Jiyong Park [Wed, 1 May 2024 07:17:36 +0000 (16:17 +0900)]
AOSP: Use no_full_install: true instead of installable: false
So far, we have used `instalable: false` to avoid collision with the
other modules that are installed to the same path. A typical example was
<foo> and <foo>.microdroid. The latter is a modified version of the
former for the inclusion of the microdroid image. They however both have
the same instalation path (ex: system/bin) and stem (ex: foo) so that we
can reference them using the same path regardless of whether we are in
Android or microdroid.
However, the use of `installable: false` for the purpose is actually
incorrect, because `installable: false` also means, obviously, "this
module shouldn't be installed". The only reason this incorrect way has
worked is simply because packaging modules (ex: android_filesystem)
didn't respect the property when gathering the modules.
As packaging modules are now fixed to respect `installable: false`, we
need a correct way of avoiding the collision. `no_full_install: true` is
it.
If a module has this property set to true, it is never installed to the
full instal path like out/target/product/<partition>/... It can be
installed only via packaging modules.