mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-24 19:51:11 +00:00
7a16bdbb9f
The fallback code of Linux wrapper for preadv2/pwritev2 executes regardless of the errno code for preadv2, instead of the case where the syscall is not supported. This fixes it by calling the fallback code iff errno is ENOSYS. The patch also adds tests for both invalid file descriptor and invalid iov_len and vector count. The only discrepancy between preadv2 and fallback code regarding error reporting is when an invalid flags are used. The fallback code bails out earlier with ENOTSUP instead of EINVAL/EBADF when the syscall is used. Checked on x86_64-linux-gnu on a 4.4.0 and 4.15.0 kernel. [BZ #23579] * misc/tst-preadvwritev2-common.c (do_test_with_invalid_fd): New test. * misc/tst-preadvwritev2.c, misc/tst-preadvwritev64v2.c (do_test): Call do_test_with_invalid_fd. * sysdeps/unix/sysv/linux/preadv2.c (preadv2): Use fallback code iff errno is ENOSYS. * sysdeps/unix/sysv/linux/preadv64v2.c (preadv64v2): Likewise. * sysdeps/unix/sysv/linux/pwritev2.c (pwritev2): Likewise. * sysdeps/unix/sysv/linux/pwritev64v2.c (pwritev64v2): Likewise.
38 lines
1.3 KiB
C
38 lines
1.3 KiB
C
/* Tests for preadv2 and pwritev2.
|
|
Copyright (C) 2016-2018 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
#define PREADV(__fd, __iov, __iovcnt, __offset) \
|
|
preadv2 (__fd, __iov, __iovcnt, __offset, 0)
|
|
|
|
#define PWRITEV(__fd, __iov, __iovcnt, __offset) \
|
|
pwritev2 (__fd, __iov, __iovcnt, __offset, 0)
|
|
|
|
#include "tst-preadvwritev-common.c"
|
|
#include "tst-preadvwritev2-common.c"
|
|
|
|
static int
|
|
do_test (void)
|
|
{
|
|
do_test_with_invalid_flags ();
|
|
do_test_without_offset ();
|
|
do_test_with_invalid_fd ();
|
|
do_test_with_invalid_iov ();
|
|
|
|
return do_test_with_offset (0);
|
|
}
|