]> git.ipfire.org Git - thirdparty/e2fsprogs.git/log
thirdparty/e2fsprogs.git
4 hours agofuse2fs: fix block parameter truncation on 32-bit maint master next
Darrick J. Wong [Wed, 30 Jul 2025 17:23:24 +0000 (10:23 -0700)] 
fuse2fs: fix block parameter truncation on 32-bit

Use the blk64_t variants of the io channel read/write methods when we
have to do partial block zeroing for hole punching because otherwise
we corrupt large 64-bit filesystems on 32-bit fuse2fs due to integer
truncation.

Cc: linux-ext4@vger.kernel.org # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20250730172324.GR2672022@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 hours agofuse2fs: fix punching post-EOF blocks during truncate
Darrick J. Wong [Sat, 26 Jul 2025 16:28:48 +0000 (09:28 -0700)] 
fuse2fs: fix punching post-EOF blocks during truncate

ext2fs_punch() can update the inode that's passed in, so we need to
write it back.  This should fix some fstests failures where the test
file system ends up with inodes where all extent records fit within the
inode but inexplicably have extents beyond EOF.  While we're at it, add
the fuse2fs prefix to the two helper functions.

Cc: linux-ext4@vger.kernel.org # v1.47.3
Fixes: 4581ac60eb53ec ("fuse2fs: fix post-EOF preallocation clearing on truncation")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20250726162848.GQ2672022@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 hours agofuse2fs: don't record every errno in the superblock as an fs failure
Darrick J. Wong [Fri, 25 Jul 2025 15:56:10 +0000 (08:56 -0700)] 
fuse2fs: don't record every errno in the superblock as an fs failure

fstests just blew up because somewhere in the fuse iomap code we
returned an ESTALE, which was then passed to translate_error.  That
function decided it was a Serious Error and wrote it to the superblock,
so every subsequent mount attempt failed.

I should go figure out why the iomap cache upsert operation returned
ESTALE, but that's not a sign that the *ondisk* filesystem is corrupt.
Prior to commit 71f046a788adba we wouldn't have written that to the
superblock either.

Fix this by isolating the handful of errno that usually mean corruption
problems in filesystems and writing those to the superblock; the other
errno are merely operational errors that can be passed back to the
kernel and up to userspace.

I'm not sure why e2fsck doesn't flag when s_error_count > 0.  That might
be an error on its own.

Cc: linux-ext4@vger.kernel.org # v1.47.3
Fixes: 71f046a788adba ("fuse2fs: correctly handle system errno values in __translate_error()")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20250725155610.GP2672022@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 hours agofuse2fs: fix logging redirection
Darrick J. Wong [Tue, 22 Jul 2025 19:40:53 +0000 (12:40 -0700)] 
fuse2fs: fix logging redirection

Someone pointed out that you can't just go around reassigning stdout and
stderr because section 7.23.1 paragraph 4 of a recent C2y draft says
that stdin, stdout, and stderr “are expressions of type "pointer to
FILE" that point to the FILE objects associated, respectively, with the
standard error, input, and output streams.”

The use of the word "expression" should have been the warning sign that
a symbol that can be mostly used as a pointer is not simply a pointer.

Seven pages later, footnote 318 of the C2y draft clarifies that stdin,
stdout, and stderr “need not be modifiable lvalues to which the value
returned by the fopen function could be assigned.”

"need not be" is the magic phrasing that means that glibc, musl, and
mingw (for example) have very different declarations of stdout:

glibc:
extern FILE *stdout;           /* Standard output stream.  */

musl:
extern FILE *const stdout;

mingw:
#define stdout (&_iob[STDOUT_FILENO])

All three are following the specification, yet you can write C code that
fails to compile what otherwise looks like a normal assignment on two of
the libraries:

static FILE *const fark; /* musl */

FILE crap[3]; /* mingw */
#define crows (&crap[0])

static FILE *stupid; /* glibc */

int main(int argc, char *argv[])
{
fark = NULL;
crows = NULL;
stupid = NULL;
}

/tmp/a.c: In function ‘main’:
/tmp/a.c:20:14: error: assignment of read-only variable ‘fark’
   20 |         fark = NULL;
      |              ^
/tmp/a.c:21:15: error: lvalue required as left operand of assignment
   21 |         crows = NULL;
      |               ^

What a useless specification!  You don't even get the same error!
Unfortunately, this leadership vacuum means that each implementation of
a so-called standard C library is perfectly within its right to do this.
IOWs, the authors decided that every C programmer must divert some of
the brainpower they could spend on their program's core algorithms to be
really smart about this quirk.

A whole committee of very smart programmers collectively decided this
was a good way to run things decades ago so that C library authors in
the 1980s wouldn't have to change their code, and subsequent gatherings
have reaffirmed this "practical" decision.  Their suggestion to reassign
stdout and stderr is to use freopen, but that walks the specified path,
which is racy if you want both streams to point to the same file.  You
could pass /dev/fd/XX to solve the race, but then you lose portability.

In other words, they "engineered" an incomplete solution with problems
to achieve a short term goal that nobody should care about 40 years
later.

Fix fuse2fs by rearranging the code to change STD{OUT,ERR}_FILENO to
point to the same open logfile via dup2 and then try to use freopen on
/dev/fd/XX to capture any stdout/err usage by the libraries that fuse2fs
depends on.

Note that we must do the whole thing over again in op_init because
libfuse will dup2 STD{OUT,ERR}_FILE to /dev/null as part of daemonizing
the server.

Cc: linux-ext4@vger.kernel.org # v1.47.3
Fixes: 5cdebf3eebc22c ("fuse2fs: stop aliasing stderr with ff->err_fp")
Link: https://github.com/tytso/e2fsprogs/issues/235
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20250722194053.GO2672022@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 hours agofuse2fs: fix punch-out range calculation in fuse2fs_punch_range
Darrick J. Wong [Thu, 31 Jul 2025 14:45:50 +0000 (10:45 -0400)] 
fuse2fs: fix punch-out range calculation in fuse2fs_punch_range

In non-iomap mode, generic/008 tries to fzero the first byte of a block
and instead zeroes the entire file:

--- a/tests/generic/008.out      2025-07-15 14:45:14.937058680 -0700
+++ b/tests/generic/008.out.bad        2025-07-16 13:31:03.909315508 -0700
@@ -4,10 +4,7 @@
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 wrote 1024/1024 bytes at offset 1024
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-00000000:  00 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41  .AAAAAAAAAAAAAAA
-00000010:  41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41  AAAAAAAAAAAAAAAA
-*
-00000400:  42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42  BBBBBBBBBBBBBBBB
+00000000:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
 *
 read 2048/2048 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)

Looking at the fuse2fs debugging output, the reason why is obvious:

FUSE2FS (sda): op_fallocate: ino=50 mode=0x10 start=0x0 end=0x1
FUSE2FS (sda): fuse2fs_punch_range: ino=50 mode=0x11 offset=0x0 len=0x1 start=0 end=0

start and end are both zero, so we call ext2fs_punch with those
arguments.  ext2fs_punch interprets [start, end] as a closed interval
and removes block 0, which is not what we asked for!

The computation of end is also too subtle -- the dividend is the
expression (0 + 1 - 4096) which produces a negative number because off_t
is defined to be long long, at least on amd64 Linux.  We rely on the
behavior that dividing a negative dividend by a positive divisor
produces a quotient of zero.

Really what we should do here is round offset up to the next fsblock
and offset+len down to the nearest fsblock.  The first quantity is the
first byte of the range to punch and the second quantity is the next
byte past the range to punch.  Using those as the basis to compute start
and end, the punch should only happen if start < end, and we should pass
[start, end - 1] to ext2fs_punch because it expects a closed interval.

Improve the comments here so that I don't have to work all this out
again the next time I read through here.

Cc: linux-ext4@vger.kernel.org # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
4 hours agofuse2fs: fix clean_block_middle when punching byte 0 of a block
Darrick J. Wong [Thu, 31 Jul 2025 14:43:50 +0000 (10:43 -0400)] 
fuse2fs: fix clean_block_middle when punching byte 0 of a block

In non-iomap mode, generic/008 tries to fzero the first byte of a block
and fails:

--- a/tests/generic/008.out      2025-07-15 14:45:14.937058680 -0700
+++ b/tests/generic/008.out.bad        2025-07-16 11:43:42.427989360 -0700
@@ -4,8 +4,7 @@
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 wrote 1024/1024 bytes at offset 1024
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-00000000:  00 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41  .AAAAAAAAAAAAAAA
-00000010:  41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41  AAAAAAAAAAAAAAAA
+00000000:  41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41  AAAAAAAAAAAAAAAA
 *
 00000400:  42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42  BBBBBBBBBBBBBBBB
 *

Here we can clearly see that the first byte of the block has not been
zeroed, even though that's what the caller wanted us to do.  This is due
to an incorrect check of the residue variable that was most likely copy
pasted from clean_block_edge years ago.

Cc: linux-ext4@vger.kernel.org # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
4 hours agolibext2fs: fix data corruption when writing to inline data files
Darrick J. Wong [Thu, 17 Jul 2025 14:59:50 +0000 (07:59 -0700)] 
libext2fs: fix data corruption when writing to inline data files

Fix various bugs in ext2fs_file_write_inline_data:

 - "count = nbytes - pos" makes no sense since nbytes is already a
   length value and results in short writes if pos > 0.
 - Pass the correct file size to ext2fs_inline_data_set because count
   will not be the file size if pos > 0.
 - Simplify the decision to increase the file size.
 - Don't let a huge write corrupt memory beyond file->buf.
 - Zero the buffer between isize and pos if we're doing a sparse write
   past EOF.

Cc: linux-ext4@vger.kernel.org # v1.43
Fixes: 54e880b870f7fe ("libext2fs: handle inline data in read/write function")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20250717145950.GJ2672022@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 hours agolibext2fs: fix data read corruption in ext2fs_file_read_inline_data
Darrick J. Wong [Thu, 17 Jul 2025 14:59:33 +0000 (07:59 -0700)] 
libext2fs: fix data read corruption in ext2fs_file_read_inline_data

Fix numerous problems in the function that reads data from an inlinedata
file:

 - Reads starting after isize should be returned as short reads.
 - Reads past the end of the inline data should return zeroes.
 - Reads from the inline data buffer must not exceed isize.

Cc: linux-ext4@vger.kernel.org # v1.43
Fixes: 54e880b870f7fe ("libext2fs: handle inline data in read/write function")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20250717145933.GI2672022@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 hours agofuse2fs: fix ST_RDONLY setting
Darrick J. Wong [Thu, 17 Jul 2025 14:59:10 +0000 (07:59 -0700)] 
fuse2fs: fix ST_RDONLY setting

Only set ST_RDONLY if the filesystem isn't writable.

Cc: linux-ext4@vger.kernel.org # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20250717145910.GH2672022@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 hours agofuse2fs: fix races in statfs
Darrick J. Wong [Wed, 9 Jul 2025 16:52:40 +0000 (09:52 -0700)] 
fuse2fs: fix races in statfs

Take the BFL in statfs so that we don't expose a torn access to
userspace.  Found via code inspection.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20250709165240.GF2672022@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 hours agofuse2fs: fix race condition in op_destroy
Darrick J. Wong [Wed, 9 Jul 2025 16:51:52 +0000 (09:51 -0700)] 
fuse2fs: fix race condition in op_destroy

On a regular fuse server (i.e. one not running in fuseblk mode), libfuse
synthesizes and dispatches a FUSE_DESTROY command as soon as the event
dispatch loop terminates after the kernel disconnects /dev/fuse.
Unfortunately, this is done without coordinating with any other threads
that may have already received a real FUSE command from the kernel.

In other words, FUSE_DESTROY can run in parallel with other
fuse_operations.  Therefore, we must guard the body of this function
with the BKL just like any other fuse operation or risk races within
libext2fs.  If we're lucky, we trash the ext2_filsys state and
generic/488 will crash.

[23512.452451] [U] fuse: reading device: Software caused connection abort
[23512.453886] [U] fuse: reading device: Software caused connection abort

If we're not lucky, it corrupts the ondisk filesystem resulting in a
e2fsck complaining as well.

