diff options
| author | Daniel Palmer <daniel@thingy.jp> | 2026-01-05 05:36:28 +0300 |
|---|---|---|
| committer | Thomas Weißschuh <linux@weissschuh.net> | 2026-01-11 14:47:47 +0300 |
| commit | 109770cc81680b802ee983b09b61c3979240fd09 (patch) | |
| tree | 63506712b6b565de5df2838387bfeedec8bbe608 /tools/include | |
| parent | edaf30743185f6ed8e29dcb2f1d01e183c0b807b (diff) | |
| download | linux-109770cc81680b802ee983b09b61c3979240fd09.tar.xz | |
tools/nolibc: Add fseek() to stdio.h
A very basic wrapper around lseek() that implements fseek().
Signed-off-by: Daniel Palmer <daniel@thingy.jp>
Link: https://patch.msgid.link/20260105023629.1502801-3-daniel@thingy.jp
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Diffstat (limited to 'tools/include')
| -rw-r--r-- | tools/include/nolibc/stdio.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h index 6904252df97d..233318b0d0f0 100644 --- a/tools/include/nolibc/stdio.h +++ b/tools/include/nolibc/stdio.h @@ -272,6 +272,25 @@ char *fgets(char *s, int size, FILE *stream) } +/* fseek */ +static __attribute__((unused)) +int fseek(FILE *stream, long offset, int whence) +{ + int fd = fileno(stream); + off_t ret; + + ret = lseek(fd, offset, whence); + + /* lseek() and fseek() differ in that lseek returns the new + * position or -1, fseek() returns either 0 or -1. + */ + if (ret >= 0) + return 0; + + return -1; +} + + /* minimal printf(). It supports the following formats: * - %[l*]{d,u,c,x,p} * - %s |
