2 * Copyright (c) 1990 The Regents of the University of California.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * and/or other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 <<fopen64>>---open a large file
29 FILE *fopen64(const char *<[file]>, const char *<[mode]>);
30 FILE *_fopen64_r(void *<[reent]>,
31 const char *<[file]>, const char *<[mode]>);
34 <<fopen64>> is identical to <<fopen>> except it opens a large file that
35 is potentially >2GB in size. See <<fopen>> for further details.
38 <<fopen64>> return a file pointer which you can use for other file
39 operations, unless the file you requested could not be opened; in that
40 situation, the result is <<NULL>>. If the reason for failure was an
41 invalid string at <[mode]>, <<errno>> is set to <<EINVAL>>.
44 <<fopen64>> is a glibc extension.
46 Supporting OS subroutines required: <<close>>, <<fstat64>>, <<isatty>>,
47 <<lseek64>>, <<open64>>, <<read>>, <<sbrk>>, <<write>>.
50 /* Copied from fopen.c */
52 #if defined(LIBC_SCCS) && !defined(lint)
53 static char sccsid
[] = "%W% (Berkeley) %G%";
54 #endif /* LIBC_SCCS and not lint */
64 #ifdef __LARGE64_FILES
67 _fopen64_r (struct _reent
*ptr
,
75 if ((flags
= __sflags (ptr
, mode
, &oflags
)) == 0)
77 if ((fp
= __sfp (ptr
)) == NULL
)
80 if ((f
= _open64_r (ptr
, file
, oflags
, 0666)) < 0)
82 _newlib_sfp_lock_start ();
83 fp
->_flags
= 0; /* release */
84 #ifndef __SINGLE_THREAD__
85 __lock_close_recursive (fp
->_lock
);
87 _newlib_sfp_lock_end ();
91 _newlib_flockfile_start (fp
);
95 fp
->_cookie
= (void *) fp
;
97 fp
->_write
= __swrite64
;
99 fp
->_seek64
= __sseek64
;
100 fp
->_close
= __sclose
;
102 if (fp
->_flags
& __SAPP
)
103 _fseeko64_r (ptr
, fp
, 0, SEEK_END
);
106 if (__stextmode (fp
->_file
))
107 fp
->_flags
|= __SCLE
;
110 fp
->_flags
|= __SL64
;
112 _newlib_flockfile_end (fp
);
119 fopen64 (const char *file
,
122 return _fopen64_r (_REENT
, file
, mode
);
127 #endif /* __LARGE64_FILES */