Mercurial > dovecot > original-hg > dovecot-1.2
view src/lib/mmap-util.c @ 9191:b340ecb24469 HEAD
Fix VPATH build of RQUOTA support.
Some rpcgen derive #include "..." paths from the infile argument.
This will be off for VPATH builds, as the generated rquota_xdr.c
code will look in $(srcdir), but we'll generate the rquota.h file in
$(builddir). Play safe and copy rquota.x to $(builddir) first.
This fixes the build on openSUSE 11.1.
author | Matthias Andree <matthias.andree@gmx.de> |
---|---|
date | Tue, 07 Jul 2009 21:01:36 +0200 |
parents | b9faf4db2a9f |
children | 00cd9aacd03c |
line wrap: on
line source
/* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "mmap-util.h" #include <sys/stat.h> void *mmap_file(int fd, size_t *length, int prot) { struct stat st; if (fstat(fd, &st) < 0) return MAP_FAILED; if (st.st_size > SSIZE_T_MAX) { /* too large file to map into memory */ errno = EFBIG; return MAP_FAILED; } *length = (size_t)st.st_size; if (*length == 0) return NULL; i_assert(*length > 0 && *length < SSIZE_T_MAX); return mmap(NULL, *length, prot, MAP_SHARED, fd, 0); } void *mmap_ro_file(int fd, size_t *length) { return mmap_file(fd, length, PROT_READ); } void *mmap_rw_file(int fd, size_t *length) { return mmap_file(fd, length, PROT_READ | PROT_WRITE); } #ifndef HAVE_MADVISE int my_madvise(void *start ATTR_UNUSED, size_t length ATTR_UNUSED, int advice ATTR_UNUSED) { return 0; } #endif size_t mmap_get_page_size(void) { static size_t size = 0; if (size != 0) return size; size = getpagesize(); return size; }