[PATCH v3 0/2] nolibc: Add fallocate()

Daniel Palmer posted 2 patches 1 month, 2 weeks ago
There is a newer version of this series
tools/include/nolibc/arch-mips.h             | 11 ++++
tools/include/nolibc/fcntl.h                 | 33 ++++++++++
tools/include/nolibc/sys.h                   |  8 +++
tools/testing/selftests/nolibc/nolibc-test.c | 69 ++++++++++++++++++++
4 files changed, 121 insertions(+)
[PATCH v3 0/2] nolibc: Add fallocate()
Posted by Daniel Palmer 1 month, 2 weeks 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.

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 (2):
  tools/nolibc: fcntl: Add fallocate()
  selftests/nolibc: Add a very basic test for fallocate()

 tools/include/nolibc/arch-mips.h             | 11 ++++
 tools/include/nolibc/fcntl.h                 | 33 ++++++++++
 tools/include/nolibc/sys.h                   |  8 +++
 tools/testing/selftests/nolibc/nolibc-test.c | 69 ++++++++++++++++++++
 4 files changed, 121 insertions(+)

-- 
2.53.0
Re: [PATCH v3 0/2] nolibc: Add fallocate()
Posted by Thomas Weißschuh 1 month, 2 weeks ago
On 2026-05-01 01:41:23+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.
> 
> 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).

Can you elaborate on what is broken?

>    sparc32 doesn't seem to support fallocate() so made it skip
>    the test.
>  - Rebase on nolibc/for-next with the large file support bits.

(...)
Re: [PATCH v3 0/2] nolibc: Add fallocate()
Posted by Daniel Palmer 1 month, 2 weeks ago
Hi Thomas,

On Mon, 4 May 2026 at 01:21, Thomas Weißschuh <linux@weissschuh.net> wrote:
> Can you elaborate on what is broken?
>
> >    sparc32 doesn't seem to support fallocate() so made it skip
> >    the test.
> >  - Rebase on nolibc/for-next with the large file support bits.
>
> (...)

For loongarch I seem to be missing OVMF:

qemu-system-loongarch64 -display none -no-reboot -kernel
"/home/daniel/.cache/nolibc-tests/loongarch/arch/loongarch/boot/vmlinuz.efi"
-initrd initramfs.cpio -serial file:/dev/stdout -m 1G
-M virt -append "console=ttyS0,115200 panic=-1 " -bios
/usr/share/edk2//loongarch64/OVMF_CODE.fd  >
"/home/daniel/coding/cleantrees/linux-nolibc/tools/testing/selftests/nolibc/run.out"
qemu-system-loongarch64: Could not find ROM image
'/usr/share/edk2//loongarch64/OVMF_CODE.fd'
make: *** [Makefile.nolibc:341: run] Error 1

Debian doesn't seem to have a package for this.

For s390x, fixed now. Missing package.

For sh4, qemu-system-sh4 is 100% on one CPU and the test never
completes. I guess it's getting stuck during boot.

Thanks,

Daniel
Re: [PATCH v3 0/2] nolibc: Add fallocate()
Posted by Thomas Weißschuh 1 month, 2 weeks ago
On 2026-05-04 10:46:29+0900, Daniel Palmer wrote:
> On Mon, 4 May 2026 at 01:21, Thomas Weißschuh <linux@weissschuh.net> wrote:
> > Can you elaborate on what is broken?
> >
> > >    sparc32 doesn't seem to support fallocate() so made it skip
> > >    the test.
> > >  - Rebase on nolibc/for-next with the large file support bits.
> >
> > (...)
> 
> For loongarch I seem to be missing OVMF:
> 
> qemu-system-loongarch64 -display none -no-reboot -kernel
> "/home/daniel/.cache/nolibc-tests/loongarch/arch/loongarch/boot/vmlinuz.efi"
> -initrd initramfs.cpio -serial file:/dev/stdout -m 1G
> -M virt -append "console=ttyS0,115200 panic=-1 " -bios
> /usr/share/edk2//loongarch64/OVMF_CODE.fd  >
> "/home/daniel/coding/cleantrees/linux-nolibc/tools/testing/selftests/nolibc/run.out"
> qemu-system-loongarch64: Could not find ROM image
> '/usr/share/edk2//loongarch64/OVMF_CODE.fd'
> make: *** [Makefile.nolibc:341: run] Error 1
> 
> Debian doesn't seem to have a package for this.

There is this in trixie:

https://packages.debian.org/trixie/all/qemu-efi-loongarch64

Unfortunately the path to the firmware files differ between distros and
QEMU versions. There are standard JSON descriptors which could be
queried but no tool for that is provided...

(...)

> For sh4, qemu-system-sh4 is 100% on one CPU and the test never
> completes. I guess it's getting stuck during boot.

See commit b0aa5e4b087b ("sh: Fix fallout from ZERO_PAGE
consolidation"). I now merged v7.1-rc2 into the nolibc tree to get
this fix.


Thomas
Re: [PATCH v3 0/2] nolibc: Add fallocate()
Posted by Daniel Palmer 1 month, 2 weeks ago
Hi Thomas,

On Tue, 5 May 2026 at 00:33, Thomas Weißschuh <linux@weissschuh.net> wrote:
> > Debian doesn't seem to have a package for this.
>
> There is this in trixie:
>
> https://packages.debian.org/trixie/all/qemu-efi-loongarch64

For sid it is now /usr/share/qemu-efi-loongarch64/QEMU_EFI.fd
I've changed to that locally and the tests complete now.

> > For sh4, qemu-system-sh4 is 100% on one CPU and the test never
> > completes. I guess it's getting stuck during boot.
>
> See commit b0aa5e4b087b ("sh: Fix fallout from ZERO_PAGE
> consolidation"). I now merged v7.1-rc2 into the nolibc tree to get
> this fix.

SH4 is also completing now.

Thanks,

Daniel
Re: [PATCH v3 0/2] nolibc: Add fallocate()
Posted by Willy Tarreau 1 month, 2 weeks ago
On Fri, May 01, 2026 at 01:41:23AM +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.
> 
> 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.

The series looks good to me, I don't have any particular comment, but
let's wait for Thomas since he's been reviewing it from day one.

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

Thanks,
Willy