Skip to content

Commit 02c385e

Browse files
committed
Auto merge of #3423 - GuillaumeGomez:sysctl-constants, r=JohnTitor
Add new constants to be used in (linux) sysctl I started using `sysctl` and realized that most constants for it are actually not defined in linux so I added them.
2 parents 4d2b981 + 7daf1dc commit 02c385e

File tree

3 files changed

+264
-0
lines changed

3 files changed

+264
-0
lines changed

libc-test/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,7 @@ fn test_android(target: &str) {
15691569
"libgen.h",
15701570
"limits.h",
15711571
"link.h",
1572+
"linux/sysctl.h",
15721573
"locale.h",
15731574
"malloc.h",
15741575
"net/ethernet.h",
@@ -3264,6 +3265,7 @@ fn test_linux(target: &str) {
32643265
"libgen.h",
32653266
"limits.h",
32663267
"link.h",
3268+
"linux/sysctl.h",
32673269
"locale.h",
32683270
"malloc.h",
32693271
"mntent.h",

src/unix/linux_like/android/mod.rs

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3153,6 +3153,135 @@ pub const RTMSG_DELDEVICE: u32 = 0x12;
31533153
pub const RTMSG_NEWROUTE: u32 = 0x21;
31543154
pub const RTMSG_DELROUTE: u32 = 0x22;
31553155

3156+
pub const CTL_KERN: ::c_int = 1;
3157+
pub const CTL_VM: ::c_int = 2;
3158+
pub const CTL_NET: ::c_int = 3;
3159+
pub const CTL_FS: ::c_int = 5;
3160+
pub const CTL_DEBUG: ::c_int = 6;
3161+
pub const CTL_DEV: ::c_int = 7;
3162+
pub const CTL_BUS: ::c_int = 8;
3163+
pub const CTL_ABI: ::c_int = 9;
3164+
pub const CTL_CPU: ::c_int = 10;
3165+
3166+
pub const CTL_BUS_ISA: ::c_int = 1;
3167+
3168+
pub const INOTIFY_MAX_USER_INSTANCES: ::c_int = 1;
3169+
pub const INOTIFY_MAX_USER_WATCHES: ::c_int = 2;
3170+
pub const INOTIFY_MAX_QUEUED_EVENTS: ::c_int = 3;
3171+
3172+
pub const KERN_OSTYPE: ::c_int = 1;
3173+
pub const KERN_OSRELEASE: ::c_int = 2;
3174+
pub const KERN_OSREV: ::c_int = 3;
3175+
pub const KERN_VERSION: ::c_int = 4;
3176+
pub const KERN_SECUREMASK: ::c_int = 5;
3177+
pub const KERN_PROF: ::c_int = 6;
3178+
pub const KERN_NODENAME: ::c_int = 7;
3179+
pub const KERN_DOMAINNAME: ::c_int = 8;
3180+
pub const KERN_PANIC: ::c_int = 15;
3181+
pub const KERN_REALROOTDEV: ::c_int = 16;
3182+
pub const KERN_SPARC_REBOOT: ::c_int = 21;
3183+
pub const KERN_CTLALTDEL: ::c_int = 22;
3184+
pub const KERN_PRINTK: ::c_int = 23;
3185+
pub const KERN_NAMETRANS: ::c_int = 24;
3186+
pub const KERN_PPC_HTABRECLAIM: ::c_int = 25;
3187+
pub const KERN_PPC_ZEROPAGED: ::c_int = 26;
3188+
pub const KERN_PPC_POWERSAVE_NAP: ::c_int = 27;
3189+
pub const KERN_MODPROBE: ::c_int = 28;
3190+
pub const KERN_SG_BIG_BUFF: ::c_int = 29;
3191+
pub const KERN_ACCT: ::c_int = 30;
3192+
pub const KERN_PPC_L2CR: ::c_int = 31;
3193+
pub const KERN_RTSIGNR: ::c_int = 32;
3194+
pub const KERN_RTSIGMAX: ::c_int = 33;
3195+
pub const KERN_SHMMAX: ::c_int = 34;
3196+
pub const KERN_MSGMAX: ::c_int = 35;
3197+
pub const KERN_MSGMNB: ::c_int = 36;
3198+
pub const KERN_MSGPOOL: ::c_int = 37;
3199+
pub const KERN_SYSRQ: ::c_int = 38;
3200+
pub const KERN_MAX_THREADS: ::c_int = 39;
3201+
pub const KERN_RANDOM: ::c_int = 40;
3202+
pub const KERN_SHMALL: ::c_int = 41;
3203+
pub const KERN_MSGMNI: ::c_int = 42;
3204+
pub const KERN_SEM: ::c_int = 43;
3205+
pub const KERN_SPARC_STOP_A: ::c_int = 44;
3206+
pub const KERN_SHMMNI: ::c_int = 45;
3207+
pub const KERN_OVERFLOWUID: ::c_int = 46;
3208+
pub const KERN_OVERFLOWGID: ::c_int = 47;
3209+
pub const KERN_SHMPATH: ::c_int = 48;
3210+
pub const KERN_HOTPLUG: ::c_int = 49;
3211+
pub const KERN_IEEE_EMULATION_WARNINGS: ::c_int = 50;
3212+
pub const KERN_S390_USER_DEBUG_LOGGING: ::c_int = 51;
3213+
pub const KERN_CORE_USES_PID: ::c_int = 52;
3214+
pub const KERN_TAINTED: ::c_int = 53;
3215+
pub const KERN_CADPID: ::c_int = 54;
3216+
pub const KERN_PIDMAX: ::c_int = 55;
3217+
pub const KERN_CORE_PATTERN: ::c_int = 56;
3218+
pub const KERN_PANIC_ON_OOPS: ::c_int = 57;
3219+
pub const KERN_HPPA_PWRSW: ::c_int = 58;
3220+
pub const KERN_HPPA_UNALIGNED: ::c_int = 59;
3221+
pub const KERN_PRINTK_RATELIMIT: ::c_int = 60;
3222+
pub const KERN_PRINTK_RATELIMIT_BURST: ::c_int = 61;
3223+
pub const KERN_PTY: ::c_int = 62;
3224+
pub const KERN_NGROUPS_MAX: ::c_int = 63;
3225+
pub const KERN_SPARC_SCONS_PWROFF: ::c_int = 64;
3226+
pub const KERN_HZ_TIMER: ::c_int = 65;
3227+
pub const KERN_UNKNOWN_NMI_PANIC: ::c_int = 66;
3228+
pub const KERN_BOOTLOADER_TYPE: ::c_int = 67;
3229+
pub const KERN_RANDOMIZE: ::c_int = 68;
3230+
pub const KERN_SETUID_DUMPABLE: ::c_int = 69;
3231+
pub const KERN_SPIN_RETRY: ::c_int = 70;
3232+
pub const KERN_ACPI_VIDEO_FLAGS: ::c_int = 71;
3233+
pub const KERN_IA64_UNALIGNED: ::c_int = 72;
3234+
pub const KERN_COMPAT_LOG: ::c_int = 73;
3235+
pub const KERN_MAX_LOCK_DEPTH: ::c_int = 74;
3236+
3237+
pub const VM_OVERCOMMIT_MEMORY: ::c_int = 5;
3238+
pub const VM_PAGE_CLUSTER: ::c_int = 10;
3239+
pub const VM_DIRTY_BACKGROUND: ::c_int = 11;
3240+
pub const VM_DIRTY_RATIO: ::c_int = 12;
3241+
pub const VM_DIRTY_WB_CS: ::c_int = 13;
3242+
pub const VM_DIRTY_EXPIRE_CS: ::c_int = 14;
3243+
pub const VM_NR_PDFLUSH_THREADS: ::c_int = 15;
3244+
pub const VM_OVERCOMMIT_RATIO: ::c_int = 16;
3245+
pub const VM_PAGEBUF: ::c_int = 17;
3246+
pub const VM_HUGETLB_PAGES: ::c_int = 18;
3247+
pub const VM_SWAPPINESS: ::c_int = 19;
3248+
pub const VM_LOWMEM_RESERVE_RATIO: ::c_int = 20;
3249+
pub const VM_MIN_FREE_KBYTES: ::c_int = 21;
3250+
pub const VM_MAX_MAP_COUNT: ::c_int = 22;
3251+
pub const VM_LAPTOP_MODE: ::c_int = 23;
3252+
pub const VM_BLOCK_DUMP: ::c_int = 24;
3253+
pub const VM_HUGETLB_GROUP: ::c_int = 25;
3254+
pub const VM_VFS_CACHE_PRESSURE: ::c_int = 26;
3255+
pub const VM_LEGACY_VA_LAYOUT: ::c_int = 27;
3256+
pub const VM_SWAP_TOKEN_TIMEOUT: ::c_int = 28;
3257+
pub const VM_DROP_PAGECACHE: ::c_int = 29;
3258+
pub const VM_PERCPU_PAGELIST_FRACTION: ::c_int = 30;
3259+
pub const VM_ZONE_RECLAIM_MODE: ::c_int = 31;
3260+
pub const VM_MIN_UNMAPPED: ::c_int = 32;
3261+
pub const VM_PANIC_ON_OOM: ::c_int = 33;
3262+
pub const VM_VDSO_ENABLED: ::c_int = 34;
3263+
3264+
pub const NET_CORE: ::c_int = 1;
3265+
pub const NET_ETHER: ::c_int = 2;
3266+
pub const NET_802: ::c_int = 3;
3267+
pub const NET_UNIX: ::c_int = 4;
3268+
pub const NET_IPV4: ::c_int = 5;
3269+
pub const NET_IPX: ::c_int = 6;
3270+
pub const NET_ATALK: ::c_int = 7;
3271+
pub const NET_NETROM: ::c_int = 8;
3272+
pub const NET_AX25: ::c_int = 9;
3273+
pub const NET_BRIDGE: ::c_int = 10;
3274+
pub const NET_ROSE: ::c_int = 11;
3275+
pub const NET_IPV6: ::c_int = 12;
3276+
pub const NET_X25: ::c_int = 13;
3277+
pub const NET_TR: ::c_int = 14;
3278+
pub const NET_DECNET: ::c_int = 15;
3279+
pub const NET_ECONET: ::c_int = 16;
3280+
pub const NET_SCTP: ::c_int = 17;
3281+
pub const NET_LLC: ::c_int = 18;
3282+
pub const NET_NETFILTER: ::c_int = 19;
3283+
pub const NET_DCCP: ::c_int = 20;
3284+
31563285
// Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the
31573286
// following are only available on newer Linux versions than the versions
31583287
// currently used in CI in some configurations, so we define them here.

src/unix/linux_like/linux/mod.rs

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4029,6 +4029,139 @@ pub const DCCP_SOCKOPT_CCID_TX_INFO: ::c_int = 192;
40294029
/// maximum number of services provided on the same listening port
40304030
pub const DCCP_SERVICE_LIST_MAX_LEN: ::c_int = 32;
40314031

4032+
pub const CTL_KERN: ::c_int = 1;
4033+
pub const CTL_VM: ::c_int = 2;
4034+
pub const CTL_NET: ::c_int = 3;
4035+
pub const CTL_FS: ::c_int = 5;
4036+
pub const CTL_DEBUG: ::c_int = 6;
4037+
pub const CTL_DEV: ::c_int = 7;
4038+
pub const CTL_BUS: ::c_int = 8;
4039+
pub const CTL_ABI: ::c_int = 9;
4040+
pub const CTL_CPU: ::c_int = 10;
4041+
4042+
pub const CTL_BUS_ISA: ::c_int = 1;
4043+
4044+
pub const INOTIFY_MAX_USER_INSTANCES: ::c_int = 1;
4045+
pub const INOTIFY_MAX_USER_WATCHES: ::c_int = 2;
4046+
pub const INOTIFY_MAX_QUEUED_EVENTS: ::c_int = 3;
4047+
4048+
pub const KERN_OSTYPE: ::c_int = 1;
4049+
pub const KERN_OSRELEASE: ::c_int = 2;
4050+
pub const KERN_OSREV: ::c_int = 3;
4051+
pub const KERN_VERSION: ::c_int = 4;
4052+
pub const KERN_SECUREMASK: ::c_int = 5;
4053+
pub const KERN_PROF: ::c_int = 6;
4054+
pub const KERN_NODENAME: ::c_int = 7;
4055+
pub const KERN_DOMAINNAME: ::c_int = 8;
4056+
pub const KERN_PANIC: ::c_int = 15;
4057+
pub const KERN_REALROOTDEV: ::c_int = 16;
4058+
pub const KERN_SPARC_REBOOT: ::c_int = 21;
4059+
pub const KERN_CTLALTDEL: ::c_int = 22;
4060+
pub const KERN_PRINTK: ::c_int = 23;
4061+
pub const KERN_NAMETRANS: ::c_int = 24;
4062+
pub const KERN_PPC_HTABRECLAIM: ::c_int = 25;
4063+
pub const KERN_PPC_ZEROPAGED: ::c_int = 26;
4064+
pub const KERN_PPC_POWERSAVE_NAP: ::c_int = 27;
4065+
pub const KERN_MODPROBE: ::c_int = 28;
4066+
pub const KERN_SG_BIG_BUFF: ::c_int = 29;
4067+
pub const KERN_ACCT: ::c_int = 30;
4068+
pub const KERN_PPC_L2CR: ::c_int = 31;
4069+
pub const KERN_RTSIGNR: ::c_int = 32;
4070+
pub const KERN_RTSIGMAX: ::c_int = 33;
4071+
pub const KERN_SHMMAX: ::c_int = 34;
4072+
pub const KERN_MSGMAX: ::c_int = 35;
4073+
pub const KERN_MSGMNB: ::c_int = 36;
4074+
pub const KERN_MSGPOOL: ::c_int = 37;
4075+
pub const KERN_SYSRQ: ::c_int = 38;
4076+
pub const KERN_MAX_THREADS: ::c_int = 39;
4077+
pub const KERN_RANDOM: ::c_int = 40;
4078+
pub const KERN_SHMALL: ::c_int = 41;
4079+
pub const KERN_MSGMNI: ::c_int = 42;
4080+
pub const KERN_SEM: ::c_int = 43;
4081+
pub const KERN_SPARC_STOP_A: ::c_int = 44;
4082+
pub const KERN_SHMMNI: ::c_int = 45;
4083+
pub const KERN_OVERFLOWUID: ::c_int = 46;
4084+
pub const KERN_OVERFLOWGID: ::c_int = 47;
4085+
pub const KERN_SHMPATH: ::c_int = 48;
4086+
pub const KERN_HOTPLUG: ::c_int = 49;
4087+
pub const KERN_IEEE_EMULATION_WARNINGS: ::c_int = 50;
4088+
pub const KERN_S390_USER_DEBUG_LOGGING: ::c_int = 51;
4089+
pub const KERN_CORE_USES_PID: ::c_int = 52;
4090+
pub const KERN_TAINTED: ::c_int = 53;
4091+
pub const KERN_CADPID: ::c_int = 54;
4092+
pub const KERN_PIDMAX: ::c_int = 55;
4093+
pub const KERN_CORE_PATTERN: ::c_int = 56;
4094+
pub const KERN_PANIC_ON_OOPS: ::c_int = 57;
4095+
pub const KERN_HPPA_PWRSW: ::c_int = 58;
4096+
pub const KERN_HPPA_UNALIGNED: ::c_int = 59;
4097+
pub const KERN_PRINTK_RATELIMIT: ::c_int = 60;
4098+
pub const KERN_PRINTK_RATELIMIT_BURST: ::c_int = 61;
4099+
pub const KERN_PTY: ::c_int = 62;
4100+
pub const KERN_NGROUPS_MAX: ::c_int = 63;
4101+
pub const KERN_SPARC_SCONS_PWROFF: ::c_int = 64;
4102+
pub const KERN_HZ_TIMER: ::c_int = 65;
4103+
pub const KERN_UNKNOWN_NMI_PANIC: ::c_int = 66;
4104+
pub const KERN_BOOTLOADER_TYPE: ::c_int = 67;
4105+
pub const KERN_RANDOMIZE: ::c_int = 68;
4106+
pub const KERN_SETUID_DUMPABLE: ::c_int = 69;
4107+
pub const KERN_SPIN_RETRY: ::c_int = 70;
4108+
pub const KERN_ACPI_VIDEO_FLAGS: ::c_int = 71;
4109+
pub const KERN_IA64_UNALIGNED: ::c_int = 72;
4110+
pub const KERN_COMPAT_LOG: ::c_int = 73;
4111+
pub const KERN_MAX_LOCK_DEPTH: ::c_int = 74;
4112+
pub const KERN_NMI_WATCHDOG: ::c_int = 75;
4113+
pub const KERN_PANIC_ON_NMI: ::c_int = 76;
4114+
4115+
pub const VM_OVERCOMMIT_MEMORY: ::c_int = 5;
4116+
pub const VM_PAGE_CLUSTER: ::c_int = 10;
4117+
pub const VM_DIRTY_BACKGROUND: ::c_int = 11;
4118+
pub const VM_DIRTY_RATIO: ::c_int = 12;
4119+
pub const VM_DIRTY_WB_CS: ::c_int = 13;
4120+
pub const VM_DIRTY_EXPIRE_CS: ::c_int = 14;
4121+
pub const VM_NR_PDFLUSH_THREADS: ::c_int = 15;
4122+
pub const VM_OVERCOMMIT_RATIO: ::c_int = 16;
4123+
pub const VM_PAGEBUF: ::c_int = 17;
4124+
pub const VM_HUGETLB_PAGES: ::c_int = 18;
4125+
pub const VM_SWAPPINESS: ::c_int = 19;
4126+
pub const VM_LOWMEM_RESERVE_RATIO: ::c_int = 20;
4127+
pub const VM_MIN_FREE_KBYTES: ::c_int = 21;
4128+
pub const VM_MAX_MAP_COUNT: ::c_int = 22;
4129+
pub const VM_LAPTOP_MODE: ::c_int = 23;
4130+
pub const VM_BLOCK_DUMP: ::c_int = 24;
4131+
pub const VM_HUGETLB_GROUP: ::c_int = 25;
4132+
pub const VM_VFS_CACHE_PRESSURE: ::c_int = 26;
4133+
pub const VM_LEGACY_VA_LAYOUT: ::c_int = 27;
4134+
pub const VM_SWAP_TOKEN_TIMEOUT: ::c_int = 28;
4135+
pub const VM_DROP_PAGECACHE: ::c_int = 29;
4136+
pub const VM_PERCPU_PAGELIST_FRACTION: ::c_int = 30;
4137+
pub const VM_ZONE_RECLAIM_MODE: ::c_int = 31;
4138+
pub const VM_MIN_UNMAPPED: ::c_int = 32;
4139+
pub const VM_PANIC_ON_OOM: ::c_int = 33;
4140+
pub const VM_VDSO_ENABLED: ::c_int = 34;
4141+
pub const VM_MIN_SLAB: ::c_int = 35;
4142+
4143+
pub const NET_CORE: ::c_int = 1;
4144+
pub const NET_ETHER: ::c_int = 2;
4145+
pub const NET_802: ::c_int = 3;
4146+
pub const NET_UNIX: ::c_int = 4;
4147+
pub const NET_IPV4: ::c_int = 5;
4148+
pub const NET_IPX: ::c_int = 6;
4149+
pub const NET_ATALK: ::c_int = 7;
4150+
pub const NET_NETROM: ::c_int = 8;
4151+
pub const NET_AX25: ::c_int = 9;
4152+
pub const NET_BRIDGE: ::c_int = 10;
4153+
pub const NET_ROSE: ::c_int = 11;
4154+
pub const NET_IPV6: ::c_int = 12;
4155+
pub const NET_X25: ::c_int = 13;
4156+
pub const NET_TR: ::c_int = 14;
4157+
pub const NET_DECNET: ::c_int = 15;
4158+
pub const NET_ECONET: ::c_int = 16;
4159+
pub const NET_SCTP: ::c_int = 17;
4160+
pub const NET_LLC: ::c_int = 18;
4161+
pub const NET_NETFILTER: ::c_int = 19;
4162+
pub const NET_DCCP: ::c_int = 20;
4163+
pub const NET_IRDA: ::c_int = 412;
4164+
40324165
f! {
40334166
pub fn NLA_ALIGN(len: ::c_int) -> ::c_int {
40344167
return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1)

0 commit comments

Comments
 (0)