diff mbox series

[2/5] tools/nolibc: provide a fallback for lseek through llseek

Message ID 20240929-nolibc-csky-v1-2-bb28031a73b0@weissschuh.net
State New
Headers show
Series csky: add shutdown and nolibc support | expand

Commit Message

Thomas Weißschuh Sept. 29, 2024, 9:47 p.m. UTC
Not all architectures implement the lseek syscall, for example csky for
which support will be added.
Provide a fallback implementation to the llseek syscall.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 tools/include/nolibc/sys.h | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index 7b82bc3cf107439a3f09f98b99d4d540ffb9ba2a..b3b78343647177c9e5ecb7261997b4f5e03fb8f5 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -595,6 +595,14 @@  off_t sys_lseek(int fd, off_t offset, int whence)
 {
 #ifdef __NR_lseek
 	return my_syscall3(__NR_lseek, fd, offset, whence);
+#elif defined(__NR_llseek)
+	off_t result;
+	int ret;
+
+	ret = my_syscall5(__NR_llseek, fd,
+			  sizeof(offset) > 4 ? offset >> 32 : 0,
+			  offset, &result, whence);
+	return ret ? ret : result;
 #else
 	return __nolibc_enosys(__func__, fd, offset, whence);
 #endif