Cc: linux-ext4@vger.kernel.org # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20250709165152.GE2672022@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 hours agofuse2fs: fix lockfile creation, again
Darrick J. Wong [Tue, 8 Jul 2025 17:33:33 +0000 (10:33 -0700)] 
fuse2fs: fix lockfile creation, again

On closer examination of the lockfile code, there is still a fatal flaw
in the locking logic.  This is born out by the fact that you can run:

# truncate -s 300m /tmp/a
# mkfs.ext2 /tmp/a
# fuse2fs -o kernel /tmp/a /mnt -o lockfile=/tmp/fuselock
# fuse2fs -o kernel /tmp/a /mnt -o lockfile=/tmp/fuselock

and the second mount attempt succeeds where it really shouldn't.  This
is due to the use of fopen(..., "w"), because "w" means "truncate or
create".  It does /not/ imply O_CREAT | O_EXCL, which fails if the file
already exists.  Theoretically that could have been done with mode
string "wx", but that's a glibc extension.

Fix this by calling open() directly with the O_ modes that we want.

Cc: linux-ext4@vger.kernel.org # v1.47.3-rc3
Fixes: e50fbaa4d156a6 ("fuse2fs: clean up the lockfile handling")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20250708173333.GD2672022@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 hours agofuse2fs: fix relatime comparisons
Darrick J. Wong [Mon, 7 Jul 2025 16:05:25 +0000 (09:05 -0700)] 
fuse2fs: fix relatime comparisons

generic/192 fails like this even before we start adding iomap code:

    --- tests/generic/192.out   2025-04-30 16:20:44.512675591 -0700
    +++ tests/generic/192.out.bad    2025-07-06 22:26:11.666015735 -0700
    @@ -1,5 +1,6 @@
     QA output created by 192
     sleep for 5 seconds
     test
    -delta1 is in range
    +delta1 has value of 0
    +delta1 is NOT in range 5 .. 7
     delta2 is in range

The cause of this regression is that the timestamp comparisons account
only for seconds, not nanoseconds.  If a write came in 100ms after the
last read but still in the same second, then we fail to update atime on
a subsequent read.

Fix this by converting the timespecs to doubles so that we can include
the nanoseconds component, and then perform the comparison in floating
point mode.

Cc: linux-ext4@vger.kernel.org # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20250707160525.GC2672022@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 hours agofuse2fs: don't try to mount after option parsing errors
Darrick J. Wong [Sun, 6 Jul 2025 18:32:50 +0000 (11:32 -0700)] 
fuse2fs: don't try to mount after option parsing errors

Actually check the outcome of parsing CLI options before trying to
mount.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/175182663113.1984706.10460295274868313866.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 hours agofuse2fs: fix incorrect unit conversion at the end of FITRIM
Darrick J. Wong [Sun, 6 Jul 2025 18:32:34 +0000 (11:32 -0700)] 
fuse2fs: fix incorrect unit conversion at the end of FITRIM

generic/260 also points out that the bytes cleared are in the wrong
units -- they're supposed to be in bytes, but the "cleared" variable is
in units of fsblocks.  Fix that.

Cc: linux-ext4@vger.kernel.org # v1.47.3-rc1
Fixes: 7235b58533b9cd ("fuse2fs: fix FITRIM validation")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/175182663095.1984706.13547873393931840622.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 hours agofuse2fs: fix incorrect EOFS input handling in FITRIM
Darrick J. Wong [Thu, 31 Jul 2025 14:38:21 +0000 (10:38 -0400)] 
fuse2fs: fix incorrect EOFS input handling in FITRIM

FITRIM isn't well documented, which means that I missed that
len == -1ULL always means "trim to end of filesystem".  generic/260 has
been failing with:

--- a/tests/generic/260.out      2025-04-30 16:20:44.532797310 -0700
+++ b/tests/generic/260.out.bad        2025-07-03 11:44:26.946394170 -0700
@@ -11,4 +11,5 @@
 [+] Default length with start set (should succeed)
 [+] Length beyond the end of fs (should succeed)
 [+] Length beyond the end of fs with start set (should succeed)
+After the full fs discard 0 bytes were discarded however the file system is 10401542144 bytes long.
 Test done

because the addition used to compute end suffered an integer overflow,
resulting in end < start, which meant nothing happened.  Fix this by
explicitly checking for -1ULL.

Cc: linux-ext4@vger.kernel.org # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
4 hours agofuse2fs: don't truncate when creating a new file
Darrick J. Wong [Sun, 6 Jul 2025 18:32:03 +0000 (11:32 -0700)] 
fuse2fs: don't truncate when creating a new file

New files can't have contents, so there's no need to truncate them,
which then messes with ctime/mtime.

Cc: linux-ext4@vger.kernel.org # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/175182663059.1984706.11656403223439904537.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 hours agofuse2fs: fix gid inheritance on sgid parent directories
Darrick J. Wong [Sun, 6 Jul 2025 18:31:47 +0000 (11:31 -0700)] 
fuse2fs: fix gid inheritance on sgid parent directories

When a child file is created inside a setgid parent directory, the child
is supposed to inherit the gid of the parent, not the fsgid of the
creating process.  Fix this error, which was discovered by generic/633,
generic/696, and generic/697.

Cc: linux-ext4@vger.kernel.org # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/175182663041.1984706.582232688757289460.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 hours agofuse2fs: refactor uid/gid setting
Darrick J. Wong [Sun, 6 Jul 2025 18:31:31 +0000 (11:31 -0700)] 
fuse2fs: refactor uid/gid setting

Don't open-code the uid and gid update logic.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/175182663023.1984706.1635443008190304976.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 hours agolibext2fs: fix arguments passed to ->block_alloc_stats_range
Darrick J. Wong [Sun, 6 Jul 2025 18:31:16 +0000 (11:31 -0700)] 
libext2fs: fix arguments passed to ->block_alloc_stats_range

In ext2fs_block_alloc_stats_range, we use @num as the loop counter but
then pass it to the callback and @blk as the loop cursor.  This means
that the range passed to e2fsck_block_alloc_stats_range starts beyond
the range that was actually freed and has a length of zero, which is not
at all correct.

Fix this by saving the original values and passing those instead.

Cc: linux-ext4@vger.kernel.org # v1.43
Fixes: 647e8786156061 ("libext2fs: add new hooks to support large allocations")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/175182663005.1984706.2711154041137486922.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 hours agolibext2fs: fix off-by-one bug in punch_extent_blocks
Darrick J. Wong [Sun, 6 Jul 2025 18:31:00 +0000 (11:31 -0700)] 
libext2fs: fix off-by-one bug in punch_extent_blocks

punch_extent_blocks tries to validate its input parameters to make sure
that the physical range of blocks being punched do not go past the end
of the filesystem.  Unfortunately, there's an off-by-one bug in the
valiation, because start==0 count==10 is a perfectly valid range on a
10-block filesystem.

Cc: linux-ext4@vger.kernel.org # v1.46.6
Fixes: 6772d4969e9c90 ("libext2fs: check for invalid blocks in ext2fs_punch_blocks()")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/175182662987.1984706.5292286424808159532.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 weeks agoe2scrub: reorder exit status check after calling lvremove
Samuel Smith [Sat, 5 Jul 2025 03:38:21 +0000 (22:38 -0500)] 
e2scrub: reorder exit status check after calling lvremove

Checking for snapshot device existence resets the status code in $?.
Reording the conditions will allow the retry loop to work properly.

Signed-off-by: Samuel Smith <satlug@net153.net>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20250705033821.3695205-1-satlug@net153.net
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 weeks agoUpdate release notes, etc., for the 1.47.3 release maint-1.47 maint-1.47 v1.47.3
Theodore Ts'o [Tue, 8 Jul 2025 22:08:50 +0000 (18:08 -0400)] 
Update release notes, etc., for the 1.47.3 release

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 weeks agopo: update ms.po (from translationproject.org)
Sharuzzaman Ahmat Raslan [Tue, 8 Jul 2025 21:24:38 +0000 (17:24 -0400)] 
po: update ms.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 weeks agoUpdate release notes, etc., for the 1.47.3-rc3 release v1.47.3-rc3
Theodore Ts'o [Wed, 2 Jul 2025 18:18:15 +0000 (14:18 -0400)] 
Update release notes, etc., for the 1.47.3-rc3 release

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 weeks agoconfigure: correctly set up CFLAGS while setting up libarchive
Theodore Ts'o [Wed, 2 Jul 2025 19:22:46 +0000 (15:22 -0400)] 
configure: correctly set up CFLAGS while setting up libarchive

Fix a regression where the debugging options ("-g -O") got dropped
while setting up the include path for libarchive.

Fixes: c54a2e825847 ("Use the libarchive library reported by pkg-config")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 weeks agofuse2fs.1: fix formatting of newly added options in the man page
Theodore Ts'o [Wed, 2 Jul 2025 03:05:31 +0000 (23:05 -0400)] 
fuse2fs.1: fix formatting of newly added options in the man page

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 weeks agofuse2fs: fix normal (non-kernel) permissions checking
Theodore Ts'o [Wed, 2 Jul 2025 02:58:39 +0000 (22:58 -0400)] 
fuse2fs: fix normal (non-kernel) permissions checking

Commit 9f69dfc4e275 ("fuse2fs: implement O_APPEND correctly") defined
a new flag, A_OK, to add support for testing whether the file is valid
for append operations.  This is relevant for the check_iflags_access()
function, but when are later testing operations mask against the inode
permissions, this new flag gets in the way and causes non-root users
attempting to create new inodes in a directory to fail.  Fix this by
masking off A_OK before doing these tests.

Fixes: 9f69dfc4e275 ("fuse2fs: implement O_APPEND correctly")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 weeks agoAvoid redefining CACHE_LINE_SIZE if system provides it.
Matthias Andree [Tue, 1 Jul 2025 21:14:08 +0000 (23:14 +0200)] 
Avoid redefining CACHE_LINE_SIZE if system provides it.

FreeBSD 14.3 complains about our trying to redefine
the CACHE_LINE_SIZE, which happens to be 1 << 6 == 64
on amd64 but not arm64.

Just check and only #define unless it's already:

../../../lib/ext2fs/unix_io.c:563: warning: "CACHE_LINE_SIZE" redefined
  563 | #define CACHE_LINE_SIZE         64
      |
In file included from /usr/include/sys/param.h:163,
                 from /usr/include/bsm/audit.h:41,
                 from /usr/include/sys/ucred.h:42,
                 from /usr/include/sys/mount.h:37,
                 from ../../../lib/ext2fs/unix_io.c:53:
/usr/include/machine/param.h:92: note: this is the location of the previous definition
   92 | #define CACHE_LINE_SIZE         (1 << CACHE_LINE_SHIFT)
      |

On FreeBSD 14.3, machine/param.h
- for arm64 and powerpc define CACHE_LINE_SIZE to (128),
- for i386, amd64, arm (32) and riscv define (64).

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 weeks agoPass down autoconf's EGREP to the tests.
Matthias Andree [Tue, 1 Jul 2025 19:30:23 +0000 (21:30 +0200)] 
Pass down autoconf's EGREP to the tests.

Care was taken to make sure where to quote and where not to; variable
assignments with EGREP=@EGREP@ need quoting in order not to split the
variable into tokens; expansions in places where we used to invoke egrep
need not because they actually need to split $EGREP contents in case
it's "grep -E".

This fixes "egrep is obsolescent" warnings on newer coreutils.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 weeks agoAccept alternate ordering of ACLs from btrfs.
Matthias Andree [Tue, 1 Jul 2025 19:21:47 +0000 (21:21 +0200)] 
Accept alternate ordering of ACLs from btrfs.

https://github.com/tytso/e2fsprogs/issues/158

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 weeks agoe2scrub: honor fstrim setting in e2scrub.conf
Samuel Smith [Sat, 28 Jun 2025 05:14:15 +0000 (00:14 -0500)] 
e2scrub: honor fstrim setting in e2scrub.conf

The systemd service unconditionally passes -t to e2scrub, forcing
fstrim to run after every scrub regardless of the fstrim setting
in /etc/e2scrub.conf. Removing the hardcoded flag will allow users to
control the behavior via the configuration file.

