Whamcloud - gitweb
tools/e2fsprogs.git
5 weeks agoUpdate release notes, etc., for the 1.47.3 release
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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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

5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks agoAdd a support for new flag (EXT2FS_LINK_EXPAND) for ext2fs_link()
Theodore Ts'o [Sun, 25 May 2025 04:39:13 +0000 (00:39 -0400)]
Add a support for new flag (EXT2FS_LINK_EXPAND) for ext2fs_link()

Many calls to ext2fs_link() checks for EXT2_ET_DIR_NO_SPACE and if so,
calls ext2fs_expand_dir() and then retries the ext2fs_link().  We can
simplify a lot of code by adding support for a flag which does the
retry into the ext2fs_link() function.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agomke2fs: disallow -O verity without extents
Allison Karlitskaya [Thu, 13 Mar 2025 16:18:17 +0000 (17:18 +0100)]
mke2fs: disallow -O verity without extents

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.

5 weeks agomke2fs: add support for copying signature blobs in the fs-verity metadata
Theodore Ts'o [Sat, 24 May 2025 23:28:13 +0000 (19:28 -0400)]
mke2fs: add support for copying signature blobs in the fs-verity metadata

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agomke2fs: enable copying of fs-verity metadata
Allison Karlitskaya [Mon, 25 Nov 2024 08:46:30 +0000 (09:46 +0100)]
mke2fs: enable copying of fs-verity metadata

When creating a filesystem with `mke2fs -O verity` and populating
content via `-d`, check if that content is fs-verity enabled, and if it
is, copy the fs-verity metadata from the host-native filesystem into the
created filesystem.

Closes: https://github.com/tytso/e2fsprogs/pull/201
Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
5 weeks agomke2fs: factor out 'write_all()' functionality
Allison Karlitskaya [Mon, 25 Nov 2024 08:46:30 +0000 (09:46 +0100)]
mke2fs: factor out 'write_all()' functionality

When writing data to an inode (with mke2fs -d) we need to do the typical
loop to handle partial writes to make sure all of the data gets written.

Move that code to its own function.  This function also takes an offset
parameter, which makes it feel a bit like pwrite() (except that it does
modify the file offset).

Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
5 weeks agomke2fs: modify the fallback path for copying data
Allison Karlitskaya [Mon, 25 Nov 2024 08:46:30 +0000 (09:46 +0100)]
mke2fs: modify the fallback path for copying data

Right now we jump to the end as soon as we've found a method that works.
This is a reasonable approach because it's the last operation in the
function, but soon it won't be.  Switch to a logically-equivalent
alternative approach: keep trying until we find the approach that works,
dropping the `goto out`.  Now we can add code after this.

Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
5 weeks agodebugfs: abort reading a file on failure when dumping out a file
Theodore Ts'o [Fri, 23 May 2025 17:22:00 +0000 (13:22 -0400)]
debugfs: abort reading a file on failure when dumping out a file

If ext2fs_file_read() fails --- perhaps due to a corrupted file
system, or an I/O error --- avoid looping forever in dump_file().

This issue was pointed out in [1] by Quentin Kaiser but the commit
description was too confusing and specific to the user's particular
situation.

[1] https://github.com/tytso/e2fsprogs/pull/149

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: implement blocksize converters
Darrick J. Wong [Wed, 21 May 2025 22:43:17 +0000 (15:43 -0700)]
fuse2fs: implement blocksize converters

Before we implement iomap, add some helpers to convert bytes to fsblocks
and back.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786678247.1384866.5139178053250117853.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: replace ext2fs_{read,write}_inode with fuse2fs_{read,write}_inode
Darrick J. Wong [Wed, 21 May 2025 22:43:01 +0000 (15:43 -0700)]
fuse2fs: replace ext2fs_{read,write}_inode with fuse2fs_{read,write}_inode

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786678229.1384866.9795826246954895736.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: clean up open-coded ext2_inode_large -> ext2_inode casts
Darrick J. Wong [Wed, 21 May 2025 22:42:46 +0000 (15:42 -0700)]
fuse2fs: clean up open-coded ext2_inode_large -> ext2_inode casts

