1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-27 22:50:26 +03:00

configure: Centralize check for posix_fallocate

This checks for posix_fallocate unless we are sitting on an ancient glibc.
With this we don't need HAVE_BROKEN_POSIX_FALLOCATE anymore,
HAVE_POSIX_FALLOCATE will only be defined if we have a valid [g]libc.

./configure tested on Debian, FreeBSD (which does have posix_fallocate) and
OpenBSD (which does not have posix_fallocate). Also tested with changing the
not have an old-enough glibc around. All did the right thing.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Volker Lendecke 2017-08-22 17:09:01 +02:00 committed by Jeremy Allison
parent c66b214537
commit ab132ba7e5
3 changed files with 15 additions and 16 deletions

View File

@ -249,6 +249,18 @@ def configure(conf):
if conf.CONFIG_SET('HAVE_MEMALIGN'):
conf.CHECK_DECLS('memalign', headers='malloc.h')
# glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
if conf.CHECK_CODE('''
#define _XOPEN_SOURCE 600
#include <stdlib.h>
#if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4))
#error probably broken posix_fallocate
#endif
''',
'_POSIX_FALLOCATE_CAPABLE_LIBC',
msg='Checking for posix_fallocate-capable libc'):
conf.CHECK_FUNCS('posix_fallocate')
conf.CHECK_FUNCS('prctl dirname basename')
# libbsd on some platforms provides strlcpy and strlcat

View File

@ -438,7 +438,7 @@ int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf,
********************************************************************/
int sys_posix_fallocate(int fd, off_t offset, off_t len)
{
#if defined(HAVE_POSIX_FALLOCATE) && !defined(HAVE_BROKEN_POSIX_FALLOCATE)
#if defined(HAVE_POSIX_FALLOCATE)
return posix_fallocate(fd, offset, len);
#elif defined(F_RESVSP64)
/* this handles XFS on IRIX */

View File

@ -106,7 +106,7 @@ def configure(conf):
conf.CHECK_FUNCS('innetgr')
conf.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
conf.CHECK_FUNCS('setpriv setgidx setuidx setgroups syscall sysconf')
conf.CHECK_FUNCS('atexit grantpt posix_openpt fallocate posix_fallocate')
conf.CHECK_FUNCS('atexit grantpt posix_openpt fallocate')
conf.CHECK_FUNCS('fseeko setluid')
conf.CHECK_FUNCS('getpwnam', headers='sys/types.h pwd.h')
conf.CHECK_FUNCS('fdopendir')
@ -397,7 +397,7 @@ llseek _llseek __llseek _lseek __lseek
_lstat __lstat lutimes
__lxstat memalign mknod mlock mlockall munlock munlockall
_open __open _opendir __opendir
pathconf poll posix_fallocate
pathconf poll
posix_memalign pread _pread __pread
pwrite _pwrite __pwrite
rdchk _read __read _readdir __readdir
@ -1154,19 +1154,6 @@ err:
execute=True,
msg="Checking whether fcntl lock supports open file description locks")
# glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
if not conf.CHECK_CODE('''
#define _XOPEN_SOURCE 600
#include <stdlib.h>
#if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4))
#error probably broken posix_fallocate
#endif
''',
'_HAVE_UNBROKEN_POSIX_FALLOCATE',
msg='Checking for broken posix_fallocate'):
conf.DEFINE('HAVE_BROKEN_POSIX_FALLOCATE', '1')
conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec',
define='HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') # Linux, Solaris
conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimensec',