[klibc] Add rewind() function

Add rewind() function - basically fseek + clearerr.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
diff --git a/usr/include/stdio.h b/usr/include/stdio.h
index 44f38a7..d6aec62 100644
--- a/usr/include/stdio.h
+++ b/usr/include/stdio.h
@@ -49,6 +49,7 @@
 __extern FILE *fdopen(int, const char *);
 __extern int fclose(FILE *);
 __extern int fseek(FILE *, off_t, int);
+__extern void rewind(FILE *);
 __extern int fputs(const char *, FILE *);
 __extern int puts(const char *);
 __extern int fputc(int, FILE *);
diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
index 96ff76a..d7335c2 100644
--- a/usr/klibc/Kbuild
+++ b/usr/klibc/Kbuild
@@ -61,7 +61,7 @@
 	  stdio/fclose.o stdio/fopen.o stdio/fdopen.o \
 	  stdio/openmode.o stdio/fxopen.o \
 	  stdio/fread.o stdio/fwrite.o stdio/fflush.o \
-	  stdio/fseek.o stdio/ftell.o stdio/fileno.o \
+	  stdio/fseek.o stdio/ftell.o stdio/rewind.o stdio/fileno.o \
 	  stdio/ungetc.o stdio/feof.o stdio/ferror.o
 
 klib-$(CONFIG_KLIBC_ERRLIST) += errlist.o
diff --git a/usr/klibc/stdio/rewind.c b/usr/klibc/stdio/rewind.c
new file mode 100644
index 0000000..f5d39fb
--- /dev/null
+++ b/usr/klibc/stdio/rewind.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+void rewind(FILE *f)
+{
+	if (!fseek(f, 0, SEEK_SET))
+		clearerr(f);
+}