There's a typechecked helper for this now, so let's use it.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786678211.1384866.6557992647185012616.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: fix group membership checking in op_chmod
Darrick J. Wong [Wed, 21 May 2025 22:42:30 +0000 (15:42 -0700)]
fuse2fs: fix group membership checking in op_chmod

In the decade or so since I touched fuse2fs, libfuse3 has grown the
ability to read the group ids of a process making a chmod request.  So
now we actually /can/ determine if a file's gid is a in the group list
of the process that initiated a fuse request.  Let's implement that too.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786678066.1383760.15547379523110361909.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: propagate default ACLs to new children
Darrick J. Wong [Wed, 21 May 2025 22:42:14 +0000 (15:42 -0700)]
fuse2fs: propagate default ACLs to new children

generic/319 points out that we don't propagate the default ACL from a
directory into new children.  Do that, since that's expected behavior.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786678048.1383760.1562421474540065349.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: also ignore the nodelalloc mount option
Darrick J. Wong [Wed, 21 May 2025 22:41:59 +0000 (15:41 -0700)]
fuse2fs: also ignore the nodelalloc mount option

We don't support delalloc, so accept the nodelalloc option even if we do
nothing about it.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786678032.1383760.18384774850296194367.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: fix post-EOF preallocation clearing on truncation
Darrick J. Wong [Wed, 21 May 2025 22:41:43 +0000 (15:41 -0700)]
fuse2fs: fix post-EOF preallocation clearing on truncation

generic/092 shows that truncating a file to its current size does not
clean out post-eof preallocations like the kernel does.  Adopt the
kernel's behavior for consistency.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786678014.1383760.1321101978729586160.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: fix removing ea inodes when freeing a file
Darrick J. Wong [Wed, 21 May 2025 22:41:26 +0000 (15:41 -0700)]
fuse2fs: fix removing ea inodes when freeing a file

If the filesystem has ea_inode set, then each file that has xattrs might
have stored an xattr value in a separate inode.  These inodes also need
to be freed, so create a library function to do that, and call it from
the fuse2fs unlink method.  Seen by ext4/026.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677996.1383760.7408606469648643965.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: simplify reading and writing inodes
Darrick J. Wong [Wed, 21 May 2025 22:43:01 +0000 (15:43 -0700)]
fuse2fs: simplify reading and writing inodes

Wrap the inode read and write methods in a wrapper so that we don't have
to maintain all these silly casts and sizeof operators.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786678229.1384866.9795826246954895736.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: fix return value handling
Darrick J. Wong [Wed, 21 May 2025 22:41:11 +0000 (15:41 -0700)]
fuse2fs: fix return value handling

For the xattr functions, don't obliterate the return value of the file
system operation with an error code coming from ext2fs_xattrs_close
failing.  Granted, it doesn't ever fail (right now!) so this is mostly
just preening.

Also fix the obsolete op_truncate not to squash error returns.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677978.1383760.8801097477278077188.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: check for supported xattr name prefixes
Darrick J. Wong [Wed, 21 May 2025 22:40:55 +0000 (15:40 -0700)]
fuse2fs: check for supported xattr name prefixes

Ignore any xattr calls for name prefixes that the kernel doesn't also
support.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677959.1383760.12099114841852662650.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: fix fallocate zero range
Darrick J. Wong [Wed, 21 May 2025 22:40:39 +0000 (15:40 -0700)]
fuse2fs: fix fallocate zero range

Allow this flag when we're checking flags in op_fallocate.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677941.1383760.17359353030156900900.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: decode fuse_main error codes
Darrick J. Wong [Wed, 21 May 2025 22:40:23 +0000 (15:40 -0700)]
fuse2fs: decode fuse_main error codes

Translate the fuse_main return values into actual mount(8) style error
codes instead of returning 0 all the time, and print something to the
original stderr if something went wrong so that the user will know what
to do next.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677923.1383760.3429767121128890204.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: implement O_APPEND correctly
Darrick J. Wong [Wed, 21 May 2025 22:40:08 +0000 (15:40 -0700)]
fuse2fs: implement O_APPEND correctly

Try to implement append-only files correctly.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677905.1383760.14021746902005874478.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: check the immutable flag in more places
Darrick J. Wong [Wed, 21 May 2025 22:39:52 +0000 (15:39 -0700)]
fuse2fs: check the immutable flag in more places

We need to check the immutable flag in a few more places that try to
modify files.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677887.1383760.16795876049190712906.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: return EPERM for write access to EXT2_IMMUTABLE_FL files
Darrick J. Wong [Wed, 21 May 2025 22:39:36 +0000 (15:39 -0700)]
fuse2fs: return EPERM for write access to EXT2_IMMUTABLE_FL files

The kernel drivers return EPERM for attempts to write to immutable
files, so switch the error code.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677869.1383760.310634374176043971.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: make bad magic numbers report a corruption error too
Darrick J. Wong [Wed, 21 May 2025 22:39:21 +0000 (15:39 -0700)]
fuse2fs: make bad magic numbers report a corruption error too

Report bad magic numbers as corruption errors too.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677853.1383760.10493605429423115597.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: make internal state corruption a hard error
Darrick J. Wong [Wed, 21 May 2025 22:39:05 +0000 (15:39 -0700)]
fuse2fs: make internal state corruption a hard error

If the in-memory contents are wrong, then we want to report a corruption
error and shut down the filesystem.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677837.1383760.2730283507317571357.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: make filesystem corruption a hard error
Darrick J. Wong [Wed, 21 May 2025 22:38:49 +0000 (15:38 -0700)]
fuse2fs: make filesystem corruption a hard error

Change __translate_error so that all the EXT2_*_CORRUPTED codes generate
a hard error returning EUCLEAN which is the same errno that the kernel
uses.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677819.1383760.15120011207188940205.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: rearrange check_inum_access parameters a bit
Darrick J. Wong [Wed, 21 May 2025 22:38:34 +0000 (15:38 -0700)]
fuse2fs: rearrange check_inum_access parameters a bit

Pass the struct fuse2fs pointer to check_inum_access so that we can do
some more rearranging in the next patches.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677801.1383760.3807372754743381596.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: implement O_TRUNC correctly
Darrick J. Wong [Wed, 21 May 2025 22:38:18 +0000 (15:38 -0700)]
fuse2fs: implement O_TRUNC correctly

Actually truncate files on open with O_TRUNC.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677783.1383760.5736479713431403960.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: make removexattr work correctly
Darrick J. Wong [Wed, 21 May 2025 22:38:02 +0000 (15:38 -0700)]
fuse2fs: make removexattr work correctly

removexattr is supposed to return ENODATA if the xattr name does not
exist, so we need to check for it explicitly.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677765.1383760.11407998503450588763.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: enable processing of acls in the kernel
Darrick J. Wong [Wed, 21 May 2025 22:37:47 +0000 (15:37 -0700)]
fuse2fs: enable processing of acls in the kernel

Let the kernel process ACLs.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677747.1383760.17294624757826456720.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: allow some control over acls
Darrick J. Wong [Wed, 21 May 2025 22:37:31 +0000 (15:37 -0700)]
fuse2fs: allow some control over acls

Allow some control over whether or not ACLs get used, though for kernel
mode it will always be enabled.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677729.1383760.10883670792875770541.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: fix CLI argument parsing leaks
Darrick J. Wong [Wed, 21 May 2025 22:37:15 +0000 (15:37 -0700)]
fuse2fs: fix CLI argument parsing leaks

Fix some memory leaks in the argument parser.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677711.1383760.4278826288377195178.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: flip parameter order in __translate_error
Darrick J. Wong [Wed, 21 May 2025 22:37:00 +0000 (15:37 -0700)]
fuse2fs: flip parameter order in __translate_error

Flip the parameter order in __translate_error so that it matches
translate_error.  I wasted too much time debugging a memory corruption
that happened because I converted translate_error to __translate_error
when developing the next patch and the compiler didn't warn me about
mismatched types.

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/174786677693.1383760.5102016357729108965.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: fix error return handling in op_truncate
Darrick J. Wong [Wed, 21 May 2025 22:36:44 +0000 (15:36 -0700)]
fuse2fs: fix error return handling in op_truncate