Signed-off-by: Samuel Smith <satlug@net153.net>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20250628051415.3015410-1-satlug@net153.net
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 weeks agot_mmp_fail: resolve bash-ism [ a == b ] to [ a = b ]
Matthias Andree [Thu, 26 Jun 2025 20:28:42 +0000 (22:28 +0200)] 
t_mmp_fail: resolve bash-ism [ a == b ] to [ a = b ]

for those systems where sh does not support the == operator in
the test or [ built-ins, for instance, on FreeBSD's sh.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Link: https://lore.kernel.org/r/20250626202919.321842-3-matthias.andree@gmx.de
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 weeks agof_detect_junk: avoid dd option oflag=append
Matthias Andree [Thu, 26 Jun 2025 20:28:41 +0000 (22:28 +0200)] 
f_detect_junk: avoid dd option oflag=append

because it is unavailable on, for instance, FreeBSD's dd.
Instead use dd to just generate 16 MB of zeroes and use
the shell append redirection.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Link: https://lore.kernel.org/r/20250626202919.321842-2-matthias.andree@gmx.de
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 weeks agom_offset: make self-test reliable with non-GNU yes(1)
Matthias Andree [Thu, 26 Jun 2025 20:28:40 +0000 (22:28 +0200)] 
m_offset: make self-test reliable with non-GNU yes(1)

m_offset has been failing sporadically on FreeBSD, and always because
crc_exp(ected) was different from all other CRC values (which were
mutually equal, first1, first2, last).

The test scrsipt uses yes(1) to write into dd(1),
but FreeBSD's "yes a" use sizes of 8192 - length-of-pattern, meaning
8190 with "a\n" (meaning a + LF).
GNU yes from coreutils 9.1 instead dispatches 1024-sized writes.

The peculiar thing is that dd bs=1k count=512 will dispatch 512 read
attempts of 1 k each, but due to yes and dd running concurrently, dd
will sometimes see a short read block, resulting in an overall shorter
output file fed into crcsum, leading to a mismatched crc_exp value.

Fix: Add iflag=fullblock to ensure the proper output size will be fed
into crcsum, even if that means doing more than 512 reads internally.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Link: https://lore.kernel.org/r/20250626202919.321842-1-matthias.andree@gmx.de
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agodebian: update to debian policy 4.7.2
Theodore Ts'o [Thu, 26 Jun 2025 13:52:51 +0000 (09:52 -0400)] 
debian: update to debian policy 4.7.2

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: clean up the lockfile handling
Darrick J. Wong [Mon, 16 Jun 2025 15:06:14 +0000 (08:06 -0700)] 
fuse2fs: clean up the lockfile handling

Fix various problems with the new lockfile code in fuse2fs: the printfs
should use the actual logging function err_printf, the messages should
be looked up in gettext, we should actually exit main properly on
error instead of calling exit(), and the error message printing for the
final lockfile unlink is broken.

Fixes: e83c0df0135f98 ("fuse2fs: rename the inusefile option to lockfile")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20250616150614.GG6134@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agodebian: use dpkg-shlibdeps for library dependency calculation
Jochen Sprickerhof [Thu, 19 Jun 2025 19:42:57 +0000 (21:42 +0200)] 
debian: use dpkg-shlibdeps for library dependency calculation

* Drop old shlibs.local. The file is not needed and "This file should
  normally not be used" according to:
  https://www.debian.org/doc/debian-policy/ch-sharedlibs.html#the-shlibs-files-present-on-the-system

* Remove manual dependency on libcom-err2 as dpkg-shlibdeps will compute
  and add it to ${shlibs:Depends}.

Addresses-Debian-Bug: #1108010
Signed-off-by: Jochen Sprickerhof <git@jochen.sprickerhof.de>
5 weeks agodebian: fix libcom-err2 package name in d/rules
Jochen Sprickerhof [Thu, 19 Jun 2025 19:42:04 +0000 (21:42 +0200)] 
debian: fix libcom-err2 package name in d/rules

libcomerr2 was renamed to libcom-err2 in 146649cd ("Update release
notes, etc., for the 1.43.9 release").

Signed-off-by: Jochen Sprickerhof <git@jochen.sprickerhof.de>
6 weeks agoUse static linking for libarchive by default on MacOS
Theodore Ts'o [Sun, 15 Jun 2025 10:30:05 +0000 (06:30 -0400)] 
Use static linking for libarchive by default on MacOS

Apparently dlopen() path searching doesn't work or is unreliable on
MacOS; it appears to not search LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, or
DYLD_FALLBACK_LIBRARY_PATH as documented by the dlopen(3) man page.
Furthmore setting any of these variables to include /opt/local/lib,
which is where MacPort drops libarchive.13.dylib, can cause all manner
of warnings when running other dynamically linked programs, such as
"grep".  What a mess.  It appears dlopen(2) support in MacOS is a
disaster, and it's not really needed since we don't care about the
size of mke2fs on installation media on non-Linux systems.  So default
to using --with-libarchive=direct for MacOS.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agoUse the libarchive library reported by pkg-config
Theodore Ts'o [Sun, 15 Jun 2025 01:47:50 +0000 (21:47 -0400)] 
Use the libarchive library reported by pkg-config

If pkg-config is present, use it to determine how to access libarchive
library and its header file.

This fixes support for MacOS when trying to use libarchive.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agoUse the fuse3 libraries reported by pkg-config
Theodore Ts'o [Sat, 14 Jun 2025 20:47:26 +0000 (16:47 -0400)] 
Use the fuse3 libraries reported by pkg-config

It used to be that PKG_CHECK_MODULES would set foo_LDFLAGS; not it
just sets the foo_LIBS with the required -L and -l options.  Fix this
up for fuse3 support.

This fixes support on MacOS using MacFuse.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agoMerge branch 'patch' of github.com:usertam/e2fsprogs into next
Theodore Ts'o [Sat, 14 Jun 2025 20:45:30 +0000 (16:45 -0400)] 
Merge branch 'patch' of github.com:usertam/e2fsprogs into next

6 weeks agolibext2fs: fix bounding error in the extent fallocate code
Darrick J. Wong [Thu, 12 Jun 2025 22:18:26 +0000 (15:18 -0700)] 
libext2fs: fix bounding error in the extent fallocate code

generic/361 popped up this weird error:

generic/361       [failed, exit status 1]- output mismatch (see /var/tmp/fstests/generic/361.out.bad)
    --- tests/generic/361.out   2025-04-30 16:20:44.563589363 -0700
    +++ /var/tmp/fstests/generic/361.out.bad    2025-06-11 10:40:07.475036412 -0700
    @@ -1,2 +1,2 @@
     QA output created by 361
    -Silence is golden
    +mkfs.fuse.ext4: Input/output error while writing out and closing file system
    ...
    (Run 'diff -u /run/fstests/bin/tests/generic/361.out /var/tmp/fstests/generic/361.out.bad'  to see the entire diff)

The test formats a small filesystem, creates a larger sparse file, loop
mounts it, and tries to format an ext4 filesystem on the loopdev.  The
loop driver sends fallocate zero_range requests to fuse2fs, but stumbles
over this extent tree layout when fallocating 16 blocks at offset 145:

EXTENTS:
(262128-262143[u]):2127-2142

fallocate goes to offset 145, and sees the right-extent at 262128.
Oddly, it then tries to allocate 262128-145 blocks instead of the 16
that were asked for, so it tries to allocate a huge number of blocks
but then crashes and burns when it runs out of space.

Fix this by constraining the len parameter to ext_falloc_helper to the
correct value.

Cc: linux-ext4@vger.kernel.org # v1.43
Fixes: 5aad5b8e0e3cfa ("libext2fs: implement fallocate")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20250612221826.GE6134@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agoUpdate release notes, etc., for the 1.47.3-rc2 release v1.47.3-rc2
Theodore Ts'o [Fri, 13 Jun 2025 19:26:06 +0000 (15:26 -0400)] 
Update release notes, etc., for the 1.47.3-rc2 release

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agopo: update zh_CN.po (from translationproject.org)
Wenbin Lv [Thu, 12 Jun 2025 23:58:47 +0000 (19:58 -0400)] 
po: update zh_CN.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agopo: update uk.po (from translationproject.org)
Yuri Chornoivan [Thu, 12 Jun 2025 23:58:47 +0000 (19:58 -0400)] 
po: update uk.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agopo: update sv.po (from translationproject.org)
Göran Uddeborg [Thu, 12 Jun 2025 23:58:47 +0000 (19:58 -0400)] 
po: update sv.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agopo: update sr.po (from translationproject.org)
Мирослав Николић [Thu, 12 Jun 2025 23:58:47 +0000 (19:58 -0400)] 
po: update sr.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agopo: update ro.po (from translationproject.org)
Remus-Gabriel Chelu [Thu, 12 Jun 2025 23:58:47 +0000 (19:58 -0400)] 
po: update ro.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agopo: update pt.po (from translationproject.org)
Pedro Albuquerque [Thu, 12 Jun 2025 23:58:47 +0000 (19:58 -0400)] 
po: update pt.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agopo: update pl.po (from translationproject.org)
Jakub Bogusz [Thu, 12 Jun 2025 23:58:47 +0000 (19:58 -0400)] 
po: update pl.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agopo: update nl.po (from translationproject.org)
Benno Schulenberg [Thu, 12 Jun 2025 23:58:46 +0000 (19:58 -0400)] 
po: update nl.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agopo: update fr.po (from translationproject.org)
Samuel Thibault [Thu, 12 Jun 2025 23:58:46 +0000 (19:58 -0400)] 
po: update fr.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agopo: update es.po (from translationproject.org)
Antonio Ceballos [Thu, 12 Jun 2025 23:58:46 +0000 (19:58 -0400)] 
po: update es.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agopo: update cs.po (from translationproject.org)
Petr Pisar [Thu, 12 Jun 2025 23:58:46 +0000 (19:58 -0400)] 
po: update cs.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: rename the inusefile option to lockfile
Theodore Ts'o [Thu, 12 Jun 2025 19:00:08 +0000 (15:00 -0400)] 
fuse2fs: rename the inusefile option to lockfile

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
7 weeks agofuse2fs: fix error bailout in op_create
Darrick J. Wong [Wed, 11 Jun 2025 16:44:01 +0000 (09:44 -0700)] 
fuse2fs: fix error bailout in op_create

Tim Woodall pointed out that op_create returns garbage error codes if
the ext2fs_extent_open2 in op_create fails.  Worse than that, it also
neglects to drop the bfl and leaks temp_path.  Let's fix all that.

Cc: linux-ext4@vger.kernel.org # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Reported-by: Tim Woodall <debianbugs@woodall.me.uk>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
7 weeks agolibext2fs: fix spurious warnings from fallocate
Darrick J. Wong [Wed, 11 Jun 2025 16:43:45 +0000 (09:43 -0700)] 
libext2fs: fix spurious warnings from fallocate

generic/522 routinely produces error messages from fuse2fs like this:

FUSE2FS (sde): Illegal block number passed to ext2fs_test_block_bitmap #9321 for block bitmap for /dev/sde

Curiously, these don't actually result in errors being thrown up to the
kernel.  Digging into the program (which was more difficult than it
needed to be because of the weird bitmap base + errcode weirdness)
produced a left record:

e_lblk = 16
e_pblk = 9293
e_len = 6
e_flags = 0

and a right record:

e_lblk = 45
e_pblk = 9321
e_len = 6
e_flags = 0

Thus we end up in the "Merge both extents together, perhaps?" section of
ext_falloc_helper.  Unfortunately, the merge selection code isn't smart
enough to notice that the two mappings aren't actually physically
contiguous, so it scans the bitmap with a negative length, which is why
the assertion trips.

The simple fix here is not to try to merge the adjacent extents if
they're not actually physically contiguous.

Cc: linux-ext4@vger.kernel.org # v1.43
Fixes: 5aad5b8e0e3cfa ("libext2fs: implement fallocate")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
7 weeks agofuse2fs: correctly handle system errno values in __translate_error()
Theodore Ts'o [Thu, 12 Jun 2025 16:33:44 +0000 (14:03 -0230)] 
fuse2fs: correctly handle system errno values in __translate_error()

Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Reported-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
7 weeks agodebian: fix typo in fuse2fs.postrm which breaks a /usr-move mitigation
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:

Unpacking fuse2fs (1.47.2-2) over (1.47.2-1+b1) ...
/var/lib/dpkg/info/fuse2fs.postrm: 6: test: failed-upgrade: unexpected operator

Addresses-Debian-Bug: #1107595
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
7 weeks agomisc: teach fuse2fs the inusefile command-line option
Theodore Ts'o [Mon, 9 Jun 2025 19:49:52 +0000 (15:49 -0400)] 
misc: teach fuse2fs the inusefile command-line option

The inusefile option is useful for scripts that want to know when
fuse2fs is done modifying the file system after it is unmounted.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
7 weeks agolibext2fs: fix integer overflow in ext2fs_punch() when releasing more than 2**31...
Theodore Ts'o [Mon, 9 Jun 2025 15:30:48 +0000 (11:30 -0400)] 
libext2fs: fix integer overflow in ext2fs_punch() when releasing more than 2**31 blocks

Addresses-Debian-Bug: #1106241
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
7 weeks agolibext2fs: fix ext2fs_link() when the directory has an extent tree depth > 1
Theodore Ts'o [Fri, 6 Jun 2025 22:52:13 +0000 (18:52 -0400)] 
libext2fs: fix ext2fs_link() when the directory has an extent tree depth > 1

Ext2fs_link() was passing the wrong inode number to ext2fs_bmap(); as
a result, when a directory inode was using extents and the extent tree
depth was greater than 1, the extent tree checksum would be
incorrectly calculated resulting in a error that the extent tree block
checksum was incorrect.

Fixes: 53aa6c54224f ("libext2fs: add the EXT2FS_LINK_APPEND flag ...)
Addresses-Debian-Bug: #1106854
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
7 weeks agolibext2fs: fix a extent tree corruption bug in ext2fs_extent_set_bmap()
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.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
8 weeks agoe2freefrag: correct a mistyped symbol name
Benno Schulenberg [Sun, 1 Jun 2025 12:36:24 +0000 (14:36 +0200)] 
e2freefrag: correct a mistyped symbol name

Fixes: 0c675a67c568 ("debugfs: return after printing the usage message..."(
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
8 weeks agomke2fs: fix a misindentation in the man page
Benno Schulenberg [Sun, 1 Jun 2025 12:36:23 +0000 (14:36 +0200)] 
mke2fs: fix a misindentation in the man page

Problem existed since commit 3c22bf7e70 from twelve years ago.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
8 weeks agomisc: define XATTR_{CREATE,REMOVE} if necessary
Theodore Ts'o [Wed, 4 Jun 2025 20:29:49 +0000 (20:29 +0000)] 
misc: define XATTR_{CREATE,REMOVE} if necessary

This fixes a FreeBSD portability issue in fuse2fs.

Fixes: 5c7fec6121e6 ("fuse2fs: support XATTR_CREATE/REPLACE in setxattr")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
8 weeks agomisc: define alternative errno if OS doesn't provide ENODATA
Theodore Ts'o [Wed, 4 Jun 2025 00:16:30 +0000 (00:16 +0000)] 
misc: define alternative errno if OS doesn't provide ENODATA

FreeBSD doesn't define ENODATA, and uses ENOATTR when an extended
attribute is not found.  So map ENODATA to ENOATTR to fix a build
failure for platforms that don't define ENODATA.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
8 weeks agodebian: add a Built-Using field to the e2fsck-static package
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.

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1106799#32

Addresses-Debian-Bug: #1106799
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
8 weeks agodebian: remove physical address of the FSF from the copyright file
Theodore Ts'o [Tue, 3 Jun 2025 17:31:40 +0000 (17:31 +0000)] 
debian: remove physical address of the FSF from the copyright file

Use https://www.gnu.org/licenses instead of telling users to request a
copy of the license text via snail (postal) mail.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agodebian: release 1.47.3~rc1-1 to experimental
Theodore Ts'o [Wed, 28 May 2025 14:50:38 +0000 (10:50 -0400)] 
debian: release 1.47.3~rc1-1 to experimental

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agomkgnutar.pl: avoid uninitialized username variable
usertam [Thu, 29 May 2025 11:19:06 +0000 (19:19 +0800)] 
mkgnutar.pl: avoid uninitialized username variable

This can happen when the running uid is dynamically allocated
without a proper user entry or name.

2 months agocreate_inode_libarchive.c: define libarchive dylib for darwin
usertam [Thu, 29 May 2025 11:16:23 +0000 (19:16 +0800)] 
create_inode_libarchive.c: define libarchive dylib for darwin

2 months agodebian: use 1.47.3~rc1 in libext2fs2t64.symbols instead of 1.47.3
Theodore Ts'o [Wed, 28 May 2025 14:44:08 +0000 (10:44 -0400)] 
debian: use 1.47.3~rc1 in libext2fs2t64.symbols instead of 1.47.3

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agoUpdate release notes, etc., for the 1.47.3 release v1.47.3-rc1
Theodore Ts'o [Wed, 28 May 2025 12:33:03 +0000 (08:33 -0400)] 
Update release notes, etc., for the 1.47.3 release

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agopo: add Georgian language from the Translation Project
Theodore Ts'o [Wed, 28 May 2025 12:27:00 +0000 (08:27 -0400)] 
po: add Georgian language from the Translation Project

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agopo: update sr.po (from translationproject.org)
Мирослав Николић [Wed, 28 May 2025 12:19:37 +0000 (08:19 -0400)] 
po: update sr.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agopo: update pt.po (from translationproject.org)
Pedro Albuquerque [Wed, 28 May 2025 12:19:37 +0000 (08:19 -0400)] 
po: update pt.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agopo: update nl.po (from translationproject.org)
Benno Schulenberg [Wed, 28 May 2025 12:19:37 +0000 (08:19 -0400)] 
po: update nl.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agopo: update ms.po (from translationproject.org)
Sharuzzaman Ahmat Raslan [Wed, 28 May 2025 12:19:37 +0000 (08:19 -0400)] 
po: update ms.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agoutil: avoid potential buffer overruns caused by super-long pathnames
Theodore Ts'o [Wed, 28 May 2025 11:52:44 +0000 (07:52 -0400)] 
util: avoid potential buffer overruns caused by super-long pathnames

This shouldn't happen in real life, but this clears a few coverity
warning.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agodebian: update libext2fs2t64.symbols with shared library additions
Theodore Ts'o [Tue, 27 May 2025 21:06:58 +0000 (17:06 -0400)] 
debian: update libext2fs2t64.symbols with shared library additions

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agoUpdate Makefile.in files using "make depend"
Theodore Ts'o [Tue, 27 May 2025 21:05:13 +0000 (17:05 -0400)] 
Update Makefile.in files using "make depend"

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months ago.gitignore: add files generated by "make depend"
Theodore Ts'o [Tue, 27 May 2025 21:04:24 +0000 (17:04 -0400)] 
.gitignore: add files generated by "make depend"

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agoMerge branch 'fix-fuse' of github.com:allisonkarlitskaya/e2fsprogs into next
Theodore Ts'o [Tue, 27 May 2025 16:49:22 +0000 (12:49 -0400)] 
Merge branch 'fix-fuse' of github.com:allisonkarlitskaya/e2fsprogs into next

2 months agocreate_inode: fix 32-bit -Werror=pointer-to-int-cast build failure
Theodore Ts'o [Mon, 26 May 2025 20:46:45 +0000 (16:46 -0400)] 
create_inode: fix 32-bit -Werror=pointer-to-int-cast build failure

Fixes: 6bfa843b4435 ("mke2fs: enable copying of fs-verity metadata")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agodebugfs: return after printing the usage message in the e2freefrag command
Theodore Ts'o [Mon, 26 May 2025 20:25:15 +0000 (16:25 -0400)] 
debugfs: return after printing the usage message in the e2freefrag command

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agofuse2fs: fix old libfuse compatibility issue
Allison Karlitskaya [Mon, 26 May 2025 18:38:16 +0000 (20:38 +0200)] 
fuse2fs: fix old libfuse compatibility issue

We only have the 'cfg' parameter defined here #if FUSE_VERSION >=
FUSE_MAKE_VERSION(3, 0), so only attempt to access it in that case as
well.

In particular, this fixes an issue when building on the GitHub Actions
runners.

Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
2 months agomisc: remove unused retry label
Theodore Ts'o [Mon, 26 May 2025 17:53:25 +0000 (13:53 -0400)] 
misc: remove unused retry label

Fixes: 0a5dc78ba4dc ("Add a support for new flag (EXT2FS_LINK_EXPAND) ..."
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agoe2fsck: add error checking for sysconf(3) in get_memory_size()
Theodore Ts'o [Mon, 26 May 2025 17:29:19 +0000 (13:29 -0400)] 
e2fsck: add error checking for sysconf(3) in get_memory_size()

Also remove some dead code relating to using sysctl().

Addresses-Coverity-Bug: 1633755
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agomke2fs: add range checks for -E desc_size
Theodore Ts'o [Mon, 26 May 2025 16:51:49 +0000 (12:51 -0400)] 
mke2fs: add range checks for -E desc_size

Prevent the user from specifying group descriptor that result in
invalid/corrupted file systems.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agoe2freefrag: require that the chunksize must be greater than 0
Theodore Ts'o [Mon, 26 May 2025 16:36:07 +0000 (12:36 -0400)] 
e2freefrag: require that the chunksize must be greater than 0

"e2freefrag -c 0" doesn't make much sense, so abort with an error
message if the user specifies a zero chunksize.

Addresses-Coverity-Bug: 1633767
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agolibe2p: avoid potential integer overflow in interate_on_dir()
Theodore Ts'o [Mon, 26 May 2025 14:09:59 +0000 (10:09 -0400)] 
libe2p: avoid potential integer overflow in interate_on_dir()

Overflows won't happen if the OS's implementation of pathconf()
returns reasonable values, but we can make it a bit more hardened
against maliciou implementations.

Addresses-Coverity-Bug: 1633758
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agoe4defrag: fix memory leak
Super User [Wed, 9 Apr 2025 13:59:58 +0000 (16:59 +0300)] 
e4defrag: fix memory leak

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agoe2fsck: fix e2fsck -E unshare_blocks when there are no shared blocks
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.

https://github.com/tytso/e2fsprogs/issues/218

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agolibext2fs: fix Coverity type warnings from ext2fs_inode_xtime_set()
Theodore Ts'o [Mon, 26 May 2025 01:37:38 +0000 (21:37 -0400)] 
libext2fs: fix Coverity type warnings from ext2fs_inode_xtime_set()

The ext2fs_inode_xtime_set() C preprocessor macro needs to cast to
__u32 before assigning to the time field.

This fixes a number of integer handling issues reported by Coverity.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agomke2fs: propagate some chattr flags into the fs image when using mke2fs -d
Theodore Ts'o [Sun, 25 May 2025 16:51:36 +0000 (12:51 -0400)] 
mke2fs: propagate some chattr flags into the fs image when using mke2fs -d

When copying files from a source directory, propagate chattr flags
such as the immutable, append-only, nodump, etc. into the files in the
destination file system.  Flags in directory inodes are also propagated.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agolibext2fs: add new function ext2fs_mkdir2()
Theodore Ts'o [Sun, 25 May 2025 05:11:54 +0000 (01:11 -0400)] 
libext2fs: add new function ext2fs_mkdir2()

Add a new function which allows caller to specify the flags passed to
ext2fs_link and to set flags in the newly created directory.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agolibext2fs: fix ext2fs_link() for EXT2FS_LINK_APPEND and non-regular files
Theodore Ts'o [Sun, 25 May 2025 21:38:49 +0000 (17:38 -0400)] 
libext2fs: fix ext2fs_link() for EXT2FS_LINK_APPEND and non-regular files

Fix the incorrect flag being passed to ext2fs_process_dir_block().
This bug was masked because EXT2_FT_REG_FILE has the same code point
as DIRENT_FLAG_INCLUDE_EMPTY which was the flag that was needed and
mke2fs -d was only use ext2fs_lik() for regular files.

Fixes: 53aa6c54224f ("libext2fs: add the EXT2FS_LINK_APPEND flag ...)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>