Skip to content

Commit e8ba00e

Browse files
committed
NetBSD: Introduce utmp_.rs, correct the definition of lastlog
The field order was incorrect. Update this and move it to `new`, along with the rest of `utmp`. As part of this, correct an incorrectly spelled `utpname` to `utmpname`. Fixes: 42289eb "Implement utmp for NetBSD" (backport <#4782>) (cherry picked from commit 6a01e2f)
1 parent ea09f15 commit e8ba00e

File tree

5 files changed

+38
-25
lines changed

5 files changed

+38
-25
lines changed

libc-test/semver/netbsd.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1623,9 +1623,9 @@ updwtmpx
16231623
useconds_t
16241624
utimensat
16251625
utmp
1626+
utmpname
16261627
utmpx
16271628
utmpxname
1628-
utpname
16291629
utrace
16301630
uucred
16311631
wait4

src/new/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ cfg_if! {
185185
} else if #[cfg(target_os = "netbsd")] {
186186
pub use sys::ipc::*;
187187
pub use sys::statvfs::*;
188+
pub use utmp_::*;
188189
} else if #[cfg(target_os = "openbsd")] {
189190
pub use sys::ipc::*;
190191
}

src/new/netbsd/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
77
pub(crate) mod sys;
88
pub(crate) mod unistd;
9+
pub(crate) mod utmp_;

src/new/netbsd/utmp_.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//! Header: `utmp.h`
2+
//!
3+
//! <https://github.com/NetBSD/src/blob/master/include/utmp.h>
4+
5+
use crate::prelude::*;
6+
7+
pub const UT_NAMESIZE: usize = 8;
8+
pub const UT_LINESIZE: usize = 8;
9+
pub const UT_HOSTSIZE: usize = 16;
10+
11+
s! {
12+
pub struct lastlog {
13+
pub ll_time: crate::time_t,
14+
pub ll_line: [c_char; UT_LINESIZE],
15+
pub ll_host: [c_char; UT_HOSTSIZE],
16+
}
17+
18+
pub struct utmp {
19+
pub ut_line: [c_char; UT_LINESIZE],
20+
pub ut_name: [c_char; UT_NAMESIZE],
21+
pub ut_host: [c_char; UT_HOSTSIZE],
22+
pub ut_time: crate::time_t,
23+
}
24+
}
25+
26+
#[link(name = "util")]
27+
extern "C" {
28+
pub fn utmpname(file: *const c_char) -> c_int;
29+
pub fn setutent();
30+
pub fn getutent() -> *mut utmp;
31+
pub fn endutent();
32+
}

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -436,19 +436,6 @@ s! {
436436
_shm_internal: *mut c_void,
437437
}
438438

439-
pub struct utmp {
440-
pub ut_line: [c_char; UT_LINESIZE],
441-
pub ut_name: [c_char; UT_NAMESIZE],
442-
pub ut_host: [c_char; UT_HOSTSIZE],
443-
pub ut_time: crate::time_t,
444-
}
445-
446-
pub struct lastlog {
447-
pub ll_line: [c_char; UT_LINESIZE],
448-
pub ll_host: [c_char; UT_HOSTSIZE],
449-
pub ll_time: crate::time_t,
450-
}
451-
452439
pub struct timex {
453440
pub modes: c_uint,
454441
pub offset: c_long,
@@ -1816,9 +1803,6 @@ pub const CHWFLOW: crate::tcflag_t = crate::MDMBUF | crate::CRTSCTS | crate::CDT
18161803
// pub const _PATH_WTMPX: &[c_char; 14] = b"/var/log/wtmpx";
18171804
// pub const _PATH_LASTLOGX: &[c_char; 17] = b"/var/log/lastlogx";
18181805
// pub const _PATH_UTMP_UPDATE: &[c_char; 24] = b"/usr/libexec/utmp_update";
1819-
pub const UT_NAMESIZE: usize = 8;
1820-
pub const UT_LINESIZE: usize = 8;
1821-
pub const UT_HOSTSIZE: usize = 16;
18221806
pub const _UTX_USERSIZE: usize = 32;
18231807
pub const _UTX_LINESIZE: usize = 32;
18241808
pub const _UTX_PADSIZE: usize = 40;
@@ -2497,13 +2481,8 @@ extern "C" {
24972481
pub fn setutxent();
24982482
pub fn endutxent();
24992483

2500-
pub fn getutmp(ux: *const utmpx, u: *mut utmp);
2501-
pub fn getutmpx(u: *const utmp, ux: *mut utmpx);
2502-
2503-
pub fn utpname(file: *const c_char) -> c_int;
2504-
pub fn setutent();
2505-
pub fn endutent();
2506-
pub fn getutent() -> *mut utmp;
2484+
pub fn getutmp(ux: *const utmpx, u: *mut crate::utmp);
2485+
pub fn getutmpx(u: *const crate::utmp, ux: *mut utmpx);
25072486

25082487
pub fn efopen(p: *const c_char, m: *const c_char) -> crate::FILE;
25092488
pub fn emalloc(n: size_t) -> *mut c_void;
@@ -2566,7 +2545,7 @@ extern "C" {
25662545
precision: size_t,
25672546
) -> *mut c_char;
25682547
#[link_name = "__login50"]
2569-
pub fn login(ut: *const utmp);
2548+
pub fn login(ut: *const crate::utmp);
25702549
#[link_name = "__loginx50"]
25712550
pub fn loginx(ut: *const utmpx);
25722551
pub fn logout(line: *const c_char);

0 commit comments

Comments
 (0)