Fix a couple of bugs with the errcode/ret handling in op_truncate.
First, we need to return ESTALE for a zero inumber because there is no
inode zero in an ext* filesystem.  Second, we need to return negative
errno for failures to libfuse, not raw errcode_t.

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/174786677675.1383760.13355151028679279614.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: support XATTR_CREATE/REPLACE in setxattr
Darrick J. Wong [Wed, 21 May 2025 22:36:28 +0000 (15:36 -0700)]
fuse2fs: support XATTR_CREATE/REPLACE in setxattr

Fix the setxattr implementation to support the create and replace flags
instead of performing an upsert regardless of inputs.

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/174786677657.1383760.12232239908991346763.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: compact all the boolean flags in struct fuse2fs
Darrick J. Wong [Wed, 21 May 2025 22:36:13 +0000 (15:36 -0700)]
fuse2fs: compact all the boolean flags in struct fuse2fs

Compact all the booleans into u8 fields.  I'd go further and turn them
into bitfields but that breaks the fuse argument parsing macros, which
compute the offset of the structure fields, and gcc won't let us do that
to bit fields.  Still, 136 -> 112 bytes isn't bad.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677639.1383760.16546264802006958473.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: fix cache size parsing
Darrick J. Wong [Wed, 21 May 2025 22:35:57 +0000 (15:35 -0700)]
fuse2fs: fix cache size parsing

Fix the cache size parsing of "cache_size=%s" -- the "%" is at position
11, not 12.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677621.1383760.4131011398253369305.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: clean up error messages
Darrick J. Wong [Wed, 21 May 2025 22:35:41 +0000 (15:35 -0700)]
fuse2fs: clean up error messages

Instead of horridly line-wrapping multi-line messages that are printed
during mounting, let's just expand them to be one source code line per
printed line.  This will make it a lot easier for someone who sees the
these errors to grep the source code to find out where they came from.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677603.1383760.817536477752866097.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agolibext2fs: fix livelock in the unix io manager
Darrick J. Wong [Wed, 21 May 2025 22:35:26 +0000 (15:35 -0700)]
libext2fs: fix livelock in the unix io manager

generic/441 found a livelock in the unix IO manager.  Let's say that
write_primary_superblock decides to call io_channel_set_blksize in the
process of writing the primary super.

unix_set_blksize then takes the cache and bounce mutexes, and calls
flush_cached_blocks.  If there are dirty blocks in the cache, they will
be written with raw_write_blk.  Unfortunately, that function tries to
take the bounce mutex, which we already hold.  At that point, we
livelock fuse2fs.

Cc: linux-ext4@vger.kernel.org # v1.46.0
Fixes: f20627cc639ab6 ("libext2fs: add threading support to the I/O manager abstraction")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677584.1383760.1107858755678329558.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agolibext2fs: fix unix io manager invalidation
Darrick J. Wong [Wed, 21 May 2025 22:35:10 +0000 (15:35 -0700)]
libext2fs: fix unix io manager invalidation

flush_cached_blocks does not invalidate clean blocks from the block
cache.  From reading all the call sites, it looks like they all actually
want the cache to be empty on successful return, so adjust the
implementation to do this.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677566.1383760.15330012260577982100.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5 weeks agofuse2fs: fix portability issues when compiling on MacOS
Theodore Ts'o [Fri, 23 May 2025 03:53:40 +0000 (23:53 -0400)]
fuse2fs: fix portability issues when compiling on MacOS

Fix a number of portability issues which resulted in fuse2fs failing
to build on MacOS.

*) MacOS doesn't have the timespec fields in struct stat; we have
   a autoconf test to check for this, so use it.

*) The portable way to print off_t values is to use
   printf("%jd", (intmax_t) d);  The cast is necessary to avoid
   type mismatch warnings.

*) Define FUSE_DARWIN_ENABLE_EXTENSIONS=0 to avoid using random
   structs such as struct fuse_darwin_attr and struct fuse_darwin_fill_dir_t
   in the fuse operation function prototypes.

With these fixes, fuse2fs successfully compiles and works with
MacFuse on macOS Sequoia.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agoe2fsck: fix int vs ssize_t warnings from Coverity
Theodore Ts'o [Thu, 22 May 2025 05:24:52 +0000 (01:24 -0400)]
e2fsck: fix int vs ssize_t warnings from Coverity

Addresses-Coverity-Bug: 1605231
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agoutil: fix potential OOB write in the symlinks build helper
Theodore Ts'o [Thu, 22 May 2025 04:53:02 +0000 (00:53 -0400)]
util: fix potential OOB write in the symlinks build helper

Addresses-Coverity-Bug: 1432089
Addresses-Coverity-Bug: 1433050
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agolibext2fs: fix error paths after alocation failures
Theodore Ts'o [Thu, 22 May 2025 00:16:08 +0000 (20:16 -0400)]
libext2fs: fix error paths after alocation failures

Addresses-Coverity-Bug: 1647960
Addresses-Coverity-Bug: 1647961
Fixes: a5a6bcfb4820 ("libext2fs: make unix_io cache size configurable")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agoFix signed/unsigned compiler warnings
Theodore Ts'o [Wed, 21 May 2025 17:44:24 +0000 (13:44 -0400)]
Fix signed/unsigned compiler warnings

Fixes: a5a6bcfb4820 ("libext2fs: make unix_io cache size configurable")
Fixes: 516805378ff5 ("fuse2fs: allow setting of the cache size")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agomisc: link filefrag with the ext2fs library
Theodore Ts'o [Wed, 21 May 2025 17:41:11 +0000 (13:41 -0400)]
misc: link filefrag with the ext2fs library

If inline functions are not enabled, filefrag needs to link with
libext2fs to be able to access the ext2fs_log_u32() function.

Fixes: be4834c29e6f ("misc: deduplicate log2/log10 functions")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agolibext2fs: add missing function prototypes for new inline functions
Theodore Ts'o [Wed, 21 May 2025 16:33:15 +0000 (12:33 -0400)]
libext2fs: add missing function prototypes for new inline functions

Fixes: be4834c29e6f ("misc: deduplicate log2/log10 functions")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agocreate_inode: fix build failure when libarchive is not present
Theodore Ts'o [Wed, 21 May 2025 16:10:30 +0000 (12:10 -0400)]
create_inode: fix build failure when libarchive is not present

Add the new flags parameter to the version of __populate_fs_from_tar()
used when libarchive is not present to fix a build failure.

Fixes: 2dc83ca9b892 ("create_inode: pass no_copy_xattr via a flag...")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agomke2fs: call create_inode's populate_fs3() requesting EXT2FS_LINK_APPEND
Theodore Ts'o [Tue, 20 May 2025 03:24:31 +0000 (23:24 -0400)]
mke2fs: call create_inode's populate_fs3() requesting EXT2FS_LINK_APPEND

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agocreate_inode: pass no_copy_xattr via a flag instead of using a global variable
Theodore Ts'o [Tue, 20 May 2025 02:33:12 +0000 (22:33 -0400)]
create_inode: pass no_copy_xattr via a flag instead of using a global variable

Add a new function, populate_fs3(), which takes a new flags parameter,
with the first flag being POPULATE_FS_NO_COPY_XATTRS.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agolibext2fs: add the EXT2FS_LINK_APPEND flag to ext2fs_link()
Theodore Ts'o [Tue, 20 May 2025 02:07:55 +0000 (22:07 -0400)]
libext2fs: add the EXT2FS_LINK_APPEND flag to ext2fs_link()

Add a flag which only tries to add the new directory entry to the last
block in the directory.  This is helpful avoids mke2fs -d offering
from an O(n**2) performance bottleneck when adding a large number of
files to a directory.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agomke2fs: don't set the raid stripe for non-rotational devices by default
Theodore Ts'o [Sun, 4 May 2025 18:07:14 +0000 (14:07 -0400)]
mke2fs: don't set the raid stripe for non-rotational devices by default

The ext4 block allocator is not at all efficient when it is asked to
enforce RAID alignment.  It is especially bad for flash-based devices,
or when the file system is highly fragmented.  For non-rotational
devices, it's fine to set the stride parameter (which controls
spreading the allocation bitmaps across the RAID component devices,
which always makessense); but for the stripe parameter (which asks the
ext4 block alocator to try _very_ hard to find RAID stripe aligned
devices) it's probably not a good idea.

Add new mke2fs.conf parameters with the defaults:

[defaults]
   set_raid_stride = always
   set_raid_stripe = disk

