Linux filesystem development
 help / color / mirror / Atom feed
* [PATCH v2 0/6] fat: support O_TMPFILE
@ 2026-11-30  8:57 Christian Brauner
  2026-11-30  8:57 ` [PATCH v2 1/6] fat: add fat_new_inode() Christian Brauner
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Christian Brauner @ 2026-11-30  8:57 UTC (permalink / raw)
  To: OGAWA Hirofumi
  Cc: linux-kernel, linux-fsdevel, Christian Brauner (Amutable),
	Alexander Mikhalitsyn

This adds O_TMPFILE support to vfat and msdos.

Currently, every O_TMPFILE open on FAT fails with EOPNOTSUPP and
userspace falls back to creating a named temporary file and renaming it
into place. systemd does that in bootctl when it writes to the ESP.

FAT can do O_TMPFILE just fine. It already handles files without a
directory entry: when an open file is unlinked i_pos is reset to 0,
writing the inode does nothing and the clusters are freed when the
inode is evicted. An O_TMPFILE simply starts out in that state.

The only tricky part is linkat(). FAT has no hard links so I added a
->link() that only gives an O_TMPFILE its first name. Everything else
still fails with EPERM. Adding just ->tmpfile() would've been a
regression. systemd only falls back to the named temporary file if the
O_TMPFILE open fails. If the open succeeds it calls linkat() and gives
up if that fails.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Changes in v2:
- Add fat_new_inode() and use it in fat_build_inode() and fat_tmpfile().
- Add msdos_format_new_name() and use it in msdos_create(),
  msdos_mkdir() and msdos_link().
- Add the FIXME comments Hirofumi asked for to vfat_link() and
  msdos_link().
- Add Alexander's Reviewed-by to the patches from v1.
- Link to v1: https://patch.msgid.link/20261126-work-fat-tmpfile-v1-0-3bca7b2dbc20@kernel.org

---
Christian Brauner (6):
      fat: add fat_new_inode()
      fat: add msdos_format_new_name()
      fat: add fat_tmpfile()
      fat: support O_TMPFILE on vfat
      fat: support O_TMPFILE on msdos
      selftests/filesystems: add FAT O_TMPFILE tests

 fs/fat/fat.h                                       |   2 +
 fs/fat/inode.c                                     |  58 +++-
 fs/fat/namei_msdos.c                               | 103 +++++--
 fs/fat/namei_vfat.c                                |  47 +++
 tools/testing/selftests/filesystems/fat/.gitignore |   1 +
 tools/testing/selftests/filesystems/fat/Makefile   |   2 +-
 tools/testing/selftests/filesystems/fat/config     |   1 +
 .../selftests/filesystems/fat/run_fat_tests.sh     |  41 +++
 tools/testing/selftests/filesystems/fat/tmpfile.c  | 324 +++++++++++++++++++++
 9 files changed, 547 insertions(+), 32 deletions(-)
---
base-commit: 2dc60bd9975fc8666a13d58410499e06e6799ba9
change-id: 20261126-work-fat-tmpfile-0d0f49e95d8f


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-30  8:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30  8:57 [PATCH v2 0/6] fat: support O_TMPFILE Christian Brauner
2026-11-30  8:57 ` [PATCH v2 1/6] fat: add fat_new_inode() Christian Brauner
2026-11-30  8:57 ` [PATCH v2 2/6] fat: add msdos_format_new_name() Christian Brauner
2026-11-30  8:57 ` [PATCH v2 3/6] fat: add fat_tmpfile() Christian Brauner
2026-11-30  8:57 ` [PATCH v2 4/6] fat: support O_TMPFILE on vfat Christian Brauner
2026-11-30  8:57 ` [PATCH v2 5/6] fat: support O_TMPFILE on msdos Christian Brauner
2026-11-30  8:57 ` [PATCH v2 6/6] selftests/filesystems: add FAT O_TMPFILE tests Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox