Skip to content

page_size() returns zero under Alpine Linux #933

@yorickpeterse

Description

@yorickpeterse

The method rustix::param::page_size() returns 0 when using Alpine Linux. Consider this program:

const _SC_PAGESIZE: std::ffi::c_int = 30;

extern "C" {
    fn sysconf(name: std::ffi::c_int) -> std::ffi::c_long;
}

fn page_size() -> usize {
    unsafe { sysconf(_SC_PAGESIZE) as usize }
}

fn main() {
    println!("rustix: {}", rustix::param::page_size());
    println!("libc:   {}", page_size());
}

And this Cargo.toml:

[package]
name = "playground"
version = "0.1.0"
authors = ["Yorick Peterse"]
edition = "2021"

[dependencies]
rustix = { version = "^0.38", features = ["fs", "mm", "param", "process", "net", "std", "time"], default-features = false }
libc = "*"

When running this with cargo run, the output is as follows:

rustix: 0
libc:   4096

This was tested inside an Alpine 3.18.4 container, running on a Fedora 39 host with Linux kernel version 6.5.11.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions