fat: support O_TMPFILE
Get series with b4
b4 am [email protected] change-id 20261126-work-fat-tmpfile-0d0f49e95d8fVersions newest first
- v2 Latest6 patches 0 repliesNew
- 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 files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | fat: add fat_new_inode()fs/ | +22 | 0 replies | |
| 2/6 | fat: add msdos_format_new_name()fs/ | +22 | 0 replies | |
| 3/6 | fat: add fat_tmpfile()fs/ fs/ | +25 | 0 replies | |
| 4/6 | fat: support O_TMPFILE on vfatfs/ | +47 | 0 replies | |
| 5/6 | fat: support O_TMPFILE on msdosfs/ | +63 | 0 replies | |
| 6/6 | selftests/filesystems: add FAT O_TMPFILE teststools/ tools/ tools/ +2 more | +368 | 0 replies |
Reviews trailers per patch
4 of 6 patches have a Reviewed-by or Acked-by.
| Patch | Alexander Mikhalitsyn |
|---|---|
| 1/6 | |
| 2/6 | |
| 3/6 | R-b |
| 4/6 | R-b |
| 5/6 | R-b |
| 6/6 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
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