Skip to content

fat: support O_TMPFILE

Christian Brauner linux-fsdevel lkml 2 versions – New

Get series with b4
b4 am [email protected] change-id 20261126-work-fat-tmpfile-0d0f49e95d8f

Versions newest first

  1. v2 Latest6 patches 0 repliesNew
  2. v14 patches 4 repliesSuperseded

Changes in v2 from the cover letter

- 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/[email protected]

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6fat: add fat_new_inode()fs/fat/inode.c+22 -130 replies
2/6fat: add msdos_format_new_name()fs/fat/namei_msdos.c+22 -180 replies
3/6fat: add fat_tmpfile()fs/fat/fat.h fs/fat/inode.c+25 -00 replies
4/6fat: support O_TMPFILE on vfatfs/fat/namei_vfat.c+47 -00 replies
5/6fat: support O_TMPFILE on msdosfs/fat/namei_msdos.c+63 -00 replies
6/6selftests/filesystems: add FAT O_TMPFILE teststools/testing/selftests/filesystems/fat/.gitignore tools/testing/selftests/filesystems/fat/Makefile tools/testing/selftests/filesystems/fat/config +2 more+368 -10 replies

Reviews trailers per patch

4 of 6 patches have a Reviewed-by or Acked-by.

PatchAlexander Mikhalitsyn
1/6
2/6
3/6R-b
4/6R-b
5/6R-b
6/6R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/6] fat: support O_TMPFILE

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.

---
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/[email protected]

---
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