Skip to content

Commit 6a01e2f

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"
1 parent 066e702 commit 6a01e2f

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
@@ -435,19 +435,6 @@ s! {
435435
_shm_internal: *mut c_void,
436436
}
437437

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

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

25092488
pub fn efopen(p: *const c_char, m: *const c_char) -> crate::FILE;
25102489
pub fn emalloc(n: size_t) -> *mut c_void;
@@ -2567,7 +2546,7 @@ extern "C" {
25672546
precision: size_t,
25682547
) -> *mut c_char;
25692548
#[link_name = "__login50"]
2570-
pub fn login(ut: *const utmp);
2549+
pub fn login(ut: *const crate::utmp);
25712550
#[link_name = "__loginx50"]
25722551
pub fn loginx(ut: *const utmpx);
25732552
pub fn logout(line: *const c_char);

0 commit comments

Comments
 (0)