1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-24 06:04:05 +03:00

basic/missing_*.h: add asserts that the values are as expected

It's great that we provide fallback values, but if we got one of those wrong,
it could be a long time before anyone noticed. So let's add asserts that the
our internal defines actually match the official ones, when the latter are
available.

I did not add '#include "macro.h"' to missing_{audit,capability}, because
those are processed by an awk script that would need additional include
directories and could be confused by the additional lines. We don't include
those headers standalone anyway, so this is not necessary anyway.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2024-03-15 15:22:31 +01:00
parent 7258971b13
commit 4d6437d33c
17 changed files with 370 additions and 124 deletions

View File

@ -4,21 +4,29 @@
#include <linux/audit.h>
#if HAVE_AUDIT
#include <libaudit.h>
# include <libaudit.h>
#endif
#ifndef AUDIT_SERVICE_START
#define AUDIT_SERVICE_START 1130 /* Service (daemon) start */
# define AUDIT_SERVICE_START 1130 /* Service (daemon) start */
#else
assert_cc(AUDIT_SERVICE_START == 1130);
#endif
#ifndef AUDIT_SERVICE_STOP
#define AUDIT_SERVICE_STOP 1131 /* Service (daemon) stop */
# define AUDIT_SERVICE_STOP 1131 /* Service (daemon) stop */
#else
assert_cc(AUDIT_SERVICE_STOP == 1131);
#endif
#ifndef MAX_AUDIT_MESSAGE_LENGTH
#define MAX_AUDIT_MESSAGE_LENGTH 8970
# define MAX_AUDIT_MESSAGE_LENGTH 8970
#else
assert_cc(MAX_AUDIT_MESSAGE_LENGTH == 8970);
#endif
#ifndef AUDIT_NLGRP_MAX
#define AUDIT_NLGRP_READLOG 1
# define AUDIT_NLGRP_READLOG 1
#else
assert_cc(AUDIT_NLGRP_READLOG == 1);
#endif

View File

@ -6,21 +6,29 @@
/* 3a101b8de0d39403b2c7e5c23fd0b005668acf48 (3.16) */
#ifndef CAP_AUDIT_READ
# define CAP_AUDIT_READ 37
#else
assert_cc(CAP_AUDIT_READ == 37);
#endif
/* 980737282232b752bb14dab96d77665c15889c36 (5.8) */
#ifndef CAP_PERFMON
# define CAP_PERFMON 38
#else
assert_cc(CAP_PERFMON == 38);
#endif
/* a17b53c4a4b55ec322c132b6670743612229ee9c (5.8) */
#ifndef CAP_BPF
# define CAP_BPF 39
#else
assert_cc(CAP_BPF == 39);
#endif
/* 124ea650d3072b005457faed69909221c2905a1f (5.9) */
#ifndef CAP_CHECKPOINT_RESTORE
# define CAP_CHECKPOINT_RESTORE 40
#else
assert_cc(CAP_CHECKPOINT_RESTORE == 40);
#endif
#define SYSTEMD_CAP_LAST_CAP CAP_CHECKPOINT_RESTORE
@ -34,6 +42,7 @@
# undef CAP_LAST_CAP
# endif
#endif
#ifndef CAP_LAST_CAP
# define CAP_LAST_CAP SYSTEMD_CAP_LAST_CAP
#endif

View File

@ -2,9 +2,9 @@
#pragma once
#ifndef DRM_IOCTL_SET_MASTER
#define DRM_IOCTL_SET_MASTER _IO('d', 0x1e)
# define DRM_IOCTL_SET_MASTER _IO('d', 0x1e)
#endif
#ifndef DRM_IOCTL_DROP_MASTER
#define DRM_IOCTL_DROP_MASTER _IO('d', 0x1f)
# define DRM_IOCTL_DROP_MASTER _IO('d', 0x1f)
#endif

View File

@ -3,6 +3,8 @@
#include <linux/types.h>
#include "macro.h"
/* linux/fs.h */
#ifndef RENAME_NOREPLACE /* 0a7c3937a1f23f8cb5fc77ae01661e9968a51d0c (3.15) */
#define RENAME_NOREPLACE (1 << 0)
@ -28,43 +30,63 @@ struct file_clone_range {
/* linux/fs.h or sys/mount.h */
#ifndef MS_MOVE
#define MS_MOVE 8192
# define MS_MOVE 8192
#else
assert_cc(MS_MOVE == 8192);
#endif
#ifndef MS_REC
#define MS_REC 16384
# define MS_REC 16384
#else
assert_cc(MS_REC == 16384);
#endif
#ifndef MS_PRIVATE
#define MS_PRIVATE (1<<18)
# define MS_PRIVATE (1<<18)
#else
assert_cc(MS_PRIVATE == (1<<18));
#endif
#ifndef MS_SLAVE
#define MS_SLAVE (1<<19)
# define MS_SLAVE (1<<19)
#else
assert_cc(MS_SLAVE == (1<<19));
#endif
#ifndef MS_SHARED
#define MS_SHARED (1<<20)
# define MS_SHARED (1<<20)
#else
assert_cc(MS_SHARED == (1<<20));
#endif
#ifndef MS_RELATIME
#define MS_RELATIME (1<<21)
# define MS_RELATIME (1<<21)
#else
assert_cc(MS_RELATIME == (1<<21));
#endif
#ifndef MS_KERNMOUNT
#define MS_KERNMOUNT (1<<22)
# define MS_KERNMOUNT (1<<22)
#else
assert_cc(MS_KERNMOUNT == (1<<22));
#endif
#ifndef MS_I_VERSION
#define MS_I_VERSION (1<<23)
# define MS_I_VERSION (1<<23)
#else
assert_cc(MS_I_VERSION == (1<<23));
#endif
#ifndef MS_STRICTATIME
#define MS_STRICTATIME (1<<24)
# define MS_STRICTATIME (1<<24)
#else
assert_cc(MS_STRICTATIME == (1 << 24));
#endif
#ifndef MS_LAZYTIME
#define MS_LAZYTIME (1<<25)
# define MS_LAZYTIME (1<<25)
#else
assert_cc(MS_LAZYTIME == (1<<25));
#endif
/* Not exposed yet. Defined at fs/ext4/ext4.h */
@ -78,10 +100,14 @@ struct file_clone_range {
#endif
#ifndef FS_PROJINHERIT_FL
#define FS_PROJINHERIT_FL 0x20000000
# define FS_PROJINHERIT_FL 0x20000000
#else
assert_cc(FS_PROJINHERIT_FL == 0x20000000);
#endif
/* linux/fscrypt.h */
#ifndef FS_KEY_DESCRIPTOR_SIZE
#define FS_KEY_DESCRIPTOR_SIZE 8
# define FS_KEY_DESCRIPTOR_SIZE 8
#else
assert_cc(FS_KEY_DESCRIPTOR_SIZE == 8);
#endif

View File

@ -4,9 +4,11 @@
#include <linux/input.h>
#include <linux/types.h>
#include "macro.h"
/* linux@c7dc65737c9a607d3e6f8478659876074ad129b8 (3.12) */
#ifndef EVIOCREVOKE
#define EVIOCREVOKE _IOW('E', 0x91, int)
# define EVIOCREVOKE _IOW('E', 0x91, int)
#endif
/* linux@06a16293f71927f756dcf37558a79c0b05a91641 (4.4) */
@ -23,23 +25,34 @@ struct input_mask {
/* linux@7611392fe8ff95ecae528b01a815ae3d72ca6b95 (3.17) */
#ifndef INPUT_PROP_POINTING_STICK
#define INPUT_PROP_POINTING_STICK 0x05
# define INPUT_PROP_POINTING_STICK 0x05
#else
assert_cc(INPUT_PROP_POINTING_STICK == 0x05);
#endif
/* linux@500d4160abe9a2e88b12e319c13ae3ebd1e18108 (4.0) */
#ifndef INPUT_PROP_ACCELEROMETER
#define INPUT_PROP_ACCELEROMETER 0x06
# define INPUT_PROP_ACCELEROMETER 0x06
#else
assert_cc(INPUT_PROP_ACCELEROMETER == 0x06);
#endif
/* linux@d09bbfd2a8408a995419dff0d2ba906013cf4cc9 (3.11) */
#ifndef BTN_DPAD_UP
#define BTN_DPAD_UP 0x220
#define BTN_DPAD_DOWN 0x221
#define BTN_DPAD_LEFT 0x222
#define BTN_DPAD_RIGHT 0x223
# define BTN_DPAD_UP 0x220
# define BTN_DPAD_DOWN 0x221
# define BTN_DPAD_LEFT 0x222
# define BTN_DPAD_RIGHT 0x223
#else
assert_cc(BTN_DPAD_UP == 0x220);
assert_cc(BTN_DPAD_DOWN == 0x221);
assert_cc(BTN_DPAD_LEFT == 0x222);
assert_cc(BTN_DPAD_RIGHT == 0x223);
#endif
/* linux@358f24704f2f016af7d504b357cdf32606091d07 (3.13) */
#ifndef KEY_ALS_TOGGLE
#define KEY_ALS_TOGGLE 0x230
# fine KEY_ALS_TOGGLE 0x230
#else
assert_cc(KEY_ALS_TOGGLE == 0x230);
#endif

View File

@ -5,47 +5,77 @@
# include <linux/ioprio.h>
#endif
#include "macro.h"
/* Match values uses by the kernel internally, as no public header seems to exist. */
#ifndef IOPRIO_N_CLASSES
# define IOPRIO_N_CLASSES 8
#else
assert_cc(IOPRIO_N_CLASSES == 8);
#endif
#ifndef IOPRIO_BE_NR
# define IOPRIO_BE_NR 8
#else
assert_cc(IOPRIO_BE_NR == 8);
#endif
#ifndef IOPRIO_CLASS_NONE
# define IOPRIO_CLASS_NONE 0
#else
assert_cc(IOPRIO_CLASS_NONE == 0);
#endif
#ifndef IOPRIO_CLASS_RT
# define IOPRIO_CLASS_RT 1
#else
assert_cc(IOPRIO_CLASS_RT == 1);
#endif
#ifndef IOPRIO_CLASS_BE
# define IOPRIO_CLASS_BE 2
#else
assert_cc(IOPRIO_CLASS_BE == 2);
#endif
#ifndef IOPRIO_CLASS_IDLE
# define IOPRIO_CLASS_IDLE 3
#else
assert_cc(IOPRIO_CLASS_IDLE == 3);
#endif
#ifndef IOPRIO_WHO_PROCESS
# define IOPRIO_WHO_PROCESS 1
#else
assert_cc(IOPRIO_WHO_PROCESS == 1);
#endif
#ifndef IOPRIO_WHO_PGRP
# define IOPRIO_WHO_PGRP 2
#else
assert_cc(IOPRIO_WHO_PGRP == 2);
#endif
#ifndef IOPRIO_WHO_USER
# define IOPRIO_WHO_USER 3
#else
assert_cc(IOPRIO_WHO_USER == 3);
#endif
#ifndef IOPRIO_BITS
# define IOPRIO_BITS 16
#else
assert_cc(IOPRIO_BITS == 16);
#endif
#ifndef IOPRIO_N_CLASSES
# define IOPRIO_N_CLASSES 8
#else
assert_cc(IOPRIO_N_CLASSES == 8);
#endif
#ifndef IOPRIO_CLASS_SHIFT
# define IOPRIO_CLASS_SHIFT 13
#else
assert_cc(IOPRIO_CLASS_SHIFT == 13);
#endif
static inline int ioprio_prio_class(int value) {

View File

@ -4,40 +4,60 @@
#include <inttypes.h>
#include <linux/keyctl.h>
#include "macro.h"
#ifndef KEYCTL_JOIN_SESSION_KEYRING
#define KEYCTL_JOIN_SESSION_KEYRING 1
# define KEYCTL_JOIN_SESSION_KEYRING 1
#else
assert_cc(KEYCTL_JOIN_SESSION_KEYRING == 1);
#endif
#ifndef KEYCTL_CHOWN
#define KEYCTL_CHOWN 4
# define KEYCTL_CHOWN 4
#else
assert_cc(KEYCTL_CHOWN == 4);
#endif
#ifndef KEYCTL_SETPERM
#define KEYCTL_SETPERM 5
# define KEYCTL_SETPERM 5
#else
assert_cc(KEYCTL_SETPERM == 5);
#endif
#ifndef KEYCTL_DESCRIBE
#define KEYCTL_DESCRIBE 6
# define KEYCTL_DESCRIBE 6
#else
assert_cc(KEYCTL_DESCRIBE == 6);
#endif
#ifndef KEYCTL_LINK
#define KEYCTL_LINK 8
# define KEYCTL_LINK 8
#else
assert_cc(KEYCTL_LINK == 8);
#endif
#ifndef KEYCTL_READ
#define KEYCTL_READ 11
# define KEYCTL_READ 11
#else
assert_cc(KEYCTL_READ == 11);
#endif
#ifndef KEYCTL_SET_TIMEOUT
#define KEYCTL_SET_TIMEOUT 15
# define KEYCTL_SET_TIMEOUT 15
#else
assert_cc(KEYCTL_SET_TIMEOUT == 15);
#endif
#ifndef KEY_SPEC_USER_KEYRING
#define KEY_SPEC_USER_KEYRING -4
# define KEY_SPEC_USER_KEYRING -4
#else
assert_cc(KEY_SPEC_USER_KEYRING == -4);
#endif
#ifndef KEY_SPEC_SESSION_KEYRING
#define KEY_SPEC_SESSION_KEYRING -3
# define KEY_SPEC_SESSION_KEYRING -3
#else
assert_cc(KEY_SPEC_SESSION_KEYRING == -3);
#endif
/* From linux/key.h */
@ -45,35 +65,37 @@
typedef int32_t key_serial_t;
#define KEY_POS_VIEW 0x01000000
#define KEY_POS_READ 0x02000000
#define KEY_POS_WRITE 0x04000000
#define KEY_POS_SEARCH 0x08000000
#define KEY_POS_LINK 0x10000000
#define KEY_POS_SETATTR 0x20000000
#define KEY_POS_ALL 0x3f000000
# define KEY_POS_VIEW 0x01000000
# define KEY_POS_READ 0x02000000
# define KEY_POS_WRITE 0x04000000
# define KEY_POS_SEARCH 0x08000000
# define KEY_POS_LINK 0x10000000
# define KEY_POS_SETATTR 0x20000000
# define KEY_POS_ALL 0x3f000000
#define KEY_USR_VIEW 0x00010000
#define KEY_USR_READ 0x00020000
#define KEY_USR_WRITE 0x00040000
#define KEY_USR_SEARCH 0x00080000
#define KEY_USR_LINK 0x00100000
#define KEY_USR_SETATTR 0x00200000
#define KEY_USR_ALL 0x003f0000
# define KEY_USR_VIEW 0x00010000
# define KEY_USR_READ 0x00020000
# define KEY_USR_WRITE 0x00040000
# define KEY_USR_SEARCH 0x00080000
# define KEY_USR_LINK 0x00100000
# define KEY_USR_SETATTR 0x00200000
# define KEY_USR_ALL 0x003f0000
#define KEY_GRP_VIEW 0x00000100
#define KEY_GRP_READ 0x00000200
#define KEY_GRP_WRITE 0x00000400
#define KEY_GRP_SEARCH 0x00000800
#define KEY_GRP_LINK 0x00001000
#define KEY_GRP_SETATTR 0x00002000
#define KEY_GRP_ALL 0x00003f00
# define KEY_GRP_VIEW 0x00000100
# define KEY_GRP_READ 0x00000200
# define KEY_GRP_WRITE 0x00000400
# define KEY_GRP_SEARCH 0x00000800
# define KEY_GRP_LINK 0x00001000
# define KEY_GRP_SETATTR 0x00002000
# define KEY_GRP_ALL 0x00003f00
#define KEY_OTH_VIEW 0x00000001
#define KEY_OTH_READ 0x00000002
#define KEY_OTH_WRITE 0x00000004
#define KEY_OTH_SEARCH 0x00000008
#define KEY_OTH_LINK 0x00000010
#define KEY_OTH_SETATTR 0x00000020
#define KEY_OTH_ALL 0x0000003f
# define KEY_OTH_VIEW 0x00000001
# define KEY_OTH_READ 0x00000002
# define KEY_OTH_WRITE 0x00000004
# define KEY_OTH_SEARCH 0x00000008
# define KEY_OTH_LINK 0x00000010
# define KEY_OTH_SETATTR 0x00000020
# define KEY_OTH_ALL 0x0000003f
#else
assert_cc(KEY_OTH_ALL == 0x0000003f);
#endif

View File

@ -3,6 +3,8 @@
#include <linux/loop.h>
#include "macro.h"
#ifndef LOOP_CONFIGURE
struct loop_config {
__u32 fd;
@ -11,12 +13,17 @@ struct loop_config {
__u64 __reserved[8];
};
#define LOOP_CONFIGURE 0x4C0A
# define LOOP_CONFIGURE 0x4C0A
#else
assert_cc(LOOP_CONFIGURE == 0x4C0A);
#endif
#ifndef LO_FLAGS_DIRECT_IO
#define LO_FLAGS_DIRECT_IO 16
#define LOOP_SET_DIRECT_IO 0x4C08
# define LO_FLAGS_DIRECT_IO 16
# define LOOP_SET_DIRECT_IO 0x4C08
#else
assert_cc(LO_FLAGS_DIRECT_IO == 16);
assert_cc(LO_FLAGS_DIRECT_IO == 0x4C08);
#endif
#ifndef LOOP_SET_STATUS_SETTABLE_FLAGS

View File

@ -5,195 +5,273 @@
/* 62aa81d7c4c24b90fdb61da70ac0dbbc414f9939 (4.13) */
#ifndef OCFS2_SUPER_MAGIC
#define OCFS2_SUPER_MAGIC 0x7461636f
# define OCFS2_SUPER_MAGIC 0x7461636f
#else
assert_cc(OCFS2_SUPER_MAGIC == 0x7461636f);
#endif
/* 67e9c74b8a873408c27ac9a8e4c1d1c8d72c93ff (4.5) */
#ifndef CGROUP2_SUPER_MAGIC
#define CGROUP2_SUPER_MAGIC 0x63677270
# define CGROUP2_SUPER_MAGIC 0x63677270
#else
assert_cc(CGROUP2_SUPER_MAGIC == 0x63677270);
#endif
/* 4282d60689d4f21b40692029080440cc58e8a17d (4.1) */
#ifndef TRACEFS_MAGIC
#define TRACEFS_MAGIC 0x74726163
# define TRACEFS_MAGIC 0x74726163
#else
assert_cc(TRACEFS_MAGIC == 0x74726163);
#endif
/* e149ed2b805fefdccf7ccdfc19eca22fdd4514ac (3.19) */
#ifndef NSFS_MAGIC
#define NSFS_MAGIC 0x6e736673
# define NSFS_MAGIC 0x6e736673
#else
assert_cc(NSFS_MAGIC == 0x6e736673);
#endif
/* b2197755b2633e164a439682fb05a9b5ea48f706 (4.4) */
#ifndef BPF_FS_MAGIC
#define BPF_FS_MAGIC 0xcafe4a11
# define BPF_FS_MAGIC 0xcafe4a11
#else
assert_cc(BPF_FS_MAGIC == 0xcafe4a11);
#endif
/* Not exposed yet (4.20). Defined at ipc/mqueue.c */
#ifndef MQUEUE_MAGIC
#define MQUEUE_MAGIC 0x19800202
# define MQUEUE_MAGIC 0x19800202
#else
assert_cc(MQUEUE_MAGIC == 0x19800202);
#endif
/* Not exposed yet (as of Linux 5.4). Defined in fs/xfs/libxfs/xfs_format.h */
#ifndef XFS_SB_MAGIC
#define XFS_SB_MAGIC 0x58465342
# define XFS_SB_MAGIC 0x58465342
#else
assert_cc(XFS_SB_MAGIC == 0x58465342);
#endif
/* dea2903719283c156b53741126228c4a1b40440f (5.17) */
#ifndef CIFS_SUPER_MAGIC
#define CIFS_SUPER_MAGIC 0xFF534D42
# define CIFS_SUPER_MAGIC 0xFF534D42
#else
assert_cc(CIFS_SUPER_MAGIC == 0xFF534D42);
#endif
/* dea2903719283c156b53741126228c4a1b40440f (5.17) */
#ifndef SMB2_SUPER_MAGIC
#define SMB2_SUPER_MAGIC 0xFE534D42
# define SMB2_SUPER_MAGIC 0xFE534D42
#else
assert_cc(SMB2_SUPER_MAGIC == 0xFE534D42);
#endif
/* 257f871993474e2bde6c497b54022c362cf398e1 (4.5) */
#ifndef OVERLAYFS_SUPER_MAGIC
#define OVERLAYFS_SUPER_MAGIC 0x794c7630
# define OVERLAYFS_SUPER_MAGIC 0x794c7630
#else
assert_cc(OVERLAYFS_SUPER_MAGIC == 0x794c7630);
#endif
/* 2a28900be20640fcd1e548b1e3bad79e8221fcf9 (4.7) */
#ifndef UDF_SUPER_MAGIC
#define UDF_SUPER_MAGIC 0x15013346
# define UDF_SUPER_MAGIC 0x15013346
#else
assert_cc(UDF_SUPER_MAGIC == 0x15013346);
#endif
/* b1123ea6d3b3da25af5c8a9d843bd07ab63213f4 (4.8) */
#ifndef BALLOON_KVM_MAGIC
#define BALLOON_KVM_MAGIC 0x13661366
# define BALLOON_KVM_MAGIC 0x13661366
#else
assert_cc(BALLOON_KVM_MAGIC == 0x13661366);
#endif
/* 48b4800a1c6af2cdda344ea4e2c843dcc1f6afc9 (4.8) */
#ifndef ZSMALLOC_MAGIC
#define ZSMALLOC_MAGIC 0x58295829
# define ZSMALLOC_MAGIC 0x58295829
#else
assert_cc(ZSMALLOC_MAGIC == 0x58295829);
#endif
/* 3bc52c45bac26bf7ed1dc8d287ad1aeaed1250b6 (4.9) */
#ifndef DAXFS_MAGIC
#define DAXFS_MAGIC 0x64646178
# define DAXFS_MAGIC 0x64646178
#else
assert_cc(DAXFS_MAGIC == 0x64646178);
#endif
/* 5ff193fbde20df5d80fec367cea3e7856c057320 (4.10) */
#ifndef RDTGROUP_SUPER_MAGIC
#define RDTGROUP_SUPER_MAGIC 0x7655821
# define RDTGROUP_SUPER_MAGIC 0x7655821
#else
assert_cc(RDTGROUP_SUPER_MAGIC == 0x7655821);
#endif
/* a481f4d917835cad86701fc0d1e620c74bb5cd5f (4.13) */
#ifndef AAFS_MAGIC
#define AAFS_MAGIC 0x5a3c69f0
# define AAFS_MAGIC 0x5a3c69f0
#else
assert_cc(AAFS_MAGIC == 0x5a3c69f0);
#endif
/* f044c8847bb61eff5e1e95b6f6bb950e7f4a73a4 (4.15) */
#ifndef AFS_FS_MAGIC
#define AFS_FS_MAGIC 0x6b414653
# define AFS_FS_MAGIC 0x6b414653
#else
assert_cc(AFS_FS_MAGIC == 0x6b414653);
#endif
/* dddde68b8f06dd83486124b8d245e7bfb15c185d (4.20) */
#ifndef XFS_SUPER_MAGIC
#define XFS_SUPER_MAGIC 0x58465342
# define XFS_SUPER_MAGIC 0x58465342
#else
assert_cc(XFS_SUPER_MAGIC == 0x58465342);
#endif
/* 3ad20fe393b31025bebfc2d76964561f65df48aa (5.0) */
#ifndef BINDERFS_SUPER_MAGIC
#define BINDERFS_SUPER_MAGIC 0x6c6f6f70
# define BINDERFS_SUPER_MAGIC 0x6c6f6f70
#else
assert_cc(BINDERFS_SUPER_MAGIC == 0x6c6f6f70);
#endif
/* ed63bb1d1f8469586006a9ca63c42344401aa2ab (5.3) */
#ifndef DMA_BUF_MAGIC
#define DMA_BUF_MAGIC 0x444d4142
# define DMA_BUF_MAGIC 0x444d4142
#else
assert_cc(DMA_BUF_MAGIC == 0x444d4142);
#endif
/* ea8157ab2ae5e914dd427e5cfab533b6da3819cd (5.3) */
#ifndef Z3FOLD_MAGIC
#define Z3FOLD_MAGIC 0x33
# define Z3FOLD_MAGIC 0x33
#else
assert_cc(Z3FOLD_MAGIC == 0x33);
#endif
/* 47e4937a4a7ca4184fd282791dfee76c6799966a (5.4) */
#ifndef EROFS_SUPER_MAGIC_V1
#define EROFS_SUPER_MAGIC_V1 0xe0f5e1e2
# define EROFS_SUPER_MAGIC_V1 0xe0f5e1e2
#else
assert_cc(EROFS_SUPER_MAGIC_V1 == 0xe0f5e1e2);
#endif
/* fe030c9b85e6783bc52fe86449c0a4b8aa16c753 (5.5) */
#ifndef PPC_CMM_MAGIC
#define PPC_CMM_MAGIC 0xc7571590
# define PPC_CMM_MAGIC 0xc7571590
#else
assert_cc(PPC_CMM_MAGIC == 0xc7571590);
#endif
/* 8dcc1a9d90c10fa4143e5c17821082e5e60e46a1 (5.6) */
#ifndef ZONEFS_MAGIC
#define ZONEFS_MAGIC 0x5a4f4653
# define ZONEFS_MAGIC 0x5a4f4653
#else
assert_cc(ZONEFS_MAGIC == 0x5a4f4653);
#endif
/* 3234ac664a870e6ea69ae3a57d824cd7edbeacc5 (5.8) */
#ifndef DEVMEM_MAGIC
#define DEVMEM_MAGIC 0x454d444d
# define DEVMEM_MAGIC 0x454d444d
#else
assert_cc(DEVMEM_MAGIC == 0x454d444d);
#endif
/* cb12fd8e0dabb9a1c8aef55a6a41e2c255fcdf4b (6.8) */
#ifndef PID_FS_MAGIC
#define PID_FS_MAGIC 0x50494446
# define PID_FS_MAGIC 0x50494446
#else
assert_cc(PID_FS_MAGIC == 0x50494446);
#endif
/* Not in mainline but included in Ubuntu */
#ifndef SHIFTFS_MAGIC
#define SHIFTFS_MAGIC 0x6a656a62
# define SHIFTFS_MAGIC 0x6a656a62
#else
assert_cc(SHIFTFS_MAGIC == 0x6a656a62);
#endif
/* 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49 (5.14) */
#ifndef SECRETMEM_MAGIC
#define SECRETMEM_MAGIC 0x5345434d
# define SECRETMEM_MAGIC 0x5345434d
#else
assert_cc(SECRETMEM_MAGIC == 0x5345434d);
#endif
/* Not exposed yet. Defined at fs/fuse/inode.c */
#ifndef FUSE_SUPER_MAGIC
#define FUSE_SUPER_MAGIC 0x65735546
# define FUSE_SUPER_MAGIC 0x65735546
#else
assert_cc(FUSE_SUPER_MAGIC == 0x65735546);
#endif
/* Not exposed yet. Defined at fs/fuse/control.c */
#ifndef FUSE_CTL_SUPER_MAGIC
#define FUSE_CTL_SUPER_MAGIC 0x65735543
# define FUSE_CTL_SUPER_MAGIC 0x65735543
#else
assert_cc(FUSE_CTL_SUPER_MAGIC == 0x65735543);
#endif
/* Not exposed yet. Defined at fs/ceph/super.h */
#ifndef CEPH_SUPER_MAGIC
#define CEPH_SUPER_MAGIC 0x00c36400
# define CEPH_SUPER_MAGIC 0x00c36400
#else
assert_cc(CEPH_SUPER_MAGIC == 0x00c36400);
#endif
/* Not exposed yet. Defined at fs/orangefs/orangefs-kernel.h */
#ifndef ORANGEFS_DEVREQ_MAGIC
#define ORANGEFS_DEVREQ_MAGIC 0x20030529
# define ORANGEFS_DEVREQ_MAGIC 0x20030529
#else
assert_cc(ORANGEFS_DEVREQ_MAGIC == 0x20030529);
#endif
/* linux/gfs2_ondisk.h */
#ifndef GFS2_MAGIC
#define GFS2_MAGIC 0x01161970
# define GFS2_MAGIC 0x01161970
#else
assert_cc(GFS2_MAGIC == 0x01161970);
#endif
/* Not exposed yet. Defined at fs/configfs/mount.c */
#ifndef CONFIGFS_MAGIC
#define CONFIGFS_MAGIC 0x62656570
# define CONFIGFS_MAGIC 0x62656570
#else
assert_cc(CONFIGFS_MAGIC == 0x62656570);
#endif
/* Not exposed yet. Defined at fs/vboxsf/super.c */
#ifndef VBOXSF_SUPER_MAGIC
#define VBOXSF_SUPER_MAGIC 0x786f4256
# define VBOXSF_SUPER_MAGIC 0x786f4256
#else
assert_cc(VBOXSF_SUPER_MAGIC == 0x786f4256);
#endif
/* Not exposed yet. Defined at fs/exfat/exfat_fs.h */
#ifndef EXFAT_SUPER_MAGIC
#define EXFAT_SUPER_MAGIC 0x2011BAB0UL
# define EXFAT_SUPER_MAGIC 0x2011BAB0UL
#else
assert_cc(EXFAT_SUPER_MAGIC == 0x2011BAB0UL);
#endif
/* Not exposed yet, internally actually called RPCAUTH_GSSMAGIC. Defined in net/sunrpc/rpc_pipe.c */
#ifndef RPC_PIPEFS_SUPER_MAGIC
#define RPC_PIPEFS_SUPER_MAGIC 0x67596969
# define RPC_PIPEFS_SUPER_MAGIC 0x67596969
#else
assert_cc(RPC_PIPEFS_SUPER_MAGIC == 0x67596969);
#endif
/* Not exposed yet, defined at fs/ntfs/ntfs.h */
#ifndef NTFS_SB_MAGIC
#define NTFS_SB_MAGIC 0x5346544e
# define NTFS_SB_MAGIC 0x5346544e
#else
assert_cc(NTFS_SB_MAGIC == 0x5346544e);
#endif
/* Not exposed yet, encoded literally in fs/ntfs3/super.c. */
#ifndef NTFS3_SUPER_MAGIC
#define NTFS3_SUPER_MAGIC 0x7366746e
# define NTFS3_SUPER_MAGIC 0x7366746e
#else
assert_cc(NTFS3_SUPER_MAGIC == 0x7366746e);
#endif

View File

@ -3,18 +3,28 @@
#include <sys/mman.h>
#include "macro.h"
#ifndef MFD_ALLOW_SEALING
#define MFD_ALLOW_SEALING 0x0002U
# define MFD_ALLOW_SEALING 0x0002U
#else
assert_cc(MFD_ALLOW_SEALING == 0x0002U);
#endif
#ifndef MFD_CLOEXEC
#define MFD_CLOEXEC 0x0001U
# define MFD_CLOEXEC 0x0001U
#else
assert_cc(MFD_CLOEXEC == 0x0001U);
#endif
#ifndef MFD_NOEXEC_SEAL
#define MFD_NOEXEC_SEAL 0x0008U
# define MFD_NOEXEC_SEAL 0x0008U
#else
assert_cc(MFD_NOEXEC_SEAL == 0x0008U);
#endif
#ifndef MFD_EXEC
#define MFD_EXEC 0x0010U
# define MFD_EXEC 0x0010U
#else
assert_cc(MFD_EXEC == 0x0010U);
#endif

View File

@ -3,7 +3,11 @@
#include <sys/mount.h>
#include "macro.h"
/* dab741e0e02bd3c4f5e2e97be74b39df2523fc6e (5.10) */
#ifndef MS_NOSYMFOLLOW
#define MS_NOSYMFOLLOW 256
# define MS_NOSYMFOLLOW 256
#else
assert_cc(MS_NOSYMFOLLOW == 256);
#endif

View File

@ -3,6 +3,8 @@
#include <linux/prctl.h>
#include "macro.h"
/* 58319057b7847667f0c9585b9de0e8932b0fdb08 (4.3) */
#ifndef PR_CAP_AMBIENT
#define PR_CAP_AMBIENT 47
@ -15,12 +17,19 @@
/* b507808ebce23561d4ff8c2aa1fb949fe402bc61 (6.3) */
#ifndef PR_SET_MDWE
#define PR_SET_MDWE 65
# define PR_SET_MDWE 65
#else
assert_cc(PR_SET_MDWE == 65);
#endif
#ifndef PR_MDWE_REFUSE_EXEC_GAIN
#define PR_MDWE_REFUSE_EXEC_GAIN 1
# define PR_MDWE_REFUSE_EXEC_GAIN 1
#else
assert_cc(PR_MDWE_REFUSE_EXEC_GAIN == 1);
#endif
#ifndef PR_SET_MEMORY_MERGE
#define PR_SET_MEMORY_MERGE 67
# define PR_SET_MEMORY_MERGE 67
#else
assert_cc(PR_SET_MEMORY_MERGE == 67);
#endif

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "macro.h"
#if USE_SYS_RANDOM_H
# include <sys/random.h>
#else
@ -8,13 +10,19 @@
#endif
#ifndef GRND_NONBLOCK
#define GRND_NONBLOCK 0x0001
# define GRND_NONBLOCK 0x0001
#else
assert_cc(GRND_NONBLOCK == 0x0001);
#endif
#ifndef GRND_RANDOM
#define GRND_RANDOM 0x0002
# define GRND_RANDOM 0x0002
#else
assert_cc(GRND_RANDOM == 0x0002);
#endif
#ifndef GRND_INSECURE
#define GRND_INSECURE 0x0004
# define GRND_INSECURE 0x0004
#else
assert_cc(GRND_INSECURE == 0x0004);
#endif

View File

@ -3,8 +3,12 @@
#include <sys/resource.h>
#include "macro.h"
#ifndef RLIMIT_RTTIME
#define RLIMIT_RTTIME 15
# define RLIMIT_RTTIME 15
#else
assert_cc(RLIMIT_RTTIME == 15);
#endif
/* If RLIMIT_RTTIME is not defined, then we cannot use RLIMIT_NLIMITS as is */

View File

@ -3,18 +3,26 @@
#include <sched.h>
#include "macro.h"
#ifndef CLONE_NEWCGROUP
#define CLONE_NEWCGROUP 0x02000000
# define CLONE_NEWCGROUP 0x02000000
#else
assert_cc(CLONE_NEWCGROUP == 0x02000000);
#endif
/* 769071ac9f20b6a447410c7eaa55d1a5233ef40c (5.8) */
#ifndef CLONE_NEWTIME
#define CLONE_NEWTIME 0x00000080
# define CLONE_NEWTIME 0x00000080
#else
assert_cc(CLONE_NEWTIME == 0x00000080);
#endif
/* Not exposed yet. Defined at include/linux/sched.h */
#ifndef PF_KTHREAD
#define PF_KTHREAD 0x00200000
# define PF_KTHREAD 0x00200000
#else
assert_cc(PF_KTHREAD == 0x00200000);
#endif
/* The maximum thread/process name length including trailing NUL byte. This mimics the kernel definition of the same
@ -22,5 +30,7 @@
* name nor any other. */
/* Not exposed yet. Defined at include/linux/sched.h */
#ifndef TASK_COMM_LEN
#define TASK_COMM_LEN 16
# define TASK_COMM_LEN 16
#else
assert_cc(TASK_COMM_LEN == 16);
#endif

View File

@ -3,6 +3,10 @@
#include <sys/timerfd.h>
#include "macro.h"
#ifndef TFD_TIMER_CANCEL_ON_SET
#define TFD_TIMER_CANCEL_ON_SET (1 << 1)
# define TFD_TIMER_CANCEL_ON_SET (1 << 1)
#else
assert_cc(TFD_TIMER_CANCEL_ON_SET == (1 << 1));
#endif

View File

@ -3,6 +3,10 @@
#include <sys/wait.h>
#include "macro.h"
#ifndef P_PIDFD
#define P_PIDFD 3
# define P_PIDFD 3
#else
assert_cc(P_PIDFD == 3);
#endif