This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[COMMITTED PATCH] BZ#15361: Make aio_fsync not check open modes.
- From: Roland McGrath <roland at hack dot frob dot com>
- To: libc-alpha at sourceware dot org
- Cc: Xavier Roche <roche+kml2 at exalead dot com>
- Date: Fri, 12 Apr 2013 13:11:33 -0700 (PDT)
- Subject: [COMMITTED PATCH] BZ#15361: Make aio_fsync not check open modes.
- References: <513EEF07 dot 5090901 at 3ds dot com> <20130408212729 dot ED7592C085 at topped-with-meat dot com> <5163BA06 dot 30600 at exalead dot com> <20130411225058 dot 989CB2C07B at topped-with-meat dot com> <5167A305 dot 1010506 at exalead dot com>
2013-04-12 Roland McGrath <roland@hack.frob.com>
Xavier Roche <roche+kml2@exalead.com>
[BZ #15361]
* sysdeps/pthread/aio_fsync.c (aio_fsync): Don't check open modes,
just that it's a file descriptor.
* manual/llio.texi (Synchronizing AIO Operations): Update description
for EBADF error from aio_fsync.
--- a/manual/llio.texi
+++ b/manual/llio.texi
@@ -2320,8 +2320,7 @@ successfully enqueued. Otherwise the return value is @math{-1} and
@item EAGAIN
The request could not be enqueued due to temporary lack of resources.
@item EBADF
-The file descriptor @code{aiocbp->aio_fildes} is not valid or not open
-for writing.
+The file descriptor @code{@var{aiocbp}->aio_fildes} is not valid.
@item EINVAL
The implementation does not support I/O synchronization or the @var{op}
parameter is other than @code{O_DSYNC} and @code{O_SYNC}.
--- a/sysdeps/pthread/aio_fsync.c
+++ b/sysdeps/pthread/aio_fsync.c
@@ -36,17 +36,14 @@
int
aio_fsync (int op, struct aiocb *aiocbp)
{
- int flags;
-
if (op != O_DSYNC && __builtin_expect (op != O_SYNC, 0))
{
__set_errno (EINVAL);
return -1;
}
- flags = fcntl (aiocbp->aio_fildes, F_GETFL);
- if (__builtin_expect (flags == -1, 0)
- || __builtin_expect ((flags & O_ACCMODE) == O_RDONLY, 0))
+ /* Verify that this is an open file descriptor. */
+ if (__glibc_unlikely (fcntl (aiocbp->aio_fildes, F_GETFL) == -1))
{
__set_errno (EBADF);
return -1;