summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/fopen.c
Commit message (Collapse)AuthorAgeFilesLines
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-0/+2
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* Add _flags2 per jhb@ suggestion since no room left in _flags.Andrey A. Chernov2015-10-281-2/+1
| | | | | | | | | Rewrite O_APPEND flag checking using new __S2OAP flag. MFC after: 3 weeks Notes: svn path=/head/; revision=290110
* Since no room left in the _flags, reuse __SALC for O_APPEND.Andrey A. Chernov2015-10-241-1/+4
| | | | | | | | | | It helps to remove _fcntl() call from _ftello() and optimize seek position calculation in _swrite(). MFC after: 3 weeks Notes: svn path=/head/; revision=289863
* Convert libc/stdio from K&R to ANSI CEd Maste2013-04-231-3/+1
| | | | | | | And add '__restrict' where it appeared in the header prototypes Notes: svn path=/head/; revision=249810
* Renumber clauses to reduce diffs to other versionsEd Maste2013-04-231-1/+1
| | | | | | | | | | NetBSD, OpenBSD, and Android's Bionic all number the clauses 1 through 3, so follow suit to make comparison easier. Acked-by: imp@ Notes: svn path=/head/; revision=249808
* Fix a leak in the recent fixes for file descriptors > SHRT_MAX. In theJohn Baldwin2008-04-221-0/+1
| | | | | | | | | | | case of a file descriptor we can't handle, clear the FILE structure's flags so it can be reused. MFC after: 1 week Reported by: otto @ OpenBSD Notes: svn path=/head/; revision=178427
* Add <limits.h> for SHRT_MAX.John Baldwin2008-02-271-0/+1
| | | | | | | Pointy hat to: jhb Notes: svn path=/head/; revision=176629
* File descriptors are an int, but our stdio FILE object uses a short to holdJohn Baldwin2008-02-271-0/+13
| | | | | | | | | | | | | | | | | | | | them. Thus, any fd whose value is greater than SHRT_MAX is handled incorrectly (the short value is sign-extended when converted to an int). An unpleasant side effect is that if fopen() opens a file and gets a backing fd that is greater than SHRT_MAX, fclose() will fail and the file descriptor will be leaked. Better handle this by fixing fopen(), fdopen(), and freopen() to fail attempts to use a fd greater than SHRT_MAX with EMFILE. At some point in the future we should look at expanding the file descriptor in FILE to an int, but that is a bit complicated due to ABI issues. MFC after: 1 week Discussed on: arch Reviewed by: wollman Notes: svn path=/head/; revision=176628
* Per Regents of the University of Calfornia letter, remove advertisingWarner Losh2007-01-091-4/+0
| | | | | | | | | clause. # If I've done so improperly on a file, please let me know. Notes: svn path=/head/; revision=165903
* Add restrict type-qualifier.Mike Barcroft2002-10-121-2/+2
| | | | Notes: svn path=/head/; revision=104989
* Fix the style of the SCM ID's.David E. O'Brien2002-03-221-2/+2
| | | | | | | I believe have made all of libc .c's as consistent as possible. Notes: svn path=/head/; revision=92986
* Internal seeks are overoptimized. They should remember fp->_offset only forAndrey A. Chernov2001-09-021-2/+0
| | | | | | | | | | plain regular files, i.e. files with __SOPT flag set. Fix it, so ftell(stdout) always returns the same as lseek(1, 0, 1) now. NOTE: this bug was in original stdio code Notes: svn path=/head/; revision=82827
* Move all stdio internal flags processing and setting out of __sread(),Andrey A. Chernov2001-09-021-1/+1
| | | | | | | | | | | | | __swrite() and __sseek() to higher level. According to funopen(3) they all are just wrappers to something like standard read(2), write(2) and lseek(2), i.e. must not touch stdio internals because they are replaceable with any other functions knows nothing about stdio internals. See example of funopen(3) usage in sendmail sources f.e. NOTE: this is original stdio bug, not result of my range checkin added. Notes: svn path=/head/; revision=82807
* Initialize _offset to 0 in fopen(), it helps to optimize fseek/ftellAndrey A. Chernov2001-08-311-0/+2
| | | | Notes: svn path=/head/; revision=82654
* libc MT-safety, part 2.Daniel Eischen2001-02-111-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a lock to FILE. flockfile and friends are now implemented (for the most part) in libc. flockfile_debug is implemented in libc_r; I suppose it's about time to kill it but will do it in a future commit. Fix a potential deadlock in _fwalk in a threaded environment. A file flag (__SIGN) was added to stdio.h that, when set, tells _fwalk to ignore it in its walk. This seemed to be needed in refill.c because each file needs to be locked when flushing. Add a stub for pthread_self in libc. This is needed by flockfile which is allowed by POSIX to be recursive. Make fgetpos() error return value (-1) match man page. Remove recursive calls to locked functions (stdio); I think I've got them all, but I may have missed a couple. A few K&R -> ANSI conversions along with removal of a few instances of "register". $Id$ -> $FreeBSD$ in libc/stdio/rget.c Not objected to: -arch, a few months ago Notes: svn path=/head/; revision=72373
* Remove _THREAD_SAFE and make libc thread-safe by default byDaniel Eischen2001-01-241-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | adding (weak definitions to) stubs for some of the pthread functions. If the threads library is linked in, the real pthread functions will pulled in. Use the following convention for system calls wrapped by the threads library: __sys_foo - actual system call _foo - weak definition to __sys_foo foo - weak definition to __sys_foo Change all libc uses of system calls wrapped by the threads library from foo to _foo. In order to define the prototypes for _foo(), we introduce namespace.h and un-namespace.h (suggested by bde). All files that need to reference these system calls, should include namespace.h before any standard includes, then include un-namespace.h after the standard includes and before any local includes. <db.h> is an exception and shouldn't be included in between namespace.h and un-namespace.h namespace.h will define foo to _foo, and un-namespace.h will undefine foo. Try to eliminate some of the recursive calls to MT-safe functions in libc/stdio in preparation for adding a mutex to FILE. We have recursive mutexes, but would like to avoid using them if possible. Remove uneeded includes of <errno.h> from a few files. Add $FreeBSD$ to a few files in order to pass commitprep. Approved by: -arch Notes: svn path=/head/; revision=71579
* Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(),Jason Evans2000-01-271-1/+1
| | | | | | | | | | | | | | | | | | | | just use _foo() <-- foo(). In the case of a libpthread that doesn't do call conversion (such as linuxthreads and our upcoming libpthread), this is adequate. In the case of libc_r, we still need three names, which are now _thread_sys_foo() <-- _foo() <-- foo(). Convert all internal libc usage of: aio_suspend(), close(), fsync(), msync(), nanosleep(), open(), fcntl(), read(), and write() to _foo() instead of foo(). Remove all internal libc usage of: creat(), pause(), sleep(), system(), tcdrain(), wait(), and waitpid(). Make thread cancellation fully POSIX-compliant. Suggested by: deischen Notes: svn path=/head/; revision=56698
* Add three-tier symbol naming in support of POSIX thread cancellationJason Evans2000-01-121-1/+3
| | | | | | | | | points. For library functions, the pattern is __sleep() <-- _libc_sleep() <-- sleep(). The arrows represent weak aliases. For system calls, the pattern is _read() <-- _libc_read() <-- read(). Notes: svn path=/head/; revision=55837
* BSD 4.4 Lite Lib SourcesRodney W. Grimes1994-05-271-0/+84
Notes: svn path=/cvs2svn/branches/unlabeled-1.1.1/; revision=1573