Skip to content

Commit

Permalink
Check for various headers to simplify porting efforts
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Edwards <sedwards@cisco.com>
  • Loading branch information
sedwards authored and Steven Edwards committed Oct 22, 2024
1 parent e9c9294 commit 1c44e07
Show file tree
Hide file tree
Showing 17 changed files with 94 additions and 3 deletions.
18 changes: 17 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,23 @@ AC_PATH_PROG(MD2MAN, go-md2man)

AM_CONDITIONAL([HAVE_MD2MAN], [test "x$ac_cv_path_MD2MAN" != x])

AC_CHECK_HEADERS([error.h linux/openat2.h stdatomic.h linux/ioprio.h])
AC_CHECK_HEADERS([
error.h
linux/filter.h
linux/ioprio.h
linux/limits.h
linux/magic.h
linux/netlink.h
linux/openat2.h
linux/sched.h
stdatomic.h
sys/epoll.h
sys/personality.h
sys/prctl.h
sys/signalfd.h
sys/statfs.h
sys/sys/vfs.h
sys/sysmacros.h])

AC_CHECK_TYPES([atomic_int], [], [], [[#include <stdatomic.h>]])

Expand Down
2 changes: 2 additions & 0 deletions src/libcrun/cgroup-cgroupfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
#include <string.h>
#include <sys/types.h>
#include <signal.h>
#ifdef HAVE_SYS_VFS_H
#include <sys/vfs.h>
#endif
#include <inttypes.h>
#include <time.h>

Expand Down
3 changes: 3 additions & 0 deletions src/libcrun/cgroup-resources.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
#include "status.h"
#include <string.h>
#include <sys/types.h>
#include <sys/mount.h>
#ifdef HAVE_SYS_VFS_H
#include <sys/vfs.h>
#endif
#include <inttypes.h>
#include <time.h>

Expand Down
4 changes: 4 additions & 0 deletions src/libcrun/cgroup-setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
#include <string.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/mount.h>
#ifdef HAVE_SYS_VFS_H
#include <sys/vfs.h>
#endif

#include <inttypes.h>
#include <time.h>

Expand Down
3 changes: 3 additions & 0 deletions src/libcrun/cgroup-systemd.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
#include <string.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/mount.h>
#ifdef HAVE_SYS_VFS_H
#include <sys/vfs.h>
#endif
#include <inttypes.h>
#include <fcntl.h>
#include <time.h>
Expand Down
6 changes: 6 additions & 0 deletions src/libcrun/cgroup-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@
#include <string.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/mount.h>
#ifdef HAVE_SYS_VFS_H
#include <sys/vfs.h>
#endif
#include <inttypes.h>
#include <time.h>

#include <sys/stat.h>
#ifdef HAVE_SYS_STATFS_H
#include <sys/statfs.h>
#endif
#include <sys/types.h>
#include <fcntl.h>
#include <libgen.h>
Expand Down
2 changes: 2 additions & 0 deletions src/libcrun/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
#include <sched.h>
#include <sys/types.h>
#include <signal.h>
#ifdef HAVE_SYS_VFS_H
#include <sys/vfs.h>
#endif
#include <inttypes.h>
#include <time.h>

Expand Down
6 changes: 6 additions & 0 deletions src/libcrun/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,15 @@
#include "io_priority.h"
#include "cgroup.h"
#include "cgroup-utils.h"
#ifdef HAVE_SYS_PRCTL_H
#include <sys/prctl.h>
#endif
#ifdef HAVE_SYS_SIGNALFD_H
#include <sys/signalfd.h>
#endif
#ifdef HAVE_SYS_EPOLL_H
#include <sys/epoll.h>
#endif
#include <sys/socket.h>
#ifdef HAVE_CAP
# include <sys/capability.h>
Expand Down
2 changes: 2 additions & 0 deletions src/libcrun/handlers/krun.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
#include <errno.h>
#include <sys/param.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SYSMACROS_H
#include <sys/sysmacros.h>
#endif
#include <fcntl.h>
#include <sched.h>
#include <ocispec/runtime_spec_schema_config_schema.h>
Expand Down
6 changes: 6 additions & 0 deletions src/libcrun/intelrdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@
#include <string.h>
#include <sched.h>
#include <fcntl.h>
#ifdef HAVE_SYS_STATFS_H
#include <sys/statfs.h>
#endif
#include <sys/mount.h>
#ifdef HAVE_SYS_VFS_H
#include <sys/vfs.h>
#endif

#define INTEL_RDT_MOUNT_POINT "/sys/fs/resctrl"
#define SCHEMATA_FILE "schemata"
Expand Down
3 changes: 3 additions & 0 deletions src/libcrun/io_priority.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
#include "linux.h"
#include "utils.h"
#include "io_priority.h"
#include <sys/types.h>
#ifdef HAVE_SYS_SYSMAROS_H
#include <sys/sysmacros.h>
#endif

#ifdef HAVE_LINUX_IOPRIO_H
static int
Expand Down
13 changes: 13 additions & 0 deletions src/libcrun/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@
# define HAVE_NEW_MOUNT_API
#endif

#ifdef HAVE_SYS_PRCTL_H
#include <sys/prctl.h>
#endif

#ifdef HAVE_CAP
# include <sys/capability.h>
#endif
#include <sys/time.h>
#include <sys/resource.h>
#ifdef HAVE_SYS_SYSMACROS_H
#include <sys/sysmacros.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <grp.h>
Expand All @@ -56,14 +61,22 @@
#include <sys/socket.h>
#include <libgen.h>
#include <sys/wait.h>
#ifdef HAVE_SYS_VFS_H
#include <sys/vfs.h>
#endif
#include <limits.h>
#include <inttypes.h>
#ifdef HAVE_SYS_PERSONALITY_H
#include <sys/personality.h>
#endif
#include <net/if.h>
#include <sys/xattr.h>
#ifdef HAVE_LINUX_NETLINK_H
#include <linux/netlink.h>
#endif
#ifdef HAVE_LINUX_RTNETLINK_H
#include <linux/rtnetlink.h>
#endif
#include <sched.h>

#include <yajl/yajl_tree.h>
Expand Down
4 changes: 4 additions & 0 deletions src/libcrun/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@
#include "linux.h"
#include "utils.h"
#include <sched.h>
#ifdef HAVE_LINUX_SCHED_H
#include <linux/sched.h>
#endif
#ifdef HAVE_SYS_SYSMACROS_H
#include <sys/sysmacros.h>
#endif
#include <limits.h>
#include <inttypes.h>
#include <ocispec/runtime_spec_schema_config_schema.h>
Expand Down
9 changes: 7 additions & 2 deletions src/libcrun/seccomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@
#include <unistd.h>
#include <sys/mount.h>
#include <sys/syscall.h>
#if HAVE_SYS_PRCTL_H
#include <sys/prctl.h>
#endif
#include <sys/time.h>
#include <sys/resource.h>
#ifdef HAVE_SYS_SYSMACROS_H
#include <sys/sysmacros.h>
#endif
#include <sys/types.h>
#include <sys/utsname.h>
#include <sys/stat.h>
Expand All @@ -47,10 +51,11 @@

#ifdef HAVE_SECCOMP
# include <seccomp.h>
#endif
#include <linux/seccomp.h>
#endif
#ifdef HAVE_LINUX_FILTER_H
#include <linux/filter.h>
#include <sys/prctl.h>
#endif
#include <sys/syscall.h>

#ifndef __NR_seccomp
Expand Down
10 changes: 10 additions & 0 deletions src/libcrun/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,28 @@
#include <sys/types.h>
#include <sys/un.h>
#include <sys/socket.h>
#ifdef HAVE_SYS_SIGNALFD_H
#include <sys/signalfd.h>
#endif
#ifdef HAVE_SYS_EPOLL_H
#include <sys/epoll.h>
#endif
#include <sys/syscall.h>
#include <sys/wait.h>
#include <pwd.h>
#include <grp.h>
#include <time.h>
#include <sys/time.h>
#include <sys/xattr.h>
#ifdef HAVE_SYS_SYSMACROS_H
#include <sys/sysmacros.h>
#endif
#ifdef HAVE_SYS_VFS_H
#include <sys/vfs.h>
#endif
#ifdef HAVE_LINUX_MAGIC_H
#include <linux/magic.h>
#endif
#include <limits.h>
#include <sys/mman.h>
#ifdef HAVE_LINUX_OPENAT2_H
Expand Down
4 changes: 4 additions & 0 deletions tests/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#define _GNU_SOURCE

#include <config.h>
#ifdef HAVE_LINUX_LIMITS_H
#include <linux/limits.h>
#endif
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
Expand All @@ -33,7 +35,9 @@
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/syscall.h>
#ifdef HAVE_SYS_PRCTL_H
#include <sys/prctl.h>
#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <sched.h>
Expand Down
2 changes: 2 additions & 0 deletions tests/tests_libcrun_fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
#include <signal.h>
#include <fcntl.h>
#include <limits.h>
#ifdef HAVE_SYS_PRCTL_H
#include <sys/prctl.h>
#endif

static int test_mode = -1;

Expand Down

0 comments on commit 1c44e07

Please sign in to comment.