[PATCH v4 0/3] nolibc: Add fallocate()

Daniel Palmer posted 3 patches 1 month, 1 week ago
tools/include/nolibc/Makefile                |  1 +
tools/include/nolibc/arch-mips.h             | 11 +++
tools/include/nolibc/fcntl.h                 | 31 +++++++++
tools/include/nolibc/nolibc.h                |  1 +
tools/include/nolibc/sys.h                   |  8 +++
tools/include/nolibc/sys/statfs.h            | 50 ++++++++++++++
tools/testing/selftests/nolibc/nolibc-test.c | 70 ++++++++++++++++++++
7 files changed, 172 insertions(+)
create mode 100644 tools/include/nolibc/sys/statfs.h
[PATCH v4 0/3] nolibc: Add fallocate()
Posted by Daniel Palmer 1 month, 1 week ago
While poking around with my "static PIE for nommu" series I found
I needed fallocate(). Implementing it turned out a bit more
interesting than I thought it would be due to how the offset and
size need to be passed on 32bit machines.

v4:
 - Added statfs()...
 - Reworked the test a bit to use statfs() to work out if /tmp
   is a tmpfs or not and skip the test if it isn't. This skips
   the test on sparc32 where CONFIG_TMPFS=n.
 - Adding the needed bits to the sparc32 config to allow tmpfs
   to be enabled allows it to run and pass the test. I will check
   the changes and send a patch.
 - Cleaned up the if() around deciding how to pass the parameters
   for fallocate() based on the comments from David and Thomas.
 - Test passed on all of the supported targets.

v3:
 - Reworked the test a bit, ran it on all the targets I could get
   to run (s390, loongarch and sh currently don't work for me).
   sparc32 doesn't seem to support fallocate() so made it skip
   the test.
 - Rebase on nolibc/for-next with the large file support bits.

v2:
 - Addressed Thomas' comments
 - Trial and error'd a test for the arguments being passed correctly.
   Hopefully someone smarter than I am can tell if it actually works.

Daniel Palmer (3):
  tools/nolibc: fcntl: Add fallocate()
  tools/nolibc: Add statfs()
  selftests/nolibc: Add a very basic test for fallocate()

 tools/include/nolibc/Makefile                |  1 +
 tools/include/nolibc/arch-mips.h             | 11 +++
 tools/include/nolibc/fcntl.h                 | 31 +++++++++
 tools/include/nolibc/nolibc.h                |  1 +
 tools/include/nolibc/sys.h                   |  8 +++
 tools/include/nolibc/sys/statfs.h            | 50 ++++++++++++++
 tools/testing/selftests/nolibc/nolibc-test.c | 70 ++++++++++++++++++++
 7 files changed, 172 insertions(+)
 create mode 100644 tools/include/nolibc/sys/statfs.h


base-commit: bb2d82d41894cb30d836e9796ff67d2f9a71eccf
-- 
2.53.0
Re: [PATCH v4 0/3] nolibc: Add fallocate()
Posted by Willy Tarreau 1 month ago
Hi Daniel,

On Thu, May 07, 2026 at 06:03:50PM +0900, Daniel Palmer wrote:
> While poking around with my "static PIE for nommu" series I found
> I needed fallocate(). Implementing it turned out a bit more
> interesting than I thought it would be due to how the offset and
> size need to be passed on 32bit machines.
> 
> v4:
>  - Added statfs()...
>  - Reworked the test a bit to use statfs() to work out if /tmp
>    is a tmpfs or not and skip the test if it isn't. This skips
>    the test on sparc32 where CONFIG_TMPFS=n.
>  - Adding the needed bits to the sparc32 config to allow tmpfs
>    to be enabled allows it to run and pass the test. I will check
>    the changes and send a patch.
>  - Cleaned up the if() around deciding how to pass the parameters
>    for fallocate() based on the comments from David and Thomas.
>  - Test passed on all of the supported targets.
(...)

Thanks, the whole series looks good to me:

Acked-by: Willy Tarreau <w@1wt.eu>

Let's wait for Thomas who usually spots finer issues than me ;-)

Thanks,
Willy