mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 01:04:41 +01:00
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>
This commit is contained in:
parent
edaf307431
commit
109770cc81
1 changed files with 19 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue