[PATCH 0/2] nolibc: Add sendfile()

Daniel Palmer posted 2 patches 4 weeks, 1 day ago
tools/include/nolibc/Makefile                |  1 +
tools/include/nolibc/nolibc.h                |  1 +
tools/include/nolibc/sys/sendfile.h          | 41 ++++++++++++
tools/testing/selftests/nolibc/nolibc-test.c | 70 ++++++++++++++++++++
4 files changed, 113 insertions(+)
create mode 100644 tools/include/nolibc/sys/sendfile.h
[PATCH 0/2] nolibc: Add sendfile()
Posted by Daniel Palmer 4 weeks, 1 day ago
This is another thing from my backlog[0] and seemed simple enough so
sending now. Also, this feels right for nolibc as it lets you move lots
of data around without needing to allocate memory or even transfer it
into userspace. I've used it to implement cp and dd in my 64KB userspace
for linux on the sega megadrive.

There is some 32bit weirdness again, I think I caught that and added
some static asserts to make sure it doesn't silently break.

Maybe the test should actually test the offset?

0 - fallocate(), static pie, sockets,...

Daniel Palmer (2):
  tools/nolibc: Add sendfile()
  selftests/nolibc: Add basic test for sendfile()

 tools/include/nolibc/Makefile                |  1 +
 tools/include/nolibc/nolibc.h                |  1 +
 tools/include/nolibc/sys/sendfile.h          | 41 ++++++++++++
 tools/testing/selftests/nolibc/nolibc-test.c | 70 ++++++++++++++++++++
 4 files changed, 113 insertions(+)
 create mode 100644 tools/include/nolibc/sys/sendfile.h

-- 
2.53.0
Re: [PATCH 0/2] nolibc: Add sendfile()
Posted by Thomas Weißschuh 4 weeks, 1 day ago
Aug 28, 2026 12:32:21 Daniel Palmer <daniel@thingy.jp>:

> This is another thing from my backlog[0] and seemed simple enough so
> sending now. Also, this feels right for nolibc as it lets you move lots
> of data around without needing to allocate memory or even transfer it
> into userspace. I've used it to implement cp and dd in my 64KB userspace
> for linux on the sega megadrive.
>
> There is some 32bit weirdness again, I think I caught that and added
> some static asserts to make sure it doesn't silently break.
>
> Maybe the test should actually test the offset?
>
> 0 - fallocate(), static pie, sockets,...
>
> Daniel Palmer (2):
>   tools/nolibc: Add sendfile()
>   selftests/nolibc: Add basic test for sendfile()

Looks good, thanks!
I have applied the  patches with some minor changes
and will push them out after -rc1.

> tools/include/nolibc/Makefile                |  1 +
> tools/include/nolibc/nolibc.h                |  1 +
> tools/include/nolibc/sys/sendfile.h          | 41 ++++++++++++
> tools/testing/selftests/nolibc/nolibc-test.c | 70 ++++++++++++++++++++
> 4 files changed, 113 insertions(+)
> create mode 100644 tools/include/nolibc/sys/sendfile.h
>
> --
> 2.53.0