From cad937c12d93653ed1bf548eed8fc1a178f991d8 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Wed, 17 Oct 2001 01:10:29 +0000 Subject: This commit makes large file support actually work (when enabled in the config file). I've tested this and it works for me. -Erik --- libc/stdio/Makefile | 14 ++++++-------- libc/stdio/stdio.c | 34 +++++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 17 deletions(-) (limited to 'libc/stdio') diff --git a/libc/stdio/Makefile b/libc/stdio/Makefile index 42983512e..c837ae3a1 100644 --- a/libc/stdio/Makefile +++ b/libc/stdio/Makefile @@ -24,14 +24,12 @@ TOPDIR=../../ include $(TOPDIR)Rules.mak MSRC=stdio.c -MOBJ=_stdio_init.o \ - _alloc_stdio_buffer.o _free_stdio_buffer_of_file.o _free_stdio_stream.o \ - clearerr.o feof.o ferror.o fileno.o \ - setbuffer.o setvbuf.o setbuf.o setlinebuf.o \ - fclose.o _fopen.o fopen.o freopen.o fdopen.o fflush.o fsfopen.o \ - fseek.o rewind.o ftell.o fgetpos.o fsetpos.o \ - fputc.o fgetc.o fgets.o gets.o fputs.o puts.o ungetc.o \ - fread.o fwrite.o getchar.o putchar.o _uClibc_fwrite.o _uClibc_fread.o +MOBJ=_stdio_init.o _alloc_stdio_buffer.o _free_stdio_buffer_of_file.o \ + _free_stdio_stream.o clearerr.o feof.o ferror.o fileno.o setbuffer.o \ + setvbuf.o setbuf.o setlinebuf.o fclose.o _fopen.o fopen.o freopen.o \ + fdopen.o fflush.o fsfopen.o fseek.o rewind.o ftell.o fgetpos.o fsetpos.o \ + fputc.o fgetc.o fgets.o gets.o fputs.o puts.o ungetc.o fread.o fwrite.o \ + getchar.o putchar.o _uClibc_fwrite.o _uClibc_fread.o fopen64.o MSRC2=printf.c MOBJ2=printf.o sprintf.o fprintf.o vprintf.o vsprintf.o vfprintf.o snprintf.o \ diff --git a/libc/stdio/stdio.c b/libc/stdio/stdio.c index e67408d12..f87a69416 100644 --- a/libc/stdio/stdio.c +++ b/libc/stdio/stdio.c @@ -53,7 +53,8 @@ extern off_t _uClibc_fread(unsigned char *buf, off_t bytes, FILE *fp); /* Used internally to actually open files */ extern FILE *__fopen __P((__const char *__restrict __filename, int __fd, - FILE *__restrict __stream, __const char *__restrict __mode)); + FILE *__restrict __stream, __const char *__restrict __mode, + int extra_modes)); /* Note: This def of READING is ok since 1st ungetc puts in buf. */ #define READING(fp) (fp->bufstart < fp->bufread) @@ -655,11 +656,12 @@ static __inline FILE *_alloc_stdio_stream(void) return fp; } -FILE *__fopen(fname, fd, fp, mode) +FILE *__fopen(fname, fd, fp, mode, extra_modes) const char *fname; int fd; FILE *fp; const char *mode; +int extra_modes; { FILE *nfp; unsigned char *p; @@ -671,13 +673,13 @@ const char *mode; /* Parse the mode string arg. */ switch (*mode++) { case 'r': /* read */ - open_mode = O_RDONLY; + open_mode = O_RDONLY | extra_modes; break; case 'w': /* write (create or truncate)*/ - open_mode = (O_WRONLY | O_CREAT | O_TRUNC); + open_mode = (O_WRONLY | O_CREAT | O_TRUNC | extra_modes); break; case 'a': /* write (create or append) */ - open_mode = (O_WRONLY | O_CREAT | O_APPEND); + open_mode = (O_WRONLY | O_CREAT | O_APPEND | extra_modes); break; default: /* illegal mode */ __set_errno(EINVAL); @@ -958,7 +960,7 @@ FILE *fp; FILE *fopen(const char *__restrict filename, const char *__restrict mode) { - return __fopen(filename, -1, NULL, mode); + return __fopen(filename, -1, NULL, mode, 0); } #endif @@ -974,7 +976,7 @@ FILE *freopen(__const char *__restrict filename, fp->mode &= (__MODE_FREEFIL | __MODE_FREEBUF); /* Reset the FILE modes. */ fp->mode |= _IOFBF; - return __fopen(filename, -1, fp, mode); + return __fopen(filename, -1, fp, mode, 0); } #endif @@ -986,7 +988,7 @@ FILE *fsfopen(__const char *__restrict filename, fp->bufstart = fp->unbuf; fp->bufend = fp->unbuf + sizeof(fp->unbuf); - return __fopen(filename, -1, fp, mode); + return __fopen(filename, -1, fp, mode, 0); } #endif @@ -994,7 +996,7 @@ FILE *fsfopen(__const char *__restrict filename, #undef fdopen FILE *fdopen(int fd, __const char *mode) { - return __fopen(NULL, fd, NULL, mode); + return __fopen(NULL, fd, NULL, mode, 0); } #endif @@ -1074,3 +1076,17 @@ int fsetpos(FILE *fp, __const fpos_t *pos) return EOF; } #endif + +#ifdef L_fopen64 +#ifdef __UCLIBC_HAVE_LFS__ +#ifndef O_LARGEFILE +#define O_LARGEFILE 0100000 +#endif +FILE *fopen64(const char *__restrict filename, + const char *__restrict mode) +{ + return __fopen(filename, -1, NULL, mode, O_LARGEFILE); +} +#endif /* __UCLIBC_HAVE_LFS__ */ +#endif + -- cgit v1.2.3