Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new constants to be used in (linux) sysctl #3423

Merged
merged 3 commits into from Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions libc-test/build.rs
Expand Up @@ -1569,6 +1569,7 @@ fn test_android(target: &str) {
"libgen.h",
"limits.h",
"link.h",
"linux/sysctl.h",
"locale.h",
"malloc.h",
"net/ethernet.h",
Expand Down Expand Up @@ -3264,6 +3265,7 @@ fn test_linux(target: &str) {
"libgen.h",
"limits.h",
"link.h",
"linux/sysctl.h",
"locale.h",
"malloc.h",
"mntent.h",
Expand Down
129 changes: 129 additions & 0 deletions src/unix/linux_like/android/mod.rs
Expand Up @@ -3153,6 +3153,135 @@ pub const RTMSG_DELDEVICE: u32 = 0x12;
pub const RTMSG_NEWROUTE: u32 = 0x21;
pub const RTMSG_DELROUTE: u32 = 0x22;

pub const CTL_KERN: ::c_int = 1;
pub const CTL_VM: ::c_int = 2;
pub const CTL_NET: ::c_int = 3;
pub const CTL_FS: ::c_int = 5;
pub const CTL_DEBUG: ::c_int = 6;
pub const CTL_DEV: ::c_int = 7;
pub const CTL_BUS: ::c_int = 8;
pub const CTL_ABI: ::c_int = 9;
pub const CTL_CPU: ::c_int = 10;

pub const CTL_BUS_ISA: ::c_int = 1;

pub const INOTIFY_MAX_USER_INSTANCES: ::c_int = 1;
pub const INOTIFY_MAX_USER_WATCHES: ::c_int = 2;
pub const INOTIFY_MAX_QUEUED_EVENTS: ::c_int = 3;

pub const KERN_OSTYPE: ::c_int = 1;
pub const KERN_OSRELEASE: ::c_int = 2;
pub const KERN_OSREV: ::c_int = 3;
pub const KERN_VERSION: ::c_int = 4;
pub const KERN_SECUREMASK: ::c_int = 5;
pub const KERN_PROF: ::c_int = 6;
pub const KERN_NODENAME: ::c_int = 7;
pub const KERN_DOMAINNAME: ::c_int = 8;
pub const KERN_PANIC: ::c_int = 15;
pub const KERN_REALROOTDEV: ::c_int = 16;
pub const KERN_SPARC_REBOOT: ::c_int = 21;
pub const KERN_CTLALTDEL: ::c_int = 22;
pub const KERN_PRINTK: ::c_int = 23;
pub const KERN_NAMETRANS: ::c_int = 24;
pub const KERN_PPC_HTABRECLAIM: ::c_int = 25;
pub const KERN_PPC_ZEROPAGED: ::c_int = 26;
pub const KERN_PPC_POWERSAVE_NAP: ::c_int = 27;
pub const KERN_MODPROBE: ::c_int = 28;
pub const KERN_SG_BIG_BUFF: ::c_int = 29;
pub const KERN_ACCT: ::c_int = 30;
pub const KERN_PPC_L2CR: ::c_int = 31;
pub const KERN_RTSIGNR: ::c_int = 32;
pub const KERN_RTSIGMAX: ::c_int = 33;
pub const KERN_SHMMAX: ::c_int = 34;
pub const KERN_MSGMAX: ::c_int = 35;
pub const KERN_MSGMNB: ::c_int = 36;
pub const KERN_MSGPOOL: ::c_int = 37;
pub const KERN_SYSRQ: ::c_int = 38;
pub const KERN_MAX_THREADS: ::c_int = 39;
pub const KERN_RANDOM: ::c_int = 40;
pub const KERN_SHMALL: ::c_int = 41;
pub const KERN_MSGMNI: ::c_int = 42;
pub const KERN_SEM: ::c_int = 43;
pub const KERN_SPARC_STOP_A: ::c_int = 44;
pub const KERN_SHMMNI: ::c_int = 45;
pub const KERN_OVERFLOWUID: ::c_int = 46;
pub const KERN_OVERFLOWGID: ::c_int = 47;
pub const KERN_SHMPATH: ::c_int = 48;
pub const KERN_HOTPLUG: ::c_int = 49;
pub const KERN_IEEE_EMULATION_WARNINGS: ::c_int = 50;
pub const KERN_S390_USER_DEBUG_LOGGING: ::c_int = 51;
pub const KERN_CORE_USES_PID: ::c_int = 52;
pub const KERN_TAINTED: ::c_int = 53;
pub const KERN_CADPID: ::c_int = 54;
pub const KERN_PIDMAX: ::c_int = 55;
pub const KERN_CORE_PATTERN: ::c_int = 56;
pub const KERN_PANIC_ON_OOPS: ::c_int = 57;
pub const KERN_HPPA_PWRSW: ::c_int = 58;
pub const KERN_HPPA_UNALIGNED: ::c_int = 59;
pub const KERN_PRINTK_RATELIMIT: ::c_int = 60;
pub const KERN_PRINTK_RATELIMIT_BURST: ::c_int = 61;
pub const KERN_PTY: ::c_int = 62;
pub const KERN_NGROUPS_MAX: ::c_int = 63;
pub const KERN_SPARC_SCONS_PWROFF: ::c_int = 64;
pub const KERN_HZ_TIMER: ::c_int = 65;
pub const KERN_UNKNOWN_NMI_PANIC: ::c_int = 66;
pub const KERN_BOOTLOADER_TYPE: ::c_int = 67;
pub const KERN_RANDOMIZE: ::c_int = 68;
pub const KERN_SETUID_DUMPABLE: ::c_int = 69;
pub const KERN_SPIN_RETRY: ::c_int = 70;
pub const KERN_ACPI_VIDEO_FLAGS: ::c_int = 71;
pub const KERN_IA64_UNALIGNED: ::c_int = 72;
pub const KERN_COMPAT_LOG: ::c_int = 73;
pub const KERN_MAX_LOCK_DEPTH: ::c_int = 74;

pub const VM_OVERCOMMIT_MEMORY: ::c_int = 5;
pub const VM_PAGE_CLUSTER: ::c_int = 10;
pub const VM_DIRTY_BACKGROUND: ::c_int = 11;
pub const VM_DIRTY_RATIO: ::c_int = 12;
pub const VM_DIRTY_WB_CS: ::c_int = 13;
pub const VM_DIRTY_EXPIRE_CS: ::c_int = 14;
pub const VM_NR_PDFLUSH_THREADS: ::c_int = 15;
pub const VM_OVERCOMMIT_RATIO: ::c_int = 16;
pub const VM_PAGEBUF: ::c_int = 17;
pub const VM_HUGETLB_PAGES: ::c_int = 18;
pub const VM_SWAPPINESS: ::c_int = 19;
pub const VM_LOWMEM_RESERVE_RATIO: ::c_int = 20;
pub const VM_MIN_FREE_KBYTES: ::c_int = 21;
pub const VM_MAX_MAP_COUNT: ::c_int = 22;
pub const VM_LAPTOP_MODE: ::c_int = 23;
pub const VM_BLOCK_DUMP: ::c_int = 24;
pub const VM_HUGETLB_GROUP: ::c_int = 25;
pub const VM_VFS_CACHE_PRESSURE: ::c_int = 26;
pub const VM_LEGACY_VA_LAYOUT: ::c_int = 27;
pub const VM_SWAP_TOKEN_TIMEOUT: ::c_int = 28;
pub const VM_DROP_PAGECACHE: ::c_int = 29;
pub const VM_PERCPU_PAGELIST_FRACTION: ::c_int = 30;
pub const VM_ZONE_RECLAIM_MODE: ::c_int = 31;
pub const VM_MIN_UNMAPPED: ::c_int = 32;
pub const VM_PANIC_ON_OOM: ::c_int = 33;
pub const VM_VDSO_ENABLED: ::c_int = 34;

pub const NET_CORE: ::c_int = 1;
pub const NET_ETHER: ::c_int = 2;
pub const NET_802: ::c_int = 3;
pub const NET_UNIX: ::c_int = 4;
pub const NET_IPV4: ::c_int = 5;
pub const NET_IPX: ::c_int = 6;
pub const NET_ATALK: ::c_int = 7;
pub const NET_NETROM: ::c_int = 8;
pub const NET_AX25: ::c_int = 9;
pub const NET_BRIDGE: ::c_int = 10;
pub const NET_ROSE: ::c_int = 11;
pub const NET_IPV6: ::c_int = 12;
pub const NET_X25: ::c_int = 13;
pub const NET_TR: ::c_int = 14;
pub const NET_DECNET: ::c_int = 15;
pub const NET_ECONET: ::c_int = 16;
pub const NET_SCTP: ::c_int = 17;
pub const NET_LLC: ::c_int = 18;
pub const NET_NETFILTER: ::c_int = 19;
pub const NET_DCCP: ::c_int = 20;

// Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the
// following are only available on newer Linux versions than the versions
// currently used in CI in some configurations, so we define them here.
Expand Down
133 changes: 133 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Expand Up @@ -4029,6 +4029,139 @@ pub const DCCP_SOCKOPT_CCID_TX_INFO: ::c_int = 192;
/// maximum number of services provided on the same listening port
pub const DCCP_SERVICE_LIST_MAX_LEN: ::c_int = 32;

pub const CTL_KERN: ::c_int = 1;
pub const CTL_VM: ::c_int = 2;
pub const CTL_NET: ::c_int = 3;
pub const CTL_FS: ::c_int = 5;
pub const CTL_DEBUG: ::c_int = 6;
pub const CTL_DEV: ::c_int = 7;
pub const CTL_BUS: ::c_int = 8;
pub const CTL_ABI: ::c_int = 9;
pub const CTL_CPU: ::c_int = 10;

pub const CTL_BUS_ISA: ::c_int = 1;

pub const INOTIFY_MAX_USER_INSTANCES: ::c_int = 1;
pub const INOTIFY_MAX_USER_WATCHES: ::c_int = 2;
pub const INOTIFY_MAX_QUEUED_EVENTS: ::c_int = 3;

pub const KERN_OSTYPE: ::c_int = 1;
pub const KERN_OSRELEASE: ::c_int = 2;
pub const KERN_OSREV: ::c_int = 3;
pub const KERN_VERSION: ::c_int = 4;
pub const KERN_SECUREMASK: ::c_int = 5;
pub const KERN_PROF: ::c_int = 6;
pub const KERN_NODENAME: ::c_int = 7;
pub const KERN_DOMAINNAME: ::c_int = 8;
pub const KERN_PANIC: ::c_int = 15;
pub const KERN_REALROOTDEV: ::c_int = 16;
pub const KERN_SPARC_REBOOT: ::c_int = 21;
pub const KERN_CTLALTDEL: ::c_int = 22;
pub const KERN_PRINTK: ::c_int = 23;
pub const KERN_NAMETRANS: ::c_int = 24;
pub const KERN_PPC_HTABRECLAIM: ::c_int = 25;
pub const KERN_PPC_ZEROPAGED: ::c_int = 26;
pub const KERN_PPC_POWERSAVE_NAP: ::c_int = 27;
pub const KERN_MODPROBE: ::c_int = 28;
pub const KERN_SG_BIG_BUFF: ::c_int = 29;
pub const KERN_ACCT: ::c_int = 30;
pub const KERN_PPC_L2CR: ::c_int = 31;
pub const KERN_RTSIGNR: ::c_int = 32;
pub const KERN_RTSIGMAX: ::c_int = 33;
pub const KERN_SHMMAX: ::c_int = 34;
pub const KERN_MSGMAX: ::c_int = 35;
pub const KERN_MSGMNB: ::c_int = 36;
pub const KERN_MSGPOOL: ::c_int = 37;
pub const KERN_SYSRQ: ::c_int = 38;
pub const KERN_MAX_THREADS: ::c_int = 39;
pub const KERN_RANDOM: ::c_int = 40;
pub const KERN_SHMALL: ::c_int = 41;
pub const KERN_MSGMNI: ::c_int = 42;
pub const KERN_SEM: ::c_int = 43;
pub const KERN_SPARC_STOP_A: ::c_int = 44;
pub const KERN_SHMMNI: ::c_int = 45;
pub const KERN_OVERFLOWUID: ::c_int = 46;
pub const KERN_OVERFLOWGID: ::c_int = 47;
pub const KERN_SHMPATH: ::c_int = 48;
pub const KERN_HOTPLUG: ::c_int = 49;
pub const KERN_IEEE_EMULATION_WARNINGS: ::c_int = 50;
pub const KERN_S390_USER_DEBUG_LOGGING: ::c_int = 51;
pub const KERN_CORE_USES_PID: ::c_int = 52;
pub const KERN_TAINTED: ::c_int = 53;
pub const KERN_CADPID: ::c_int = 54;
pub const KERN_PIDMAX: ::c_int = 55;
pub const KERN_CORE_PATTERN: ::c_int = 56;
pub const KERN_PANIC_ON_OOPS: ::c_int = 57;
pub const KERN_HPPA_PWRSW: ::c_int = 58;
pub const KERN_HPPA_UNALIGNED: ::c_int = 59;
pub const KERN_PRINTK_RATELIMIT: ::c_int = 60;
pub const KERN_PRINTK_RATELIMIT_BURST: ::c_int = 61;
pub const KERN_PTY: ::c_int = 62;
pub const KERN_NGROUPS_MAX: ::c_int = 63;
pub const KERN_SPARC_SCONS_PWROFF: ::c_int = 64;
pub const KERN_HZ_TIMER: ::c_int = 65;
pub const KERN_UNKNOWN_NMI_PANIC: ::c_int = 66;
pub const KERN_BOOTLOADER_TYPE: ::c_int = 67;
pub const KERN_RANDOMIZE: ::c_int = 68;
pub const KERN_SETUID_DUMPABLE: ::c_int = 69;
pub const KERN_SPIN_RETRY: ::c_int = 70;
pub const KERN_ACPI_VIDEO_FLAGS: ::c_int = 71;
pub const KERN_IA64_UNALIGNED: ::c_int = 72;
pub const KERN_COMPAT_LOG: ::c_int = 73;
pub const KERN_MAX_LOCK_DEPTH: ::c_int = 74;
pub const KERN_NMI_WATCHDOG: ::c_int = 75;
pub const KERN_PANIC_ON_NMI: ::c_int = 76;

pub const VM_OVERCOMMIT_MEMORY: ::c_int = 5;
pub const VM_PAGE_CLUSTER: ::c_int = 10;
pub const VM_DIRTY_BACKGROUND: ::c_int = 11;
pub const VM_DIRTY_RATIO: ::c_int = 12;
pub const VM_DIRTY_WB_CS: ::c_int = 13;
pub const VM_DIRTY_EXPIRE_CS: ::c_int = 14;
pub const VM_NR_PDFLUSH_THREADS: ::c_int = 15;
pub const VM_OVERCOMMIT_RATIO: ::c_int = 16;
pub const VM_PAGEBUF: ::c_int = 17;
pub const VM_HUGETLB_PAGES: ::c_int = 18;
pub const VM_SWAPPINESS: ::c_int = 19;
pub const VM_LOWMEM_RESERVE_RATIO: ::c_int = 20;
pub const VM_MIN_FREE_KBYTES: ::c_int = 21;
pub const VM_MAX_MAP_COUNT: ::c_int = 22;
pub const VM_LAPTOP_MODE: ::c_int = 23;
pub const VM_BLOCK_DUMP: ::c_int = 24;
pub const VM_HUGETLB_GROUP: ::c_int = 25;
pub const VM_VFS_CACHE_PRESSURE: ::c_int = 26;
pub const VM_LEGACY_VA_LAYOUT: ::c_int = 27;
pub const VM_SWAP_TOKEN_TIMEOUT: ::c_int = 28;
pub const VM_DROP_PAGECACHE: ::c_int = 29;
pub const VM_PERCPU_PAGELIST_FRACTION: ::c_int = 30;
pub const VM_ZONE_RECLAIM_MODE: ::c_int = 31;
pub const VM_MIN_UNMAPPED: ::c_int = 32;
pub const VM_PANIC_ON_OOM: ::c_int = 33;
pub const VM_VDSO_ENABLED: ::c_int = 34;
pub const VM_MIN_SLAB: ::c_int = 35;

pub const NET_CORE: ::c_int = 1;
pub const NET_ETHER: ::c_int = 2;
pub const NET_802: ::c_int = 3;
pub const NET_UNIX: ::c_int = 4;
pub const NET_IPV4: ::c_int = 5;
pub const NET_IPX: ::c_int = 6;
pub const NET_ATALK: ::c_int = 7;
pub const NET_NETROM: ::c_int = 8;
pub const NET_AX25: ::c_int = 9;
pub const NET_BRIDGE: ::c_int = 10;
pub const NET_ROSE: ::c_int = 11;
pub const NET_IPV6: ::c_int = 12;
pub const NET_X25: ::c_int = 13;
pub const NET_TR: ::c_int = 14;
pub const NET_DECNET: ::c_int = 15;
pub const NET_ECONET: ::c_int = 16;
pub const NET_SCTP: ::c_int = 17;
pub const NET_LLC: ::c_int = 18;
pub const NET_NETFILTER: ::c_int = 19;
pub const NET_DCCP: ::c_int = 20;
pub const NET_IRDA: ::c_int = 412;

f! {
pub fn NLA_ALIGN(len: ::c_int) -> ::c_int {
return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1)
Expand Down