diff options
author | ache <ache@FreeBSD.org> | 2015-10-28 14:40:02 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2015-10-28 14:40:02 +0000 |
commit | 64dac23af83b727e5f33d41dc5ecb1444c8c0c30 (patch) | |
tree | baa8aba8f21fff38237715019c7a521ac1e39e6a /lib/libc | |
parent | c641ee406283e8610464caba08dac1b0ffd2cfff (diff) | |
download | FreeBSD-src-64dac23af83b727e5f33d41dc5ecb1444c8c0c30.zip FreeBSD-src-64dac23af83b727e5f33d41dc5ecb1444c8c0c30.tar.gz |
Add _flags2 per jhb@ suggestion since no room left in _flags.
Rewrite O_APPEND flag checking using new __S2OAP flag.
MFC after: 3 weeks
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/stdio/fdopen.c | 3 | ||||
-rw-r--r-- | lib/libc/stdio/findfp.c | 1 | ||||
-rw-r--r-- | lib/libc/stdio/fopen.c | 3 | ||||
-rw-r--r-- | lib/libc/stdio/freopen.c | 4 | ||||
-rw-r--r-- | lib/libc/stdio/ftell.c | 3 | ||||
-rw-r--r-- | lib/libc/stdio/stdio.c | 3 |
6 files changed, 7 insertions, 10 deletions
diff --git a/lib/libc/stdio/fdopen.c b/lib/libc/stdio/fdopen.c index 8bd9c2d..fbe37e8 100644 --- a/lib/libc/stdio/fdopen.c +++ b/lib/libc/stdio/fdopen.c @@ -91,9 +91,8 @@ fdopen(int fd, const char *mode) * O_APPEND bit set, assert __SAPP so that __swrite() caller * will _sseek() to the end before write. */ - /* XXX: Reuse __SALC for O_APPEND. */ if (fdflags & O_APPEND) - fp->_flags |= __SALC; + fp->_flags2 |= __S2OAP; else if (oflags & O_APPEND) fp->_flags |= __SAPP; fp->_file = fd; diff --git a/lib/libc/stdio/findfp.c b/lib/libc/stdio/findfp.c index 0eabe82..b8bb5af 100644 --- a/lib/libc/stdio/findfp.c +++ b/lib/libc/stdio/findfp.c @@ -155,6 +155,7 @@ found: /* fp->_fl_mutex = NULL; */ /* once set always set (reused) */ fp->_orientation = 0; memset(&fp->_mbstate, 0, sizeof(mbstate_t)); + fp->_flags2 = 0; return (fp); } diff --git a/lib/libc/stdio/fopen.c b/lib/libc/stdio/fopen.c index b26f637..9ab61ba 100644 --- a/lib/libc/stdio/fopen.c +++ b/lib/libc/stdio/fopen.c @@ -92,8 +92,7 @@ fopen(const char * __restrict file, const char * __restrict mode) * fseek and ftell.) */ if (oflags & O_APPEND) { - /* XXX: Reuse __SALC for O_APPEND. */ - fp->_flags |= __SALC; + fp->_flags2 |= __S2OAP; (void)_sseek(fp, (fpos_t)0, SEEK_END); } return (fp); diff --git a/lib/libc/stdio/freopen.c b/lib/libc/stdio/freopen.c index 8b68bac..e0104c8 100644 --- a/lib/libc/stdio/freopen.c +++ b/lib/libc/stdio/freopen.c @@ -187,6 +187,7 @@ finish: fp->_lb._size = 0; fp->_orientation = 0; memset(&fp->_mbstate, 0, sizeof(mbstate_t)); + fp->_flags2 = 0; if (f < 0) { /* did not get it after all */ if (isopen) @@ -241,8 +242,7 @@ finish: * fseek and ftell.) */ if (oflags & O_APPEND) { - /* XXX: Reuse __SALC for O_APPEND. */ - fp->_flags |= __SALC; + fp->_flags2 |= __S2OAP; (void) _sseek(fp, (fpos_t)0, SEEK_END); } FUNLOCKFILE(fp); diff --git a/lib/libc/stdio/ftell.c b/lib/libc/stdio/ftell.c index 0d2222b..abb6da1 100644 --- a/lib/libc/stdio/ftell.c +++ b/lib/libc/stdio/ftell.c @@ -119,8 +119,7 @@ _ftello(FILE *fp, fpos_t *offset) if (HASUB(fp)) pos -= fp->_r; /* Can be negative at this point. */ } else if ((fp->_flags & __SWR) && fp->_p != NULL) { - /* XXX: Reuse __SALC for O_APPEND. */ - if (fp->_flags & (__SAPP|__SALC)) { + if ((fp->_flags & __SAPP) || (fp->_flags2 & __S2OAP)) { int serrno = errno; errno = 0; diff --git a/lib/libc/stdio/stdio.c b/lib/libc/stdio/stdio.c index fc2e74b..5d6fb9a 100644 --- a/lib/libc/stdio/stdio.c +++ b/lib/libc/stdio/stdio.c @@ -117,8 +117,7 @@ _swrite(FILE *fp, char const *buf, int n) ret = (*fp->_write)(fp->_cookie, buf, n); /* __SOFF removed even on success in case O_APPEND mode is set. */ if (ret >= 0) { - /* XXX: Reuse __SALC for O_APPEND. */ - if ((fp->_flags & __SOFF) && !(fp->_flags & __SALC) && + if ((fp->_flags & __SOFF) && !(fp->_flags2 & __S2OAP) && fp->_offset <= OFF_MAX - ret) fp->_offset += ret; else |