1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-24 02:04:21 +03:00

replace: copy_file_range()

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12033

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Ralph Boehme 2021-06-24 14:13:50 +02:00 committed by Jeremy Allison
parent 7d101c82df
commit 4dcc04228d
3 changed files with 46 additions and 1 deletions

View File

@ -1056,3 +1056,28 @@ const char *rep_getprogname(void)
#endif /* HAVE_PROGRAM_INVOCATION_SHORT_NAME */
}
#endif /* HAVE_GETPROGNAME */
#ifndef HAVE_COPY_FILE_RANGE
# ifdef HAVE_SYSCALL_COPY_FILE_RANGE
# include <sys/syscall.h>
# endif
ssize_t rep_copy_file_range(int fd_in,
loff_t *off_in,
int fd_out,
loff_t *off_out,
size_t len,
unsigned int flags)
{
# ifdef HAVE_SYSCALL_COPY_FILE_RANGE
return syscall(__NR_copy_file_range,
fd_in,
off_in,
fd_out,
off_out,
len,
flags);
# endif /* HAVE_SYSCALL_COPY_FILE_RANGE */
errno = ENOSYS;
return -1;
}
#endif /* HAVE_COPY_FILE_RANGE */

View File

@ -964,6 +964,16 @@ int rep_memset_s(void *dest, size_t destsz, int ch, size_t count);
const char *rep_getprogname(void);
#endif
#ifndef HAVE_COPY_FILE_RANGE
#define copy_file_range rep_copy_file_range
ssize_t rep_copy_file_range(int fd_in,
loff_t *off_in,
int fd_out,
loff_t *off_out,
size_t len,
unsigned int flags);
#endif /* HAVE_COPY_FILE_RANGE */
#ifndef FALL_THROUGH
# ifdef HAVE_FALLTHROUGH_ATTRIBUTE
# define FALL_THROUGH __attribute__ ((fallthrough))

View File

@ -454,6 +454,16 @@ def configure(conf):
conf.CHECK_FUNCS('getpwent_r getpwnam_r getpwuid_r epoll_create')
conf.CHECK_FUNCS('port_create')
conf.CHECK_FUNCS('getprogname')
if not conf.CHECK_FUNCS('copy_file_range'):
conf.CHECK_CODE('''
#include <sys/syscall.h>
#include <unistd.h>
syscall(SYS_copy_file_range,0,NULL,0,NULL,0,0);
''',
'HAVE_SYSCALL_COPY_FILE_RANGE',
msg='Checking whether we have copy_file_range system call')
if conf.CONFIG_SET('HAVE_COPY_FILE_RANGE') or conf.CONFIG_SET('HAVE_SYSCALL_COPY_FILE_RANGE'):
conf.DEFINE('USE_COPY_FILE_RANGE', 1)
conf.SET_TARGET_TYPE('attr', 'EMPTY')
@ -835,7 +845,7 @@ REPLACEMENT_FUNCTIONS = {
'strsep', 'strtok_r', 'strtoll', 'strtoull', 'setenv', 'unsetenv',
'utime', 'utimes', 'dup2', 'chown', 'link', 'readlink',
'symlink', 'lchown', 'realpath', 'memmem', 'vdprintf',
'dprintf', 'get_current_dir_name',
'dprintf', 'get_current_dir_name', 'copy_file_range',
'strerror_r', 'clock_gettime', 'memset_s'],
'timegm.c': ['timegm'],
# Note: C99_VSNPRINTF is not a function, but a special condition