Even for RAID arrays based on HDD's, we can still have problems for
highly fragmented file systems.  This will need to solved in the
kernel, probably by having some kind of wall clock or CPU time
limitation for each block allocation or adding some kind of
optimization which is faster than using our current buddy bitmap
implementation, especially if the stripe size is not multiple of a
power of two.  But for SSD's, it's much less likely to make sense even
if we have an optimized block allocator, because if you've paid $$$
for a flash-based RAID array, the cost/benefit tradeoffs of doing less
optimized stripe RMW cycles versus the block allocator time and CPU
overhead is harder to justify without a lot of optimization effort.

If and when we can improve the ext4 kernel implementation (and it gets
rolled out to users using LTS kernels), we can change the defaults.
And of course, system administrators can always change
/etc/mke2fs.conf settings.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agolibext2fs: rename fls() to find_last_bit_set()
Theodore Ts'o [Wed, 21 May 2025 14:39:53 +0000 (10:39 -0400)]
libext2fs: rename fls() to find_last_bit_set()

In unix_io.c, rename fls() since some systems may already define it in
a system header file to fix a portability problem on MacOS.  The name
"find_last_bit_set" is a bit more self-descriptive anyway.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: allow setting of the cache size
Darrick J. Wong [Thu, 24 Apr 2025 21:46:49 +0000 (14:46 -0700)]
fuse2fs: allow setting of the cache size

Create a CLI option so that we can adjust the disk cache size, and set
it to 32MB by default.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065600.1161238.586822649522740605.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: allow use of direct io for disk access
Darrick J. Wong [Thu, 24 Apr 2025 21:46:33 +0000 (14:46 -0700)]
fuse2fs: allow use of direct io for disk access

Allow users to ask for O_DIRECT for disk accesses so that block device
writes won't be throttled.  This should improve latency, but will put
a lot more pressure on the disk cache.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065581.1161238.969038742323698265.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agolibext2fs: use hashing for cache lookups in unix IO manager
Darrick J. Wong [Thu, 24 Apr 2025 21:46:15 +0000 (14:46 -0700)]
libext2fs: use hashing for cache lookups in unix IO manager

Use a hash to avoid the linear scan.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065563.1161238.5896022194303080059.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agolibext2fs: make unix_io cache size configurable
Darrick J. Wong [Thu, 24 Apr 2025 21:45:59 +0000 (14:45 -0700)]
libext2fs: make unix_io cache size configurable

Make it so that we can reconfigure the unix IO manager cache size.
fuse2fs might want more than 32 blocks.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065546.1161238.2653341081512215032.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: report cache hits and misses at unmount time
Darrick J. Wong [Thu, 24 Apr 2025 21:45:43 +0000 (14:45 -0700)]
fuse2fs: report cache hits and misses at unmount time

Log the IO cache's hit and miss quantities at unmount time.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065528.1161238.4178228996070898927.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: delegate access control decisions to the kernel
Darrick J. Wong [Thu, 24 Apr 2025 21:45:28 +0000 (14:45 -0700)]
fuse2fs: delegate access control decisions to the kernel

In "kernel" mode (aka allow_others + default_permissions), the kernel
enforces all the access control for us.  Therefore, we don't need to do
any checking of our own.  Create a purpose-built helper to detect this
situation and turn off all the access controlling.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065373.1161102.14873909355987419902.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: refactor sysadmin predicate
Darrick J. Wong [Thu, 24 Apr 2025 21:45:12 +0000 (14:45 -0700)]
fuse2fs: refactor sysadmin predicate

Refactor the code that decides if an access is being made by the
superuser into a helper, which we'll use to fix more permissions
problems in the next patch.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065355.1161102.13914905314262828953.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: report inode number and file type via readdir
Darrick J. Wong [Thu, 24 Apr 2025 21:44:57 +0000 (14:44 -0700)]
fuse2fs: report inode number and file type via readdir

Report the inode number and file type in readdir to speed up directory
iteration a bit.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065213.1160461.4431922817174080124.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: fix FITRIM validation
Darrick J. Wong [Thu, 24 Apr 2025 21:44:41 +0000 (14:44 -0700)]
fuse2fs: fix FITRIM validation

