Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tools/nolibc: fold llseek fallback into lseek()

Align the implementation of the fallback handling inside sys_lseek()
with the rest of nolibc.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250821-nolibc-enosys-v1-5-4b63f2caaa89@weissschuh.net

+14 -28
+14 -28
tools/include/nolibc/sys.h
··· 594 594 #if defined(__NR_lseek) 595 595 return my_syscall3(__NR_lseek, fd, offset, whence); 596 596 #else 597 - return __nolibc_enosys(__func__, fd, offset, whence); 598 - #endif 599 - } 597 + __kernel_loff_t loff = 0; 598 + off_t result; 599 + int ret; 600 600 601 - static __attribute__((unused)) 602 - int sys_llseek(int fd, unsigned long offset_high, unsigned long offset_low, 603 - __kernel_loff_t *result, int whence) 604 - { 605 - #if defined(__NR_llseek) 606 - return my_syscall5(__NR_llseek, fd, offset_high, offset_low, result, whence); 607 - #else 608 - return __nolibc_enosys(__func__, fd, offset_high, offset_low, result, whence); 601 + /* Only exists on 32bit where nolibc off_t is also 32bit */ 602 + ret = my_syscall5(__NR_llseek, fd, 0, offset, &loff, whence); 603 + if (ret < 0) 604 + result = ret; 605 + else if (loff != (off_t)loff) 606 + result = -EOVERFLOW; 607 + else 608 + result = loff; 609 + 610 + return result; 609 611 #endif 610 612 } 611 613 612 614 static __attribute__((unused)) 613 615 off_t lseek(int fd, off_t offset, int whence) 614 616 { 615 - __kernel_loff_t loff = 0; 616 - off_t result; 617 - int ret; 618 - 619 - result = sys_lseek(fd, offset, whence); 620 - if (result == -ENOSYS) { 621 - /* Only exists on 32bit where nolibc off_t is also 32bit */ 622 - ret = sys_llseek(fd, 0, offset, &loff, whence); 623 - if (ret < 0) 624 - result = ret; 625 - else if (loff != (off_t)loff) 626 - result = -EOVERFLOW; 627 - else 628 - result = loff; 629 - } 630 - 631 - return __sysret(result); 617 + return __sysret(sys_lseek(fd, offset, whence)); 632 618 } 633 619 634 620