Blame sysdeps/unix/sysv/linux/preadv64v2.c

Packit 6c4009
/* Linux implementation of preadv2 (LFS version).
Packit 6c4009
   Copyright (C) 2017-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <sys/uio.h>
Packit 6c4009
#include <sysdep-cancel.h>
Packit 6c4009
Packit 6c4009
#if !defined(__NR_preadv64v2) && defined(__NR_preadv2)
Packit 6c4009
# define __NR_preadv64v2 __NR_preadv2
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
ssize_t
Packit 6c4009
preadv64v2 (int fd, const struct iovec *vector, int count, off64_t offset,
Packit 6c4009
	    int flags)
Packit 6c4009
{
Packit 6c4009
#ifdef __NR_preadv64v2
Packit 6c4009
  ssize_t result = SYSCALL_CANCEL (preadv64v2, fd, vector, count,
Packit 6c4009
				   LO_HI_LONG (offset), flags);
Packit Service 3e830d
  if (result >= 0)
Packit 6c4009
    return result;
Packit 6c4009
#endif
Packit 6c4009
  /* Trying to emulate the preadv2 syscall flags is troublesome:
Packit 6c4009
Packit 6c4009
     * We can not temporary change the file state of the O_DSYNC and O_SYNC
Packit 6c4009
       flags to emulate RWF_{D}SYNC (attempts to change the state of using
Packit 6c4009
       fcntl are silently ignored).
Packit 6c4009
Packit 6c4009
     * IOCB_HIPRI requires the file opened in O_DIRECT and uses an internal
Packit 6c4009
       semantic not provided by any other flag (O_NONBLOCK for instance).  */
Packit 6c4009
Packit 6c4009
  if (flags != 0)
Packit 6c4009
    {
Packit 6c4009
      __set_errno (ENOTSUP);
Packit 6c4009
      return -1;
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
  if (offset == -1)
Packit 6c4009
    return __readv (fd, vector, count);
Packit 6c4009
  else
Packit 6c4009
    return preadv64 (fd, vector, count, offset);
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
#ifdef __OFF_T_MATCHES_OFF64_T
Packit 6c4009
strong_alias (preadv64v2, preadv2)
Packit 6c4009
#endif