build: improve meson build

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2021-09-23 14:05:24 +02:00
parent ad447e353d
commit db4af8c57e
No known key found for this signature in database
GPG Key ID: 8EB056D53EECB12D
23 changed files with 252 additions and 266 deletions

View File

@ -49,7 +49,7 @@
#endif #endif
/* Define setns() if missing from the C library */ /* Define setns() if missing from the C library */
#ifndef HAVE_SETNS #if !HAVE_SETNS
static inline int setns(int fd, int nstype) static inline int setns(int fd, int nstype)
{ {
#ifdef __NR_setns #ifdef __NR_setns

View File

@ -206,15 +206,24 @@ foreach ident : [
#include <unistd.h>'''], #include <unistd.h>'''],
['close_range', '''#include <unistd.h>'''], ['close_range', '''#include <unistd.h>'''],
['execveat', '''#include <unistd.h>'''], ['execveat', '''#include <unistd.h>'''],
['endmntent', '''#include <stdio.h>
#include <mntent.h>'''],
['faccessat', '''#include <fcntl.h> ['faccessat', '''#include <fcntl.h>
#include <unistd.h>'''], #include <unistd.h>'''],
['fexecve', '''#include <unistd.h>'''], ['fexecve', '''#include <unistd.h>'''],
['fgetln', '''#include <stdio.h>'''],
['fsconfig', '''#include <sys/mount.h>'''], ['fsconfig', '''#include <sys/mount.h>'''],
['fsmount', '''#include <sys/mount.h>'''], ['fsmount', '''#include <sys/mount.h>'''],
['fsopen', '''#include <sys/mount.h>'''], ['fsopen', '''#include <sys/mount.h>'''],
['fspick', '''#include <sys/mount.h>'''], ['fspick', '''#include <sys/mount.h>'''],
['getgrgid_r', '''#include <sys/types.h>
#include <grp.h>'''],
['getline', '''#include <stdio.h>'''],
['getsubopt', '''#include <stdlib.h>'''],
['gettid', '''#include <sys/types.h> ['gettid', '''#include <sys/types.h>
#include <unistd.h>'''], #include <unistd.h>'''],
['hasmntopt', '''#include <stdio.h>
#include <mntent.h>'''],
['kcmp', '''#include <linux/kcmp.h>'''], ['kcmp', '''#include <linux/kcmp.h>'''],
['keyctl', '''#include <sys/types.h> ['keyctl', '''#include <sys/types.h>
#include <keyutils.h>'''], #include <keyutils.h>'''],
@ -243,19 +252,21 @@ foreach ident : [
['renameat2', '''#include <stdio.h> ['renameat2', '''#include <stdio.h>
#include <fcntl.h>'''], #include <fcntl.h>'''],
['sethostname', '''#include <unistd.h>'''], ['sethostname', '''#include <unistd.h>'''],
['setmntent', '''#include <stdio.h>
#include <mntent.h>'''],
['setns', '''#include <sched.h>'''], ['setns', '''#include <sched.h>'''],
['signalfd', '''#include <sys/signalfd.h>'''], ['signalfd', '''#include <sys/signalfd.h>'''],
['statx', '''#include <sys/types.h> ['statx', '''#include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h>'''], #include <unistd.h>'''],
['strchrnul', '''#include <string.h>'''],
['strlcat', '''#include <string.h>'''], ['strlcat', '''#include <string.h>'''],
['strlcpy', '''#include <string.h>'''], ['strlcpy', '''#include <string.h>'''],
['unshare', '''#include <sched.h>'''], ['unshare', '''#include <sched.h>'''],
] ]
if cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE') have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
conf.set10('HAVE_' + ident[0].to_upper(), true) conf.set10('HAVE_' + ident[0].to_upper(), have)
endif
endforeach endforeach
sh = find_program('sh') sh = find_program('sh')
@ -335,32 +346,37 @@ if libcap_static.found()
conf.set10('HAVE_STATIC_LIBCAP', libcap_static.found()) conf.set10('HAVE_STATIC_LIBCAP', libcap_static.found())
endif endif
have = cc.has_function('strchrnul', prefix : '#include <string.h>', args : '-D_GNU_SOURCE')
conf.set10('HAVE_STRCHRNUL', have)
have = cc.has_function('openpty', prefix : '#include <pty.h>', args : '-D_GNU_SOURCE')
conf.set10('HAVE_OPENPTY', have)
config_h = configure_file(
output : 'config.h',
configuration : conf)
add_project_arguments('-include', 'config.h', language : 'c')
basic_includes = include_directories( basic_includes = include_directories(
'.',
'src', 'src',
'src/include', 'src/include')
'.')
liblxc_includes = [basic_includes, include_directories( liblxc_includes = [basic_includes, include_directories(
'src/lxc/cgroups', 'src/lxc/cgroups',
'src/lxc/lsm', 'src/lxc/lsm',
'src/lxc/storage')] 'src/lxc/storage')]
add_project_arguments('-include', 'config.h', language : 'c')
subdir('hooks')
subdir('src/include') subdir('src/include')
subdir('src/lxc/tools/include')
subdir('hooks')
subdir('src/lxc') subdir('src/lxc')
subdir('src/lxc/cmd')
subdir('src/lxc/tools')
config_h = configure_file(
output : 'config.h',
configuration : conf)
liblxc = shared_library( liblxc = shared_library(
'lxc', 'lxc',
version : liblxc_version, version : liblxc_version,
include_directories : tools_liblxc_includes, include_directories: liblxc_includes,
link_args : ['-DPIC'], link_args : ['-DPIC'],
c_args : ['-DPIC'], c_args : ['-DPIC'],
link_whole : [liblxc_static], link_whole : [liblxc_static],
@ -381,156 +397,11 @@ liblxc_dep = declare_dependency(
libselinux, libselinux,
libapparmor]) libapparmor])
public_programs = []
public_programs += executable(
'lxc-autostart',
tools_lxc_autostart_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-cgroup',
tools_lxc_cgroup_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-checkpoint',
tools_lxc_checkpoint_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-config',
tools_lxc_config_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-console',
tools_lxc_console_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-copy',
tools_lxc_copy_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-create',
tools_lxc_create_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-destroy',
tools_lxc_destroy_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-device',
tools_lxc_device_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-execute',
tools_lxc_execute_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-freeze',
tools_lxc_freeze_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-info',
tools_lxc_info_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-ls',
tools_lxc_ls_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-monitor',
tools_lxc_monitor_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-snapshot',
tools_lxc_snapshot_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-start',
tools_lxc_start_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-stop',
tools_lxc_stop_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-top',
tools_lxc_top_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-unfreeze',
tools_lxc_unfreeze_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-unshare',
tools_lxc_unshare_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-wait',
tools_lxc_wait_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
cmd_programs = [] cmd_programs = []
subdir('src/lxc/cmd')
public_programs = []
subdir('src/lxc/tools')
cmd_programs += executable( cmd_programs += executable(
'lxc-init', 'lxc-init',
@ -564,14 +435,20 @@ missing_syscalls = []
foreach tuple : [ foreach tuple : [
['bpf'], ['bpf'],
['close_range'], ['close_range'],
['endmntent'],
['execveat'], ['execveat'],
['faccessat'], ['faccessat'],
['fexecve'], ['strchrnul'],
['fgetln'],
['fsconfig'], ['fsconfig'],
['fsmount'], ['fsmount'],
['fsopen'], ['fsopen'],
['fspick'], ['fspick'],
['getgrgid_r'],
['getline'],
['getsubopt'],
['gettid'], ['gettid'],
['hasmntopt'],
['kcmp'], ['kcmp'],
['keyctl'], ['keyctl'],
['memfd_create'], ['memfd_create'],
@ -587,6 +464,7 @@ foreach tuple : [
['prlimit64'], ['prlimit64'],
['renameat2'], ['renameat2'],
['sethostname'], ['sethostname'],
['setmntent'],
['setns'], ['setns'],
['signalfd'], ['signalfd'],
['statx'], ['statx'],

View File

@ -8,89 +8,50 @@ netns_ifaddrs_sources = files(
'netns_ifaddrs.c', 'netns_ifaddrs.c',
'netns_ifaddrs.h') 'netns_ifaddrs.h')
if cc.has_function('getline', prefix : '#include <stdio.h>', args : '-D_GNU_SOURCE') if conf.get('HAVE_GETLINE') == 0
conf.set10('HAVE_GETLINE', true)
else
include_sources += files( include_sources += files(
'getline.c', 'getline.c',
'getline.h') 'getline.h')
endif endif
if cc.has_function('fexecve', prefix : '#include <unistd.h>', args : '-D_GNU_SOURCE') if conf.get('HAVE_FEXECVE') == 0
conf.set10('HAVE_FEXECVE', true)
else
include_sources += files( include_sources += files(
'fexecve.c', 'fexecve.c',
'fexecve.h') 'fexecve.h')
endif endif
getgr_headers = ''' if conf.get('HAVE_GETGRGID_R') == 0
#include <sys/types.h>
#include <grp.h>
'''
if cc.has_function('getgrgid_r', prefix : getgr_headers, args : '-D_GNU_SOURCE')
conf.set10('HAVE_GETGRGID_R', true)
else
include_sources += files( include_sources += files(
'getgrgid_r.c', 'getgrgid_r.c',
'getgrgid_r.h') 'getgrgid_r.h')
endif endif
mntent_headers = ''' if conf.get('HAVE_HASMNTOPT') == 0 or conf.get('HAVE_SETMNTENT') == 0 or conf.get('HAVE_ENDMNTENT') == 0
#include <stdio.h>
#include <mntent.h>
'''
have_hasmntopt = cc.has_function('hasmntopt', prefix : mntent_headers, args : '-D_GNU_SOURCE')
if have_hasmntopt
conf.set10('HAVE_HASMNTOPT', true)
endif
have_setmntent = cc.has_function('setmntent', prefix : mntent_headers, args : '-D_GNU_SOURCE')
if have_setmntent
conf.set10('HAVE_SETMNTENT', true)
endif
have_endmntent = cc.has_function('endmntent', prefix : mntent_headers, args : '-D_GNU_SOURCE')
if have_endmntent
conf.set10('HAVE_ENDMNTENT', true)
endif
if have_hasmntopt == false or have_setmntent == false or have_endmntent == false
include_sources += files( include_sources += files(
'lxcmntent.c', 'lxcmntent.c',
'lxcmntent.h') 'lxcmntent.h')
endif endif
if cc.has_function('strlcpy', prefix : '#include <string.h>', args : '-D_GNU_SOURCE') if conf.get('HAVE_STRLCPY') == 0
conf.set10('HAVE_STRLCPY', true)
else
include_sources += files( include_sources += files(
'strlcpy.c', 'strlcpy.c',
'strlcpy.h') 'strlcpy.h')
endif endif
if cc.has_function('strlcat', prefix : '#include <string.h>', args : '-D_GNU_SOURCE') if conf.get('HAVE_STRLCAT') == 0
conf.set10('HAVE_STRLCAT', true)
else
include_sources += files( include_sources += files(
'strlcat.c', 'strlcat.c',
'strlcat.h') 'strlcat.h')
endif endif
if cc.has_function('strchrnul', prefix : '#include <string.h>', args : '-D_GNU_SOURCE') if conf.get('HAVE_STRCHRNUL') == 0
conf.set10('HAVE_STRCHRNUL', true)
else
include_sources += files( include_sources += files(
'strchrnul.c', 'strchrnul.c',
'strchrnul.h') 'strchrnul.h')
endif endif
if cc.has_function('openpty', prefix : '#include <pty.h>', args : '-D_GNU_SOURCE') if conf.get('HAVE_OPENPTY') == 0
conf.set10('HAVE_OPENPTY', true)
else
include_sources += files( include_sources += files(
'openpty.c', 'openpty.c',
'openpty.h') 'openpty.h')

View File

@ -23,7 +23,7 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#ifndef HAVE_STRLCPY #if !HAVE_STRLCPY
#include "strlcpy.h" #include "strlcpy.h"
#endif #endif

View File

@ -20,7 +20,7 @@
#include "process_utils.h" #include "process_utils.h"
#include "utils.h" #include "utils.h"
#ifndef HAVE_STRLCPY #if !HAVE_STRLCPY
#include "strlcpy.h" #include "strlcpy.h"
#endif #endif

View File

@ -49,11 +49,11 @@
#include "syscall_wrappers.h" #include "syscall_wrappers.h"
#include "utils.h" #include "utils.h"
#ifndef HAVE_STRLCPY #if !HAVE_STRLCPY
#include "strlcpy.h" #include "strlcpy.h"
#endif #endif
#ifndef HAVE_STRLCAT #if !HAVE_STRLCAT
#include "strlcat.h" #include "strlcat.h"
#endif #endif

View File

@ -28,7 +28,7 @@
#include "bpf.h" #include "bpf.h"
#include "bpf_common.h" #include "bpf_common.h"
#ifndef HAVE_BPF #if !HAVE_BPF
static inline int bpf_lxc(int cmd, union bpf_attr *attr, size_t size) static inline int bpf_lxc(int cmd, union bpf_attr *attr, size_t size)
{ {
return syscall(__NR_bpf, cmd, attr, size); return syscall(__NR_bpf, cmd, attr, size);

View File

@ -80,7 +80,7 @@
#include <sys/capability.h> #include <sys/capability.h>
#endif #endif
#ifndef HAVE_STRLCAT #if !HAVE_STRLCAT
#include "strlcat.h" #include "strlcat.h"
#endif #endif
@ -94,11 +94,11 @@
#include "prlimit.h" #include "prlimit.h"
#endif #endif
#ifndef HAVE_STRLCPY #if !HAVE_STRLCPY
#include "strlcpy.h" #include "strlcpy.h"
#endif #endif
#ifndef HAVE_STRCHRNUL #if !HAVE_STRCHRNUL
#include "strchrnul.h" #include "strchrnul.h"
#endif #endif

View File

@ -35,11 +35,11 @@
#include "parse.h" #include "parse.h"
#include "utils.h" #include "utils.h"
#ifndef HAVE_STRLCPY #if !HAVE_STRLCPY
#include "strlcpy.h" #include "strlcpy.h"
#endif #endif
#ifndef HAVE_STRLCAT #if !HAVE_STRLCAT
#include "strlcat.h" #include "strlcat.h"
#endif #endif

View File

@ -23,7 +23,7 @@
#include "parse.h" #include "parse.h"
#include "utils.h" #include "utils.h"
#ifndef HAVE_STRLCPY #if !HAVE_STRLCPY
#include "strlcpy.h" #include "strlcpy.h"
#endif #endif

View File

@ -34,7 +34,7 @@
#include <mntent.h> #include <mntent.h>
#endif #endif
#ifndef HAVE_STRLCPY #if !HAVE_STRLCPY
#include "strlcpy.h" #include "strlcpy.h"
#endif #endif

View File

@ -24,7 +24,7 @@
#include "memory_utils.h" #include "memory_utils.h"
#include "utils.h" #include "utils.h"
#ifndef HAVE_STRLCPY #if !HAVE_STRLCPY
#include "strlcpy.h" #include "strlcpy.h"
#endif #endif

View File

@ -76,7 +76,7 @@
#include <mntent.h> #include <mntent.h>
#endif #endif
#ifndef HAVE_STRLCPY #if !HAVE_STRLCPY
#include "include/strlcpy.h" #include "include/strlcpy.h"
#endif #endif

View File

@ -731,7 +731,7 @@ enum {
#define hweight32(w) __const_hweight32(w) #define hweight32(w) __const_hweight32(w)
#define hweight64(w) __const_hweight64(w) #define hweight64(w) __const_hweight64(w)
#ifndef HAVE___ALIGNED_U64 #if !HAVE___ALIGNED_U64
#define __aligned_u64 __u64 __attribute__((aligned(8))) #define __aligned_u64 __u64 __attribute__((aligned(8)))
#endif #endif
@ -739,7 +739,7 @@ enum {
#define BITS_PER_TYPE(type) (sizeof(type) * 8) #define BITS_PER_TYPE(type) (sizeof(type) * 8)
#define LAST_BIT_PER_TYPE(type) (BITS_PER_TYPE(type) - 1) #define LAST_BIT_PER_TYPE(type) (BITS_PER_TYPE(type) - 1)
#ifndef HAVE_SYS_PERSONALITY_H #if !HAVE_SYS_PERSONALITY_H
#define PER_LINUX 0x0000 #define PER_LINUX 0x0000
#define PER_LINUX32 0x0008 #define PER_LINUX32 0x0008
#endif #endif

View File

@ -254,7 +254,7 @@ __hidden extern pid_t lxc_raw_legacy_clone(unsigned long flags, int *pidfd);
__hidden extern pid_t lxc_raw_clone_cb(int (*fn)(void *), void *args, unsigned long flags, __hidden extern pid_t lxc_raw_clone_cb(int (*fn)(void *), void *args, unsigned long flags,
int *pidfd); int *pidfd);
#ifndef HAVE_EXECVEAT #if !HAVE_EXECVEAT
static inline int execveat(int dirfd, const char *pathname, char *const argv[], static inline int execveat(int dirfd, const char *pathname, char *const argv[],
char *const envp[], int flags) char *const envp[], int flags)
{ {

View File

@ -62,7 +62,7 @@
#include <sys/capability.h> #include <sys/capability.h>
#endif #endif
#ifndef HAVE_STRLCPY #if !HAVE_STRLCPY
#include "strlcpy.h" #include "strlcpy.h"
#endif #endif

View File

@ -28,11 +28,11 @@
#include "macro.h" #include "macro.h"
#include "memory_utils.h" #include "memory_utils.h"
#ifndef HAVE_STRLCPY #if !HAVE_STRLCPY
#include "strlcpy.h" #include "strlcpy.h"
#endif #endif
#ifndef HAVE_STRLCAT #if !HAVE_STRLCAT
#include "strlcat.h" #include "strlcat.h"
#endif #endif

View File

@ -10,15 +10,15 @@
#include "initutils.h" #include "initutils.h"
#include "macro.h" #include "macro.h"
#ifndef HAVE_STRLCAT #if !HAVE_STRLCAT
#include "strlcat.h" #include "strlcat.h"
#endif #endif
#ifndef HAVE_STRLCPY #if !HAVE_STRLCPY
#include "strlcpy.h" #include "strlcpy.h"
#endif #endif
#ifndef HAVE_STRCHRNUL #if !HAVE_STRCHRNUL
#include "strchrnul.h" #include "strchrnul.h"
#endif #endif

View File

@ -54,7 +54,7 @@ static inline long __keyctl(int cmd, unsigned long arg2, unsigned long arg3,
#define F_SEAL_WRITE 0x0008 #define F_SEAL_WRITE 0x0008
#endif #endif
#ifndef HAVE_MEMFD_CREATE #if !HAVE_MEMFD_CREATE
static inline int memfd_create_lxc(const char *name, unsigned int flags) static inline int memfd_create_lxc(const char *name, unsigned int flags)
{ {
return syscall(__NR_memfd_create, name, flags); return syscall(__NR_memfd_create, name, flags);
@ -64,7 +64,7 @@ static inline int memfd_create_lxc(const char *name, unsigned int flags)
extern int memfd_create(const char *name, unsigned int flags); extern int memfd_create(const char *name, unsigned int flags);
#endif #endif
#ifndef HAVE_PIVOT_ROOT #if !HAVE_PIVOT_ROOT
static inline int pivot_root(const char *new_root, const char *put_old) static inline int pivot_root(const char *new_root, const char *put_old)
{ {
return syscall(__NR_pivot_root, new_root, put_old); return syscall(__NR_pivot_root, new_root, put_old);
@ -74,7 +74,7 @@ extern int pivot_root(const char *new_root, const char *put_old);
#endif #endif
/* Define sethostname() if missing from the C library */ /* Define sethostname() if missing from the C library */
#ifndef HAVE_SETHOSTNAME #if !HAVE_SETHOSTNAME
static inline int sethostname(const char *name, size_t len) static inline int sethostname(const char *name, size_t len)
{ {
return syscall(__NR_sethostname, name, len); return syscall(__NR_sethostname, name, len);
@ -82,14 +82,14 @@ static inline int sethostname(const char *name, size_t len)
#endif #endif
/* Define setns() if missing from the C library */ /* Define setns() if missing from the C library */
#ifndef HAVE_SETNS #if !HAVE_SETNS
static inline int setns(int fd, int nstype) static inline int setns(int fd, int nstype)
{ {
return syscall(__NR_setns, fd, nstype); return syscall(__NR_setns, fd, nstype);
} }
#endif #endif
#ifndef HAVE_SYS_SIGNALFD_H #if !HAVE_SYS_SIGNALFD_H
struct signalfd_siginfo { struct signalfd_siginfo {
uint32_t ssi_signo; uint32_t ssi_signo;
int32_t ssi_errno; int32_t ssi_errno;
@ -125,7 +125,7 @@ static inline int signalfd(int fd, const sigset_t *mask, int flags)
#endif #endif
/* Define unshare() if missing from the C library */ /* Define unshare() if missing from the C library */
#ifndef HAVE_UNSHARE #if !HAVE_UNSHARE
static inline int unshare(int flags) static inline int unshare(int flags)
{ {
return syscall(__NR_unshare, flags); return syscall(__NR_unshare, flags);
@ -135,14 +135,14 @@ extern int unshare(int);
#endif #endif
/* Define faccessat() if missing from the C library */ /* Define faccessat() if missing from the C library */
#ifndef HAVE_FACCESSAT #if !HAVE_FACCESSAT
static int faccessat(int __fd, const char *__file, int __type, int __flag) static int faccessat(int __fd, const char *__file, int __type, int __flag)
{ {
return syscall(__NR_faccessat, __fd, __file, __type, __flag); return syscall(__NR_faccessat, __fd, __file, __type, __flag);
} }
#endif #endif
#ifndef HAVE_MOVE_MOUNT #if !HAVE_MOVE_MOUNT
static inline int move_mount_lxc(int from_dfd, const char *from_pathname, static inline int move_mount_lxc(int from_dfd, const char *from_pathname,
int to_dfd, const char *to_pathname, int to_dfd, const char *to_pathname,
unsigned int flags) unsigned int flags)
@ -156,7 +156,7 @@ extern int move_mount(int from_dfd, const char *from_pathname, int to_dfd,
const char *to_pathname, unsigned int flags); const char *to_pathname, unsigned int flags);
#endif #endif
#ifndef HAVE_OPEN_TREE #if !HAVE_OPEN_TREE
static inline int open_tree_lxc(int dfd, const char *filename, unsigned int flags) static inline int open_tree_lxc(int dfd, const char *filename, unsigned int flags)
{ {
return syscall(__NR_open_tree, dfd, filename, flags); return syscall(__NR_open_tree, dfd, filename, flags);
@ -166,7 +166,7 @@ static inline int open_tree_lxc(int dfd, const char *filename, unsigned int flag
extern int open_tree(int dfd, const char *filename, unsigned int flags); extern int open_tree(int dfd, const char *filename, unsigned int flags);
#endif #endif
#ifndef HAVE_FSOPEN #if !HAVE_FSOPEN
static inline int fsopen_lxc(const char *fs_name, unsigned int flags) static inline int fsopen_lxc(const char *fs_name, unsigned int flags)
{ {
return syscall(__NR_fsopen, fs_name, flags); return syscall(__NR_fsopen, fs_name, flags);
@ -176,7 +176,7 @@ static inline int fsopen_lxc(const char *fs_name, unsigned int flags)
extern int fsopen(const char *fs_name, unsigned int flags); extern int fsopen(const char *fs_name, unsigned int flags);
#endif #endif
#ifndef HAVE_FSPICK #if !HAVE_FSPICK
static inline int fspick_lxc(int dfd, const char *path, unsigned int flags) static inline int fspick_lxc(int dfd, const char *path, unsigned int flags)
{ {
return syscall(__NR_fspick, dfd, path, flags); return syscall(__NR_fspick, dfd, path, flags);
@ -186,7 +186,7 @@ static inline int fspick_lxc(int dfd, const char *path, unsigned int flags)
extern int fspick(int dfd, const char *path, unsigned int flags); extern int fspick(int dfd, const char *path, unsigned int flags);
#endif #endif
#ifndef HAVE_FSCONFIG #if !HAVE_FSCONFIG
static inline int fsconfig_lxc(int fd, unsigned int cmd, const char *key, const void *value, int aux) static inline int fsconfig_lxc(int fd, unsigned int cmd, const char *key, const void *value, int aux)
{ {
return syscall(__NR_fsconfig, fd, cmd, key, value, aux); return syscall(__NR_fsconfig, fd, cmd, key, value, aux);
@ -196,7 +196,7 @@ static inline int fsconfig_lxc(int fd, unsigned int cmd, const char *key, const
extern int fsconfig(int fd, unsigned int cmd, const char *key, const void *value, int aux); extern int fsconfig(int fd, unsigned int cmd, const char *key, const void *value, int aux);
#endif #endif
#ifndef HAVE_FSMOUNT #if !HAVE_FSMOUNT
static inline int fsmount_lxc(int fs_fd, unsigned int flags, unsigned int attr_flags) static inline int fsmount_lxc(int fs_fd, unsigned int flags, unsigned int attr_flags)
{ {
return syscall(__NR_fsmount, fs_fd, flags, attr_flags); return syscall(__NR_fsmount, fs_fd, flags, attr_flags);
@ -216,7 +216,7 @@ struct lxc_mount_attr {
__u64 userns_fd; __u64 userns_fd;
}; };
#ifndef HAVE_MOUNT_SETATTR #if !HAVE_MOUNT_SETATTR
static inline int mount_setattr(int dfd, const char *path, unsigned int flags, static inline int mount_setattr(int dfd, const char *path, unsigned int flags,
struct lxc_mount_attr *attr, size_t size) struct lxc_mount_attr *attr, size_t size)
{ {
@ -291,7 +291,7 @@ struct lxc_open_how {
#define PROTECT_OPEN_W (PROTECT_OPEN_W_WITH_TRAILING_SYMLINKS | O_NOFOLLOW) #define PROTECT_OPEN_W (PROTECT_OPEN_W_WITH_TRAILING_SYMLINKS | O_NOFOLLOW)
#define PROTECT_OPEN_RW (O_CLOEXEC | O_NOCTTY | O_RDWR | O_NOFOLLOW) #define PROTECT_OPEN_RW (O_CLOEXEC | O_NOCTTY | O_RDWR | O_NOFOLLOW)
#ifndef HAVE_OPENAT2 #if !HAVE_OPENAT2
static inline int openat2(int dfd, const char *filename, struct lxc_open_how *how, size_t size) static inline int openat2(int dfd, const char *filename, struct lxc_open_how *how, size_t size)
{ {
return syscall(__NR_openat2, dfd, filename, how, size); return syscall(__NR_openat2, dfd, filename, how, size);
@ -306,14 +306,14 @@ static inline int openat2(int dfd, const char *filename, struct lxc_open_how *ho
#define CLOSE_RANGE_CLOEXEC (1U << 2) #define CLOSE_RANGE_CLOEXEC (1U << 2)
#endif #endif
#ifndef HAVE_CLOSE_RANGE #if !HAVE_CLOSE_RANGE
static inline int close_range(unsigned int fd, unsigned int max_fd, unsigned int flags) static inline int close_range(unsigned int fd, unsigned int max_fd, unsigned int flags)
{ {
return syscall(__NR_close_range, fd, max_fd, flags); return syscall(__NR_close_range, fd, max_fd, flags);
} }
#endif #endif
#ifndef HAVE_SYS_PERSONALITY_H #if !HAVE_SYS_PERSONALITY_H
static inline int personality(unsigned long persona) static inline int personality(unsigned long persona)
{ {
return syscall(__NR_personality, persona); return syscall(__NR_personality, persona);

View File

@ -0,0 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
if conf.get('HAVE_GETSUBOPT') == 0
include_sources += files(
'getsubopt.c',
'getsubopt.h')
endif

View File

@ -6,7 +6,8 @@ tools_liblxc_includes = include_directories(
'../cgroups', '../cgroups',
'../lsm', '../lsm',
'../storage', '../storage',
'../../include') '../../include',
'../../../')
tools_common_sources = files( tools_common_sources = files(
'arguments.c', 'arguments.c',
@ -123,14 +124,6 @@ tools_lxc_config_sources = files(
tools_lxc_console_sources = files( tools_lxc_console_sources = files(
'lxc_console.c') + tools_common_sources 'lxc_console.c') + tools_common_sources
if cc.has_function('getsubopt', prefix : '#include <stdlib.h>', args : '-D_GNU_SOURCE')
conf.set10('HAVE_GETSUBOPT', true)
else
include_sources += files(
'tools/include/getsubopt.c',
'tools/include/getsubopt.h')
endif
tools_lxc_copy_sources = files( tools_lxc_copy_sources = files(
'lxc_copy.c') + tools_common_sources 'lxc_copy.c') + tools_common_sources
@ -178,3 +171,150 @@ tools_lxc_unshare_sources = files(
tools_lxc_wait_sources = files( tools_lxc_wait_sources = files(
'lxc_wait.c') + tools_common_sources 'lxc_wait.c') + tools_common_sources
public_programs += executable(
'lxc-autostart',
tools_lxc_autostart_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-cgroup',
tools_lxc_cgroup_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-checkpoint',
tools_lxc_checkpoint_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-config',
tools_lxc_config_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-console',
tools_lxc_console_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-copy',
tools_lxc_copy_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-create',
tools_lxc_create_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-destroy',
tools_lxc_destroy_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-device',
tools_lxc_device_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-execute',
tools_lxc_execute_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-freeze',
tools_lxc_freeze_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-info',
tools_lxc_info_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-ls',
tools_lxc_ls_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-monitor',
tools_lxc_monitor_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-snapshot',
tools_lxc_snapshot_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-start',
tools_lxc_start_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-stop',
tools_lxc_stop_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-top',
tools_lxc_top_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-unfreeze',
tools_lxc_unfreeze_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-unshare',
tools_lxc_unshare_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)
public_programs += executable(
'lxc-wait',
tools_lxc_wait_sources,
include_directories : tools_liblxc_includes,
dependencies : liblxc_dep,
install : true)

View File

@ -39,11 +39,11 @@
#include "syscall_wrappers.h" #include "syscall_wrappers.h"
#include "utils.h" #include "utils.h"
#ifndef HAVE_STRLCPY #if !HAVE_STRLCPY
#include "strlcpy.h" #include "strlcpy.h"
#endif #endif
#ifndef HAVE_STRLCAT #if !HAVE_STRLCAT
#include "strlcat.h" #include "strlcat.h"
#endif #endif

View File

@ -33,8 +33,8 @@ __hidden extern int mkdir_p(const char *dir, mode_t mode);
__hidden extern char *get_rundir(void); __hidden extern char *get_rundir(void);
/* Define getline() if missing from the C library */ /* Define getline() if missing from the C library */
#ifndef HAVE_GETLINE #if !HAVE_GETLINE
#ifdef HAVE_FGETLN #if !HAVE_FGETLN
#include "getline.h" #include "getline.h"
#endif #endif
#endif #endif