Skip to content

Add missing utmpx apis for linux musl #4332

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

Merged
merged 1 commit into from
Apr 11, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions libc-test/semver/linux-musl.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ACCOUNTING
AF_IB
AF_MPLS
AF_XDP
Expand Down Expand Up @@ -37,6 +38,9 @@ RWF_HIPRI
RWF_NOWAIT
RWF_SYNC
USER_PROCESS
UT_HOSTSIZE
UT_LINESIZE
UT_NAMESIZE
_CS_V6_ENV
_CS_V7_ENV
adjtimex
Expand Down Expand Up @@ -82,3 +86,4 @@ reallocarray
setutxent
tcp_info
timex
utmpxname
35 changes: 34 additions & 1 deletion src/unix/linux_like/linux/musl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ pub const INIT_PROCESS: c_short = 5;
pub const LOGIN_PROCESS: c_short = 6;
pub const USER_PROCESS: c_short = 7;
pub const DEAD_PROCESS: c_short = 8;
// musl does not define ACCOUNTING
pub const ACCOUNTING: c_short = 9;

pub const SFD_CLOEXEC: c_int = 0x080000;

Expand Down Expand Up @@ -888,6 +888,10 @@ pub const _CS_V7_ENV: c_int = 1149;

pub const CLONE_NEWTIME: c_int = 0x80;

pub const UT_HOSTSIZE: usize = 256;
pub const UT_LINESIZE: usize = 32;
pub const UT_NAMESIZE: usize = 32;

cfg_if! {
if #[cfg(target_arch = "s390x")] {
pub const POSIX_FADV_DONTNEED: c_int = 6;
Expand Down Expand Up @@ -987,12 +991,41 @@ extern "C" {
fd: c_int,
) -> c_int;

#[deprecated(
since = "0.2.172",
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
)]
pub fn getutxent() -> *mut utmpx;
#[deprecated(
since = "0.2.172",
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
)]
pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
#[deprecated(
since = "0.2.172",
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
)]
pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
#[deprecated(
since = "0.2.172",
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
)]
pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
#[deprecated(
since = "0.2.172",
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
)]
pub fn setutxent();
#[deprecated(
since = "0.2.172",
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
)]
pub fn endutxent();
#[deprecated(
since = "0.2.172",
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
)]
pub fn utmpxname(file: *const c_char) -> c_int;
}

// Alias <foo> to <foo>64 to mimic glibc's LFS64 support
Expand Down
Loading