Skip to content

Commit 2b9253a

Browse files
committed
Auto merge of #2363 - devnexen:dfbsd_utmpxname, r=Amanieu
dragonflybsd further utmpx db fn
2 parents cf5b24f + da60787 commit 2b9253a

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

libc-test/semver/dragonfly.txt

+10
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,10 @@ _SC_XOPEN_STREAMS
11691169
_SC_XOPEN_UNIX
11701170
_SC_XOPEN_VERSION
11711171
_SC_XOPEN_XCU_VERSION
1172+
_UTX_HOSTSIZE
1173+
_UTX_IDSIZE
1174+
_UTX_LINESIZE
1175+
_UTX_USERSIZE
11721176
__errno_location
11731177
abs
11741178
accept4
@@ -1241,6 +1245,7 @@ getgrouplist
12411245
gethostid
12421246
getifaddrs
12431247
getitimer
1248+
getlastlogx
12441249
getline
12451250
getloadavg
12461251
getnameinfo
@@ -1255,6 +1260,7 @@ getrusage
12551260
getservbyport
12561261
getservent
12571262
getsid
1263+
getutxuser
12581264
getutxent
12591265
getutxid
12601266
getutxline
@@ -1278,6 +1284,7 @@ kevent
12781284
killpg
12791285
kqueue
12801286
labs
1287+
lastlog
12811288
lchflags
12821289
lio_listio
12831290
lockf
@@ -1445,10 +1452,13 @@ truncate
14451452
ttyname_r
14461453
ucontext_t
14471454
unmount
1455+
updatelastlogx
1456+
updwtmpx
14481457
useconds_t
14491458
uselocale
14501459
utimensat
14511460
utmpx
1461+
utmpxname
14521462
uuid
14531463
uuid_t
14541464
vm_size_t

src/unix/bsd/freebsdlike/dragonfly/mod.rs

+44
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,13 @@ s_no_extra_traits! {
230230
pub ut_unused2: [u8; 16],
231231
}
232232

233+
pub struct lastlogx {
234+
pub ll_tv: ::timeval,
235+
pub ll_line: [::c_char; _UTX_LINESIZE],
236+
pub ll_host: [::c_char; _UTX_HOSTSIZE],
237+
pub ll_ss: ::sockaddr_storage,
238+
}
239+
233240
pub struct dirent {
234241
pub d_fileno: ::ino_t,
235242
pub d_namlen: u16,
@@ -376,6 +383,33 @@ cfg_if! {
376383
self.ut_unused2.hash(state);
377384
}
378385
}
386+
impl PartialEq for lastlogx {
387+
fn eq(&self, other: &lastlogx) -> bool {
388+
self.ll_tv == other.ll_tv
389+
&& self.ll_line == other.ll_line
390+
&& self.ll_host == other.ll_host
391+
&& self.ll_ss == other.ll_ss
392+
}
393+
}
394+
impl Eq for lastlogx {}
395+
impl ::fmt::Debug for lastlogx {
396+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
397+
f.debug_struct("lastlogx")
398+
.field("ll_tv", &self.ll_tv)
399+
.field("ll_line", &self.ll_line)
400+
.field("ll_host", &self.ll_host)
401+
.field("ll_ss", &self.ll_ss)
402+
.finish()
403+
}
404+
}
405+
impl ::hash::Hash for lastlogx {
406+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
407+
self.ll_tv.hash(state);
408+
self.ll_line.hash(state);
409+
self.ll_host.hash(state);
410+
self.ll_ss.hash(state);
411+
}
412+
}
379413

380414
impl PartialEq for dirent {
381415
fn eq(&self, other: &dirent) -> bool {
@@ -1120,6 +1154,10 @@ pub const DOWNTIME: ::c_short = 11;
11201154
pub const UTX_DB_UTMPX: ::c_uint = 0;
11211155
pub const UTX_DB_WTMPX: ::c_uint = 1;
11221156
pub const UTX_DB_LASTLOG: ::c_uint = 2;
1157+
pub const _UTX_LINESIZE: usize = 32;
1158+
pub const _UTX_USERSIZE: usize = 32;
1159+
pub const _UTX_IDSIZE: usize = 4;
1160+
pub const _UTX_HOSTSIZE: usize = 256;
11231161

11241162
pub const LC_COLLATE_MASK: ::c_int = 1 << 0;
11251163
pub const LC_CTYPE_MASK: ::c_int = 1 << 1;
@@ -1308,6 +1346,12 @@ extern "C" {
13081346
pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int;
13091347
pub fn shmctl(shmid: ::c_int, cmd: ::c_int, buf: *mut ::shmid_ds) -> ::c_int;
13101348
pub fn procctl(idtype: ::idtype_t, id: ::id_t, cmd: ::c_int, data: *mut ::c_void) -> ::c_int;
1349+
1350+
pub fn updwtmpx(file: *const ::c_char, ut: *const utmpx) -> ::c_int;
1351+
pub fn getlastlogx(fname: *const ::c_char, uid: ::uid_t, ll: *mut lastlogx) -> *mut lastlogx;
1352+
pub fn updlastlogx(fname: *const ::c_char, uid: ::uid_t, ll: *mut lastlogx) -> ::c_int;
1353+
pub fn getutxuser(name: *const ::c_char) -> utmpx;
1354+
pub fn utmpxname(file: *const ::c_char) -> ::c_int;
13111355
}
13121356

13131357
#[link(name = "rt")]

0 commit comments

Comments
 (0)