Skip to content

Commit f11e156

Browse files
committed
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
1 parent fbd47de commit f11e156

1 file changed

Lines changed: 14 additions & 28 deletions

File tree

  • tools/include/nolibc

tools/include/nolibc/sys.h

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -594,41 +594,27 @@ off_t sys_lseek(int fd, off_t offset, int whence)
594594
#if defined(__NR_lseek)
595595
return my_syscall3(__NR_lseek, fd, offset, whence);
596596
#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;
600600

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;
609611
#endif
610612
}
611613

612614
static __attribute__((unused))
613615
off_t lseek(int fd, off_t offset, int whence)
614616
{
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));
632618
}
633619

634620

0 commit comments

Comments
 (0)