2006-03-07 Eric Blake <ebb9@byu.net>
* libc/stdio/freopen.c (_freopen_r) [HAVE_FCNTL]: For NULL filename, allow read-only or write-only FILE atop O_RDWR file descriptor. * libc/stdio64/freopen64.c (_freopen64_r) [HAVE_FCNTL]: Likewise.
This commit is contained in:
parent
ddf12e6b76
commit
ce10f1789e
@ -1,3 +1,10 @@
|
|||||||
|
2006-03-07 Eric Blake <ebb9@byu.net>
|
||||||
|
|
||||||
|
* libc/stdio/freopen.c (_freopen_r) [HAVE_FCNTL]: For NULL
|
||||||
|
filename, allow read-only or write-only FILE atop O_RDWR file
|
||||||
|
descriptor.
|
||||||
|
* libc/stdio64/freopen64.c (_freopen64_r) [HAVE_FCNTL]: Likewise.
|
||||||
|
|
||||||
2006-03-07 Jeff Johnston <jjohnstn@redhat.com>
|
2006-03-07 Jeff Johnston <jjohnstn@redhat.com>
|
||||||
|
|
||||||
* libm/common/sf_isinf.c[_DOUBLE_IS_32BITS]: Undef isinf.
|
* libm/common/sf_isinf.c[_DOUBLE_IS_32BITS]: Undef isinf.
|
||||||
|
@ -56,10 +56,10 @@ it).
|
|||||||
<[file]> and <[mode]> are used just as in <<fopen>>.
|
<[file]> and <[mode]> are used just as in <<fopen>>.
|
||||||
|
|
||||||
If <[file]> is <<NULL>>, the underlying stream is modified rather than
|
If <[file]> is <<NULL>>, the underlying stream is modified rather than
|
||||||
closed. The file cannot change access mode (for example, if it was
|
closed. The file cannot be given a more permissive access mode (for
|
||||||
previously read-only, <[mode]> must be "r", "rb", or "rt"), but can
|
example, a <[mode]> of "w" will fail on a read-only file descriptor),
|
||||||
change status such as append or binary mode. If modification is not
|
but can change status such as append or binary mode. If modification
|
||||||
possible, failure occurs.
|
is not possible, failure occurs.
|
||||||
|
|
||||||
RETURNS
|
RETURNS
|
||||||
If successful, the result is the same as the argument <[fp]>. If the
|
If successful, the result is the same as the argument <[fp]>. If the
|
||||||
@ -148,12 +148,14 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
|
|||||||
#ifdef HAVE_FCNTL
|
#ifdef HAVE_FCNTL
|
||||||
int oldflags;
|
int oldflags;
|
||||||
/*
|
/*
|
||||||
* Reuse the file descriptor, but only if the access mode is
|
* Reuse the file descriptor, but only if the new access mode is
|
||||||
* unchanged. F_SETFL correctly ignores creation flags.
|
* equal or less permissive than the old. F_SETFL correctly
|
||||||
|
* ignores creation flags.
|
||||||
*/
|
*/
|
||||||
f = fp->_file;
|
f = fp->_file;
|
||||||
if ((oldflags = _fcntl_r (ptr, f, F_GETFL, 0)) == -1
|
if ((oldflags = _fcntl_r (ptr, f, F_GETFL, 0)) == -1
|
||||||
|| ((oldflags ^ oflags) & O_ACCMODE) != 0
|
|| ! ((oldflags & O_ACCMODE) == O_RDWR
|
||||||
|
|| ((oldflags ^ oflags) & O_ACCMODE) == 0)
|
||||||
|| _fcntl_r (ptr, f, F_SETFL, oflags) == -1)
|
|| _fcntl_r (ptr, f, F_SETFL, oflags) == -1)
|
||||||
f = -1;
|
f = -1;
|
||||||
#else
|
#else
|
||||||
|
@ -56,10 +56,10 @@ it).
|
|||||||
<[file]> and <[mode]> are used just as in <<fopen>>.
|
<[file]> and <[mode]> are used just as in <<fopen>>.
|
||||||
|
|
||||||
If <[file]> is <<NULL>>, the underlying stream is modified rather than
|
If <[file]> is <<NULL>>, the underlying stream is modified rather than
|
||||||
closed. The file cannot change access mode (for example, if it was
|
closed. The file cannot be given a more permissive access mode (for
|
||||||
previously read-only, <[mode]> must be "r", "rb", or "rt"), but can
|
example, a <[mode]> of "w" will fail on a read-only file descriptor),
|
||||||
change status such as append or binary mode. If modification is not
|
but can change status such as append or binary mode. If modification
|
||||||
possible, failure occurs.
|
is not possible, failure occurs.
|
||||||
|
|
||||||
RETURNS
|
RETURNS
|
||||||
If successful, the result is the same as the argument <[fp]>. If the
|
If successful, the result is the same as the argument <[fp]>. If the
|
||||||
@ -148,12 +148,14 @@ _DEFUN (_freopen64_r, (ptr, file, mode, fp),
|
|||||||
#ifdef HAVE_FCNTL
|
#ifdef HAVE_FCNTL
|
||||||
int oldflags;
|
int oldflags;
|
||||||
/*
|
/*
|
||||||
* Reuse the file descriptor, but only if the access mode is
|
* Reuse the file descriptor, but only if the new access mode is
|
||||||
* unchanged. F_SETFL correctly ignores creation flags.
|
* equal or less permissive than the old. F_SETFL correctly
|
||||||
|
* ignores creation flags.
|
||||||
*/
|
*/
|
||||||
f = fp->_file;
|
f = fp->_file;
|
||||||
if ((oldflags = _fcntl_r (ptr, f, F_GETFL, 0)) == -1
|
if ((oldflags = _fcntl_r (ptr, f, F_GETFL, 0)) == -1
|
||||||
|| ((oldflags ^ oflags) & O_ACCMODE) != 0
|
|| ! ((oldflags & O_ACCMODE) == O_RDWR
|
||||||
|
|| ((oldflags ^ oflags) & O_ACCMODE) == 0)
|
||||||
|| _fcntl_r (ptr, f, F_SETFL, oflags) == -1)
|
|| _fcntl_r (ptr, f, F_SETFL, oflags) == -1)
|
||||||
f = -1;
|
f = -1;
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user