diff --git a/hooks/unmount-namespace.c b/hooks/unmount-namespace.c index df139e052..8721b3536 100644 --- a/hooks/unmount-namespace.c +++ b/hooks/unmount-namespace.c @@ -49,7 +49,7 @@ #endif /* Define setns() if missing from the C library */ -#ifndef HAVE_SETNS +#if !HAVE_SETNS static inline int setns(int fd, int nstype) { #ifdef __NR_setns diff --git a/meson.build b/meson.build index 12d438f48..ab1885bcc 100644 --- a/meson.build +++ b/meson.build @@ -206,15 +206,24 @@ foreach ident : [ #include '''], ['close_range', '''#include '''], ['execveat', '''#include '''], + ['endmntent', '''#include + #include '''], ['faccessat', '''#include #include '''], ['fexecve', '''#include '''], + ['fgetln', '''#include '''], ['fsconfig', '''#include '''], ['fsmount', '''#include '''], ['fsopen', '''#include '''], ['fspick', '''#include '''], + ['getgrgid_r', '''#include + #include '''], + ['getline', '''#include '''], + ['getsubopt', '''#include '''], ['gettid', '''#include #include '''], + ['hasmntopt', '''#include + #include '''], ['kcmp', '''#include '''], ['keyctl', '''#include #include '''], @@ -243,19 +252,21 @@ foreach ident : [ ['renameat2', '''#include #include '''], ['sethostname', '''#include '''], + ['setmntent', '''#include + #include '''], ['setns', '''#include '''], ['signalfd', '''#include '''], ['statx', '''#include #include #include '''], + ['strchrnul', '''#include '''], ['strlcat', '''#include '''], ['strlcpy', '''#include '''], ['unshare', '''#include '''], ] - if cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE') - conf.set10('HAVE_' + ident[0].to_upper(), true) - endif + have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE') + conf.set10('HAVE_' + ident[0].to_upper(), have) endforeach sh = find_program('sh') @@ -335,32 +346,37 @@ if libcap_static.found() conf.set10('HAVE_STATIC_LIBCAP', libcap_static.found()) endif +have = cc.has_function('strchrnul', prefix : '#include ', args : '-D_GNU_SOURCE') +conf.set10('HAVE_STRCHRNUL', have) + +have = cc.has_function('openpty', prefix : '#include ', 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( + '.', 'src', - 'src/include', - '.') + 'src/include') liblxc_includes = [basic_includes, include_directories( 'src/lxc/cgroups', 'src/lxc/lsm', 'src/lxc/storage')] -add_project_arguments('-include', 'config.h', language : 'c') - -subdir('hooks') subdir('src/include') +subdir('src/lxc/tools/include') +subdir('hooks') subdir('src/lxc') -subdir('src/lxc/cmd') -subdir('src/lxc/tools') - -config_h = configure_file( - output : 'config.h', - configuration : conf) liblxc = shared_library( 'lxc', version : liblxc_version, - include_directories : tools_liblxc_includes, + include_directories: liblxc_includes, link_args : ['-DPIC'], c_args : ['-DPIC'], link_whole : [liblxc_static], @@ -381,156 +397,11 @@ liblxc_dep = declare_dependency( libselinux, 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 = [] +subdir('src/lxc/cmd') + +public_programs = [] +subdir('src/lxc/tools') cmd_programs += executable( 'lxc-init', @@ -564,14 +435,20 @@ missing_syscalls = [] foreach tuple : [ ['bpf'], ['close_range'], + ['endmntent'], ['execveat'], ['faccessat'], - ['fexecve'], + ['strchrnul'], + ['fgetln'], ['fsconfig'], ['fsmount'], ['fsopen'], ['fspick'], + ['getgrgid_r'], + ['getline'], + ['getsubopt'], ['gettid'], + ['hasmntopt'], ['kcmp'], ['keyctl'], ['memfd_create'], @@ -587,6 +464,7 @@ foreach tuple : [ ['prlimit64'], ['renameat2'], ['sethostname'], + ['setmntent'], ['setns'], ['signalfd'], ['statx'], diff --git a/src/include/meson.build b/src/include/meson.build index 38217bc70..390971fa4 100644 --- a/src/include/meson.build +++ b/src/include/meson.build @@ -8,89 +8,50 @@ netns_ifaddrs_sources = files( 'netns_ifaddrs.c', 'netns_ifaddrs.h') -if cc.has_function('getline', prefix : '#include ', args : '-D_GNU_SOURCE') - conf.set10('HAVE_GETLINE', true) -else +if conf.get('HAVE_GETLINE') == 0 include_sources += files( 'getline.c', 'getline.h') endif -if cc.has_function('fexecve', prefix : '#include ', args : '-D_GNU_SOURCE') - conf.set10('HAVE_FEXECVE', true) -else +if conf.get('HAVE_FEXECVE') == 0 include_sources += files( 'fexecve.c', 'fexecve.h') endif -getgr_headers = ''' -#include -#include -''' - -if cc.has_function('getgrgid_r', prefix : getgr_headers, args : '-D_GNU_SOURCE') - conf.set10('HAVE_GETGRGID_R', true) -else +if conf.get('HAVE_GETGRGID_R') == 0 include_sources += files( 'getgrgid_r.c', 'getgrgid_r.h') endif -mntent_headers = ''' -#include -#include -''' - -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 +if conf.get('HAVE_HASMNTOPT') == 0 or conf.get('HAVE_SETMNTENT') == 0 or conf.get('HAVE_ENDMNTENT') == 0 include_sources += files( 'lxcmntent.c', 'lxcmntent.h') endif -if cc.has_function('strlcpy', prefix : '#include ', args : '-D_GNU_SOURCE') - conf.set10('HAVE_STRLCPY', true) -else +if conf.get('HAVE_STRLCPY') == 0 include_sources += files( 'strlcpy.c', 'strlcpy.h') endif -if cc.has_function('strlcat', prefix : '#include ', args : '-D_GNU_SOURCE') - conf.set10('HAVE_STRLCAT', true) -else +if conf.get('HAVE_STRLCAT') == 0 include_sources += files( 'strlcat.c', 'strlcat.h') endif -if cc.has_function('strchrnul', prefix : '#include ', args : '-D_GNU_SOURCE') - conf.set10('HAVE_STRCHRNUL', true) -else +if conf.get('HAVE_STRCHRNUL') == 0 include_sources += files( 'strchrnul.c', 'strchrnul.h') endif -if cc.has_function('openpty', prefix : '#include ', args : '-D_GNU_SOURCE') - conf.set10('HAVE_OPENPTY', true) -else +if conf.get('HAVE_OPENPTY') == 0 include_sources += files( 'openpty.c', 'openpty.h') diff --git a/src/include/strlcat.c b/src/include/strlcat.c index ded647c6f..823c7494a 100644 --- a/src/include/strlcat.c +++ b/src/include/strlcat.c @@ -23,7 +23,7 @@ #include #include -#ifndef HAVE_STRLCPY +#if !HAVE_STRLCPY #include "strlcpy.h" #endif diff --git a/src/lxc/af_unix.c b/src/lxc/af_unix.c index 7dae44c59..97f9ac676 100644 --- a/src/lxc/af_unix.c +++ b/src/lxc/af_unix.c @@ -20,7 +20,7 @@ #include "process_utils.h" #include "utils.h" -#ifndef HAVE_STRLCPY +#if !HAVE_STRLCPY #include "strlcpy.h" #endif diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index 6a5d9eeab..7ae67e30c 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -49,11 +49,11 @@ #include "syscall_wrappers.h" #include "utils.h" -#ifndef HAVE_STRLCPY +#if !HAVE_STRLCPY #include "strlcpy.h" #endif -#ifndef HAVE_STRLCAT +#if !HAVE_STRLCAT #include "strlcat.h" #endif diff --git a/src/lxc/cgroups/cgroup2_devices.h b/src/lxc/cgroups/cgroup2_devices.h index 4b0fb7362..7979b2262 100644 --- a/src/lxc/cgroups/cgroup2_devices.h +++ b/src/lxc/cgroups/cgroup2_devices.h @@ -28,7 +28,7 @@ #include "bpf.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) { return syscall(__NR_bpf, cmd, attr, size); diff --git a/src/lxc/conf.c b/src/lxc/conf.c index aecd94228..e645d10be 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -80,7 +80,7 @@ #include #endif -#ifndef HAVE_STRLCAT +#if !HAVE_STRLCAT #include "strlcat.h" #endif @@ -94,11 +94,11 @@ #include "prlimit.h" #endif -#ifndef HAVE_STRLCPY +#if !HAVE_STRLCPY #include "strlcpy.h" #endif -#ifndef HAVE_STRCHRNUL +#if !HAVE_STRCHRNUL #include "strchrnul.h" #endif diff --git a/src/lxc/confile.c b/src/lxc/confile.c index f4cb4b5e2..4a74f8daf 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -35,11 +35,11 @@ #include "parse.h" #include "utils.h" -#ifndef HAVE_STRLCPY +#if !HAVE_STRLCPY #include "strlcpy.h" #endif -#ifndef HAVE_STRLCAT +#if !HAVE_STRLCAT #include "strlcat.h" #endif diff --git a/src/lxc/confile_utils.c b/src/lxc/confile_utils.c index 5534daa41..8d0f822f3 100644 --- a/src/lxc/confile_utils.c +++ b/src/lxc/confile_utils.c @@ -23,7 +23,7 @@ #include "parse.h" #include "utils.h" -#ifndef HAVE_STRLCPY +#if !HAVE_STRLCPY #include "strlcpy.h" #endif diff --git a/src/lxc/criu.c b/src/lxc/criu.c index 3ee736922..c3061ad74 100644 --- a/src/lxc/criu.c +++ b/src/lxc/criu.c @@ -34,7 +34,7 @@ #include #endif -#ifndef HAVE_STRLCPY +#if !HAVE_STRLCPY #include "strlcpy.h" #endif diff --git a/src/lxc/log.c b/src/lxc/log.c index ac3713ecc..cdd11ff1c 100644 --- a/src/lxc/log.c +++ b/src/lxc/log.c @@ -24,7 +24,7 @@ #include "memory_utils.h" #include "utils.h" -#ifndef HAVE_STRLCPY +#if !HAVE_STRLCPY #include "strlcpy.h" #endif diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index ac4b312c0..96fdb3fd2 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -76,7 +76,7 @@ #include #endif -#ifndef HAVE_STRLCPY +#if !HAVE_STRLCPY #include "include/strlcpy.h" #endif diff --git a/src/lxc/macro.h b/src/lxc/macro.h index 9054c326c..c6d41d79e 100644 --- a/src/lxc/macro.h +++ b/src/lxc/macro.h @@ -731,7 +731,7 @@ enum { #define hweight32(w) __const_hweight32(w) #define hweight64(w) __const_hweight64(w) -#ifndef HAVE___ALIGNED_U64 +#if !HAVE___ALIGNED_U64 #define __aligned_u64 __u64 __attribute__((aligned(8))) #endif @@ -739,7 +739,7 @@ enum { #define BITS_PER_TYPE(type) (sizeof(type) * 8) #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_LINUX32 0x0008 #endif diff --git a/src/lxc/process_utils.h b/src/lxc/process_utils.h index 2a5032c03..2eb9e5152 100644 --- a/src/lxc/process_utils.h +++ b/src/lxc/process_utils.h @@ -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, int *pidfd); -#ifndef HAVE_EXECVEAT +#if !HAVE_EXECVEAT static inline int execveat(int dirfd, const char *pathname, char *const argv[], char *const envp[], int flags) { diff --git a/src/lxc/start.c b/src/lxc/start.c index 4eed60a21..a9d3d5ead 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -62,7 +62,7 @@ #include #endif -#ifndef HAVE_STRLCPY +#if !HAVE_STRLCPY #include "strlcpy.h" #endif diff --git a/src/lxc/string_utils.c b/src/lxc/string_utils.c index e2bc9fe48..c14a38dfe 100644 --- a/src/lxc/string_utils.c +++ b/src/lxc/string_utils.c @@ -28,11 +28,11 @@ #include "macro.h" #include "memory_utils.h" -#ifndef HAVE_STRLCPY +#if !HAVE_STRLCPY #include "strlcpy.h" #endif -#ifndef HAVE_STRLCAT +#if !HAVE_STRLCAT #include "strlcat.h" #endif diff --git a/src/lxc/string_utils.h b/src/lxc/string_utils.h index 7abbc537f..e64a66d0e 100644 --- a/src/lxc/string_utils.h +++ b/src/lxc/string_utils.h @@ -10,15 +10,15 @@ #include "initutils.h" #include "macro.h" -#ifndef HAVE_STRLCAT +#if !HAVE_STRLCAT #include "strlcat.h" #endif -#ifndef HAVE_STRLCPY +#if !HAVE_STRLCPY #include "strlcpy.h" #endif -#ifndef HAVE_STRCHRNUL +#if !HAVE_STRCHRNUL #include "strchrnul.h" #endif diff --git a/src/lxc/syscall_wrappers.h b/src/lxc/syscall_wrappers.h index 10f2fff34..f1004d264 100644 --- a/src/lxc/syscall_wrappers.h +++ b/src/lxc/syscall_wrappers.h @@ -54,7 +54,7 @@ static inline long __keyctl(int cmd, unsigned long arg2, unsigned long arg3, #define F_SEAL_WRITE 0x0008 #endif -#ifndef HAVE_MEMFD_CREATE +#if !HAVE_MEMFD_CREATE static inline int memfd_create_lxc(const char *name, unsigned int 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); #endif -#ifndef HAVE_PIVOT_ROOT +#if !HAVE_PIVOT_ROOT static inline int pivot_root(const char *new_root, const char *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 /* Define sethostname() if missing from the C library */ -#ifndef HAVE_SETHOSTNAME +#if !HAVE_SETHOSTNAME static inline int sethostname(const char *name, size_t len) { return syscall(__NR_sethostname, name, len); @@ -82,14 +82,14 @@ static inline int sethostname(const char *name, size_t len) #endif /* Define setns() if missing from the C library */ -#ifndef HAVE_SETNS +#if !HAVE_SETNS static inline int setns(int fd, int nstype) { return syscall(__NR_setns, fd, nstype); } #endif -#ifndef HAVE_SYS_SIGNALFD_H +#if !HAVE_SYS_SIGNALFD_H struct signalfd_siginfo { uint32_t ssi_signo; int32_t ssi_errno; @@ -125,7 +125,7 @@ static inline int signalfd(int fd, const sigset_t *mask, int flags) #endif /* Define unshare() if missing from the C library */ -#ifndef HAVE_UNSHARE +#if !HAVE_UNSHARE static inline int unshare(int flags) { return syscall(__NR_unshare, flags); @@ -135,14 +135,14 @@ extern int unshare(int); #endif /* 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) { return syscall(__NR_faccessat, __fd, __file, __type, __flag); } #endif -#ifndef HAVE_MOVE_MOUNT +#if !HAVE_MOVE_MOUNT static inline int move_mount_lxc(int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, 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); #endif -#ifndef HAVE_OPEN_TREE +#if !HAVE_OPEN_TREE static inline int open_tree_lxc(int dfd, const char *filename, unsigned int 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); #endif -#ifndef HAVE_FSOPEN +#if !HAVE_FSOPEN static inline int fsopen_lxc(const char *fs_name, unsigned int 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); #endif -#ifndef HAVE_FSPICK +#if !HAVE_FSPICK static inline int fspick_lxc(int dfd, const char *path, unsigned int 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); #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) { 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); #endif -#ifndef HAVE_FSMOUNT +#if !HAVE_FSMOUNT static inline int fsmount_lxc(int fs_fd, unsigned int flags, unsigned int attr_flags) { return syscall(__NR_fsmount, fs_fd, flags, attr_flags); @@ -216,7 +216,7 @@ struct lxc_mount_attr { __u64 userns_fd; }; -#ifndef HAVE_MOUNT_SETATTR +#if !HAVE_MOUNT_SETATTR static inline int mount_setattr(int dfd, const char *path, unsigned int flags, 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_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) { 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) #endif -#ifndef HAVE_CLOSE_RANGE +#if !HAVE_CLOSE_RANGE static inline int close_range(unsigned int fd, unsigned int max_fd, unsigned int flags) { return syscall(__NR_close_range, fd, max_fd, flags); } #endif -#ifndef HAVE_SYS_PERSONALITY_H +#if !HAVE_SYS_PERSONALITY_H static inline int personality(unsigned long persona) { return syscall(__NR_personality, persona); diff --git a/src/lxc/tools/include/meson.build b/src/lxc/tools/include/meson.build new file mode 100644 index 000000000..f1bb4a589 --- /dev/null +++ b/src/lxc/tools/include/meson.build @@ -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 diff --git a/src/lxc/tools/meson.build b/src/lxc/tools/meson.build index 14a584899..3fb8b68a5 100644 --- a/src/lxc/tools/meson.build +++ b/src/lxc/tools/meson.build @@ -6,7 +6,8 @@ tools_liblxc_includes = include_directories( '../cgroups', '../lsm', '../storage', - '../../include') + '../../include', + '../../../') tools_common_sources = files( 'arguments.c', @@ -123,14 +124,6 @@ tools_lxc_config_sources = files( tools_lxc_console_sources = files( 'lxc_console.c') + tools_common_sources -if cc.has_function('getsubopt', prefix : '#include ', 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( 'lxc_copy.c') + tools_common_sources @@ -178,3 +171,150 @@ tools_lxc_unshare_sources = files( tools_lxc_wait_sources = files( '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) diff --git a/src/lxc/utils.c b/src/lxc/utils.c index aab0dda23..bc8a2b0c3 100644 --- a/src/lxc/utils.c +++ b/src/lxc/utils.c @@ -39,11 +39,11 @@ #include "syscall_wrappers.h" #include "utils.h" -#ifndef HAVE_STRLCPY +#if !HAVE_STRLCPY #include "strlcpy.h" #endif -#ifndef HAVE_STRLCAT +#if !HAVE_STRLCAT #include "strlcat.h" #endif diff --git a/src/lxc/utils.h b/src/lxc/utils.h index 51fb8874b..161555e6f 100644 --- a/src/lxc/utils.h +++ b/src/lxc/utils.h @@ -33,8 +33,8 @@ __hidden extern int mkdir_p(const char *dir, mode_t mode); __hidden extern char *get_rundir(void); /* Define getline() if missing from the C library */ -#ifndef HAVE_GETLINE -#ifdef HAVE_FGETLN +#if !HAVE_GETLINE +#if !HAVE_FGETLN #include "getline.h" #endif #endif