Skip to content

Commit a358dae

Browse files
Ecordonniertgross35
authored andcommitted
Add missing utmpx apis for linux musl
Close #4322 Also add a deprecation warning, because those functions are only implemented as stubs inside musl. Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com> (backport <#4332>) (cherry picked from commit 42ead6d)
1 parent 1ff2f21 commit a358dae

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

libc-test/semver/linux-musl.txt

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
ACCOUNTING
12
AF_IB
23
AF_MPLS
34
AF_XDP
@@ -37,6 +38,9 @@ RWF_HIPRI
3738
RWF_NOWAIT
3839
RWF_SYNC
3940
USER_PROCESS
41+
UT_HOSTSIZE
42+
UT_LINESIZE
43+
UT_NAMESIZE
4044
_CS_V6_ENV
4145
_CS_V7_ENV
4246
adjtimex
@@ -82,3 +86,4 @@ reallocarray
8286
setutxent
8387
tcp_info
8488
timex
89+
utmpxname

src/unix/linux_like/linux/musl/mod.rs

+34-1
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ pub const INIT_PROCESS: c_short = 5;
654654
pub const LOGIN_PROCESS: c_short = 6;
655655
pub const USER_PROCESS: c_short = 7;
656656
pub const DEAD_PROCESS: c_short = 8;
657-
// musl does not define ACCOUNTING
657+
pub const ACCOUNTING: c_short = 9;
658658

659659
pub const SFD_CLOEXEC: c_int = 0x080000;
660660

@@ -886,6 +886,10 @@ pub const _CS_V7_ENV: c_int = 1149;
886886

887887
pub const CLONE_NEWTIME: c_int = 0x80;
888888

889+
pub const UT_HOSTSIZE: usize = 256;
890+
pub const UT_LINESIZE: usize = 32;
891+
pub const UT_NAMESIZE: usize = 32;
892+
889893
cfg_if! {
890894
if #[cfg(target_arch = "s390x")] {
891895
pub const POSIX_FADV_DONTNEED: c_int = 6;
@@ -985,12 +989,41 @@ extern "C" {
985989
fd: c_int,
986990
) -> c_int;
987991

992+
#[deprecated(
993+
since = "0.2.172",
994+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
995+
)]
988996
pub fn getutxent() -> *mut utmpx;
997+
#[deprecated(
998+
since = "0.2.172",
999+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
1000+
)]
9891001
pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
1002+
#[deprecated(
1003+
since = "0.2.172",
1004+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
1005+
)]
9901006
pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
1007+
#[deprecated(
1008+
since = "0.2.172",
1009+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
1010+
)]
9911011
pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
1012+
#[deprecated(
1013+
since = "0.2.172",
1014+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
1015+
)]
9921016
pub fn setutxent();
1017+
#[deprecated(
1018+
since = "0.2.172",
1019+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
1020+
)]
9931021
pub fn endutxent();
1022+
#[deprecated(
1023+
since = "0.2.172",
1024+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
1025+
)]
1026+
pub fn utmpxname(file: *const c_char) -> c_int;
9941027
}
9951028

9961029
// Alias <foo> to <foo>64 to mimic glibc's LFS64 support

0 commit comments

Comments
 (0)