Blame misc/mmap64.c

Packit Service 82fcde
/* Copyright (C) 1997-2018 Free Software Foundation, Inc.
Packit Service 82fcde
   This file is part of the GNU C Library.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 82fcde
   modify it under the terms of the GNU Lesser General Public
Packit Service 82fcde
   License as published by the Free Software Foundation; either
Packit Service 82fcde
   version 2.1 of the License, or (at your option) any later version.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 82fcde
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 82fcde
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 82fcde
   Lesser General Public License for more details.
Packit Service 82fcde
Packit Service 82fcde
   You should have received a copy of the GNU Lesser General Public
Packit Service 82fcde
   License along with the GNU C Library; if not, see
Packit Service 82fcde
   <http://www.gnu.org/licenses/>.  */
Packit Service 82fcde
Packit Service 82fcde
#include <errno.h>
Packit Service 82fcde
#include <sys/mman.h>
Packit Service 82fcde
#include <sys/types.h>
Packit Service 82fcde
Packit Service 82fcde
/* Map addresses starting near ADDR and extending for LEN bytes.  From
Packit Service 82fcde
   OFFSET into the file FD describes according to PROT and FLAGS.  If ADDR
Packit Service 82fcde
   is nonzero, it is the desired mapping address.  If the MAP_FIXED bit is
Packit Service 82fcde
   set in FLAGS, the mapping will be at ADDR exactly (which must be
Packit Service 82fcde
   page-aligned); otherwise the system chooses a convenient nearby address.
Packit Service 82fcde
   The return value is the actual mapping address chosen or MAP_FAILED
Packit Service 82fcde
   for errors (in which case `errno' is set).  A successful `mmap' call
Packit Service 82fcde
   deallocates any previous mapping for the affected region.  */
Packit Service 82fcde
Packit Service 82fcde
void *
Packit Service 82fcde
__mmap64 (void *addr, size_t len, int prot, int flags, int fd,
Packit Service 82fcde
	  __off64_t offset)
Packit Service 82fcde
{
Packit Service 82fcde
  off_t small_offset = (off_t) offset;
Packit Service 82fcde
Packit Service 82fcde
  if (small_offset != offset)
Packit Service 82fcde
    {
Packit Service 82fcde
      /* We cannot do this since the offset is too large.  */
Packit Service 82fcde
      __set_errno (EOVERFLOW);
Packit Service 82fcde
      return MAP_FAILED;
Packit Service 82fcde
    }
Packit Service 82fcde
Packit Service 82fcde
  return __mmap (addr, len, prot, flags, fd, small_offset);
Packit Service 82fcde
}
Packit Service 82fcde
Packit Service 82fcde
weak_alias (__mmap64, mmap64)
Packit Service 82fcde
libc_hidden_def (__mmap64)