Fix the validation here to match the kernel, and report the number of
blocks trimmed.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065195.1160461.15575039465292160279.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: disable renameat2
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.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065177.1160461.684615549721279410.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: report real inode numbers
Darrick J. Wong [Thu, 24 Apr 2025 21:44:10 +0000 (14:44 -0700)]
fuse2fs: report real inode numbers

Report real inode numbers in stat instead of letting fuse invent them
for us.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065159.1160461.12395515521619169511.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: update new child timestamps during mkdir/symlink
Darrick J. Wong [Thu, 24 Apr 2025 21:43:54 +0000 (14:43 -0700)]
fuse2fs: update new child timestamps during mkdir/symlink

These two file creation functions fail to update the timestamps of the
new child file, unlike the others (mknod/creat).  Fix that.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065141.1160461.7342685341356901806.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: support changing newer iflags
Darrick J. Wong [Thu, 24 Apr 2025 21:43:39 +0000 (14:43 -0700)]
fuse2fs: support changing newer iflags

Redefine FUSE2FS_MODIFIABLE_IFLAGS so that userspace can modify any
flags that the kernel can, except for the ones that fuse2fs lacks the
ability to change.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065123.1160461.3149004980436873980.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: support getting and setting via struct fsxattr
Darrick J. Wong [Thu, 24 Apr 2025 21:43:23 +0000 (14:43 -0700)]
fuse2fs: support getting and setting via struct fsxattr

Support querying xfs file attributes in fuse2fs so that the vfs
getattr/setattr functions continue to work.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065105.1160461.8046224721957766466.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: add supportable mount options from the kernel
Darrick J. Wong [Thu, 24 Apr 2025 21:43:07 +0000 (14:43 -0700)]
fuse2fs: add supportable mount options from the kernel

Add all the kernel mount options that we can actually support.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065087.1160461.16716917319493753291.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: clamp timestamps that are being written to disk
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.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065069.1160461.14751120886781323020.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: report nanoseconds resolution through getattr
Darrick J. Wong [Thu, 24 Apr 2025 21:42:36 +0000 (14:42 -0700)]
fuse2fs: report nanoseconds resolution through getattr

Report the nanonseconds component of timestamps via getattr, and tell
fuse that we actually support nanosecond granularity.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065051.1160461.5080284869849276746.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: add an easy option for emulating kernel access behaviors
Darrick J. Wong [Thu, 24 Apr 2025 21:42:20 +0000 (14:42 -0700)]
fuse2fs: add an easy option for emulating kernel access behaviors

By default, fuse doesn't allow processes with a uid/gid that don't match
those of the server process to access the fuse mount, it doesn't allow
suid files or devices, and it relies on the fuse server to perform
permissions checking.  This is a secure default for very untrusted
filesystems, but it's possible that we might actually want to allow
general access to an ext4 filesystem as part of containerizing the ext4
metadata parsing.  In other words, we want the kernel access control
behavior.

Add an "kernel" mount option that moves most of the access permissions
interpretation back into the kernel, and logs mount/unmount/error
messages to dmesg.  Right now this is mostly useful for fstests, so we
leave it off by default.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065033.1160461.1393760776420459221.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: log names of xattrs being set/get/removed
Darrick J. Wong [Thu, 24 Apr 2025 21:42:05 +0000 (14:42 -0700)]
fuse2fs: log names of xattrs being set/get/removed

Actually record the names of the xattrs being modified to make it easier
to debug fstests failures.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065016.1160461.12942341433377716292.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: remove posix acl translation
Darrick J. Wong [Thu, 24 Apr 2025 21:41:49 +0000 (14:41 -0700)]
fuse2fs: remove posix acl translation

Remove the POSIX ACL format translation since libext2fs takes care of
that now.

Fixes: 0ee1eaf70c257e ("libext2fs: translate internal ext4 acl to Posix ACL in ext2fs_xattr_[sg]et()")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553064997.1160461.14235157932332388225.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: implement zero range
Darrick J. Wong [Thu, 24 Apr 2025 21:41:34 +0000 (14:41 -0700)]
fuse2fs: implement zero range

Implement FALLOC_FL_ZERO_RANGE.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553064980.1160461.9850792727586596449.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 weeks agofuse2fs: return -EOPNOTSUPP when we don't recognize a fallocate mode
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

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553064961.1160461.9412670014664878384.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>