From 62f9035f4c7bcd26ce209335b345b65a7fffc557 Mon Sep 17 00:00:00 2001 From: Knight <knight42@mail.ustc.edu.cn> Date: Wed, 27 Jul 2016 20:40:27 +0800 Subject: [PATCH] Add struct utmp for android --- src/unix/notbsd/android/b32.rs | 4 ++++ src/unix/notbsd/android/b64.rs | 4 ++++ src/unix/notbsd/android/mod.rs | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/src/unix/notbsd/android/b32.rs b/src/unix/notbsd/android/b32.rs index 91a56a3f..bd69ccf3 100644 --- a/src/unix/notbsd/android/b32.rs +++ b/src/unix/notbsd/android/b32.rs @@ -142,6 +142,10 @@ pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 2; pub const CPU_SETSIZE: ::size_t = 32; pub const __CPU_BITS: ::size_t = 32; +pub const UT_LINESIZE: usize = 8; +pub const UT_NAMESIZE: usize = 8; +pub const UT_HOSTSIZE: usize = 16; + extern { pub fn timegm64(tm: *const ::tm) -> ::time64_t; } diff --git a/src/unix/notbsd/android/b64.rs b/src/unix/notbsd/android/b64.rs index 025dabd4..b35dde42 100644 --- a/src/unix/notbsd/android/b64.rs +++ b/src/unix/notbsd/android/b64.rs @@ -152,6 +152,10 @@ pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 4; pub const CPU_SETSIZE: ::size_t = 1024; pub const __CPU_BITS: ::size_t = 64; +pub const UT_LINESIZE: usize = 32; +pub const UT_NAMESIZE: usize = 32; +pub const UT_HOSTSIZE: usize = 256; + extern { pub fn timegm(tm: *const ::tm) -> ::time64_t; } diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 5dbd39e9..6c6d7b08 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -100,8 +100,37 @@ s! { pub struct sem_t { count: ::c_uint, } + + pub struct lastlog { + ll_time: ::time_t, + ll_line: [::c_char; UT_LINESIZE], + ll_host: [::c_char; UT_HOSTSIZE], + } + + pub struct exit_status { + pub e_termination: ::c_short, + pub e_exit: ::c_short, + } + + pub struct utmp { + pub ut_type: ::c_short, + pub ut_pid: ::pid_t, + pub ut_line: [::c_char; UT_LINESIZE], + pub ut_id: [::c_char; 4], + + pub ut_user: [::c_char; UT_NAMESIZE], + pub ut_host: [::c_char; UT_HOSTSIZE], + pub ut_exit: exit_status, + pub ut_session: ::c_long, + pub ut_tv: ::timeval, + + pub ut_addr_v6: [::int32_t; 4], + unused: [::c_char; 20], + } } +pub const USER_PROCESS: ::c_short = 7; + pub const BUFSIZ: ::c_uint = 1024; pub const FILENAME_MAX: ::c_uint = 1024; pub const FOPEN_MAX: ::c_uint = 20; @@ -591,6 +620,10 @@ extern { pub fn __sched_cpufree(set: *mut ::cpu_set_t); pub fn __sched_cpucount(setsize: ::size_t, set: *mut cpu_set_t) -> ::c_int; pub fn sched_getcpu() -> ::c_int; + + pub fn utmpname(name: *const ::c_char) -> ::c_int; + pub fn setutent(); + pub fn getutent() -> *mut utmp; } cfg_if! { -- GitLab