glibc/sysdeps/generic
Adhemerval Zanella 0b727ed4d6 libio: Flush stream at freopen (BZ#21037)
As POSIX states [1] a freopen call should first flush the stream as if by a
call fflush.  C99 (n1256) and C11 (n1570) only states the function should
first close any file associated with the specific stream.  Although current
implementation only follow C specification, current BSD and other libc
implementation (musl) are in sync with POSIX and fflush the stream.

This patch change freopen{64} to fflush the stream before actually reopening
it (or returning if the stream does not support reopen).  It also changes the
Linux implementation to avoid a dynamic allocation on 'fd_to_filename'.

Checked on x86_64-linux-gnu.

	[BZ #21037]
	* libio/Makefile (tests): Add tst-memstream4 and tst-wmemstream4.
	* libio/freopen.c (freopen): Sync stream before reopen and adjust to
	new fd_to_filename interface.
	* libio/freopen64.c (freopen64): Likewise.
	* libio/tst-memstream.h: New file.
	* libio/tst-memstream4.c: Likewise.
	* libio/tst-wmemstream4.c: Likewise.
	* sysdeps/generic/fd_to_filename.h (fd_to_filename): Change signature.
	* sysdeps/unix/sysv/linux/fd_to_filename.h (fd_to_filename): Likewise
	and remove internal dynamic allocation.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/
2018-10-02 10:01:56 -03:00
..
net
netinet
nfs
sys
Makefile
_G_config.h
_itoa.h
a.out.h
abort-instr.h
aio_misc.h
allocalim.h
asm-syntax.h
atomic-machine.h
c++-types.data
confstr.h
device-nrs.h
dirstream.h
dl-cache.h
dl-dtprocnum.h
dl-dtv.h
dl-fcntl.h
dl-fileid.h
dl-fptr.h
dl-hash.h
dl-irel.h
dl-librecon.h
dl-lookupcfg.h
dl-machine.h
dl-mman.h
dl-osinfo.h
dl-procinfo.c
dl-procinfo.h
dl-procruntime.c
dl-prop.h x86: Support IBT and SHSTK in Intel CET [BZ #21598] 2018-07-16 14:08:27 -07:00
dl-sysdep.h
dl-tls.h
dl-unistd.h
dwarf2.h
elide.h
eloop-threshold.h
entry.h
errqueue.h
exit-thread.h
fd_to_filename.h libio: Flush stream at freopen (BZ#21037) 2018-10-02 10:01:56 -03:00
fenv_private.h Move fenv.h soft-float inlines from fenv_private.h to include/fenv.h. 2018-09-04 19:52:06 +00:00
fips-private.h
fix-fp-int-compare-invalid.h
fix-fp-int-convert-overflow.h
fix-int-fp-convert-zero.h
float128-abi.h
fork.h
fpu_control.h
framestate.c
gcc-compat.h
gccframe.h
get-rounding-mode.h
gmp-mparam.h
hp-timing-common.h
hp-timing.h
ifreq.h
ifunc-init.h
ifunc-sel.h
internal-signals.h
intr-msg.h
inttypes.h
ld.abilist
ldbl-classify-compat.h
ldconfig.h
ldsodefs.h
libBrokenLocale.abilist
libanl.abilist
libc-lock.h
libc-mmap.h
libc-start.h
libc-tsd.h
libc.abilist
libcrypt.abilist
libdl.abilist
libm-alias-double.h
libm-alias-float.h
libm-alias-float128.h
libm-alias-ldouble.h
libm-test-ulps Replace gen-libm-test.pl with gen-libm-test.py. 2018-08-09 15:34:12 +00:00
libm-test-ulps-name
libm.abilist
libnsl.abilist
libnss_compat.abilist
libnss_db.abilist
libnss_dns.abilist
libnss_files.abilist
libnss_hesiod.abilist
libnss_nis.abilist
libnss_nisplus.abilist
libpthread.abilist
libresolv.abilist
librt.abilist
libutil.abilist
link_map.h
linkmap.h
local-setxid.h
localplt.data
machine-gmon.h
machine-lock.h
machine-sp.h
malloc-alignment.h
malloc-machine.h
malloc-sysdep.h
math-barriers.h
math-nan-payload-double.h math: Merge strtod_nan_*.h into math-type-macros-*.h 2018-05-16 06:03:08 +02:00
math-nan-payload-float.h math: Merge strtod_nan_*.h into math-type-macros-*.h 2018-05-16 06:03:08 +02:00
math-tests-arch.h
math-tests-exceptions.h Move EXCEPTION_TESTS_* out of math-tests.h 2018-08-23 23:41:13 +00:00
math-tests-rounding.h Move ROUNDING_TESTS_* out of math-tests.h. 2018-08-22 12:25:50 +00:00
math-tests-snan-cast.h Move SNAN_TESTS_TYPE_CAST out of math-tests.h. 2018-08-01 11:18:57 +00:00
math-tests-snan-payload.h Move SNAN_TESTS_PRESERVE_PAYLOAD out of math-tests.h. 2018-08-01 11:21:16 +00:00
math-tests-snan.h Move SNAN_TESTS_* out of math-tests.h. 2018-08-10 19:22:01 +00:00
math-tests-trap-force.h Move EXCEPTION_SET_FORCES_TRAP out of math-tests.h. 2018-08-27 18:52:41 +00:00
math-tests-trap.h Move EXCEPTION_ENABLE_SUPPORTED out of math-tests.h. 2018-08-24 19:18:16 +00:00
math-tests.h Move EXCEPTION_SET_FORCES_TRAP out of math-tests.h. 2018-08-27 18:52:41 +00:00
math-type-macros-double.h math: Reverse include order in <math-type-macros-*.h> 2018-05-17 15:48:42 +02:00
math-type-macros-float.h math: Reverse include order in <math-type-macros-*.h> 2018-05-17 15:48:42 +02:00
math-type-macros-float128.h math: Reverse include order in <math-type-macros-*.h> 2018-05-17 15:48:42 +02:00
math-type-macros-ldouble.h math: Reverse include order in <math-type-macros-*.h> 2018-05-17 15:48:42 +02:00
math-type-macros.h Use copysign functions not __copysign functions in glibc libm. 2018-09-27 20:04:48 +00:00
math_ldbl.h
math_ldbl_opt.h
math_private.h Add new pow implementation 2018-09-19 10:04:51 +01:00
math_private_calls.h Use copysign functions not __copysign functions in glibc libm. 2018-09-27 20:04:48 +00:00
memcopy.h
memusage.h
nan-high-order-bit.h
not-cancel.h Fix Linux fcntl OFD locks for non-LFS architectures (BZ#20251) 2018-06-26 13:22:53 -03:00
not-errno.h
nscd-types.h
pagecopy.h
paths.h
profil-counter.h
pty-private.h
register-dump.h
rtld-lowlevel.h
safe-fatal.h
setjmpP.h
sigcontextinfo.h
siglist.h
sigset-cvt-mask.h
sigsetops.h
stackguard-macros.h
stackinfo.h
startup.h
stdint.h
stdio-lock.h
string_private.h
symbol-hacks.h
sysdep-cancel.h
sysdep.h
thread_state.h
tininess.h
tls-macros.h
tls-setup.h x86: Rename __glibc_reserved1 to feature_1 in tcbhead_t [BZ #22563] 2018-07-14 05:56:46 -07:00
tls.h
tst-audit.h
tst-stack-align.h
unsecvars.h
unwind-dw2-fde-glibc.c
unwind-dw2-fde.c
unwind-dw2-fde.h
unwind-dw2.c [BZ #20271] Add newlines in __libc_fatal calls. 2018-08-31 18:04:32 -07:00
unwind-pe.c
unwind-pe.h
unwind-resume.h
unwind.h
utmp-equal.h