Debian Codegraph @

src/x64.rs

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 use super::{cstr_from_bytes, UT_HOSTSIZE, UT_LINESIZE, UT_NAMESIZE};
2 use std::fmt;
•3 use zerocopy::{FromBytes, Immutable, KnownLayout};
4
5 #[repr(C)]
•6 #[derive(Clone, Copy, Debug, FromBytes, Immutable, KnownLayout)]
7 pub struct timeval {
8 /// Seconds
9 pub tv_sec: i64,
10 /// Microseconds
11 pub tv_usec: i64,
12 }
13
14 #[repr(C)]
•15 #[derive(Clone, Copy, FromBytes, Immutable, KnownLayout)]
16 pub struct utmp {
17 /// Device name of tty - `"/dev/"`
18 pub ut_line: [u8; UT_LINESIZE],
19 /// Username
20 pub ut_user: [u8; UT_NAMESIZE],
21 /// Hostname for remote login, or kernel version for run-level message
22 pub ut_host: [u8; UT_HOSTSIZE],
23 /// Time entry was made
24 pub ut_tv: timeval,
25 }
26
27 impl fmt::Debug for utmp {
28 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
29 fmt.debug_struct("utmp")
30 .field("ut_line", &cstr_from_bytes(&self.ut_line))
31 .field("ut_user", &cstr_from_bytes(&self.ut_user))
32 .field("ut_host", &cstr_from_bytes(&self.ut_host))
33 .field("ut_tv", &self.ut_tv)
34 .finish()
35 }
36 }
37
38 #[test]
39 fn test_size_of_utmp_x64() {
40 assert_eq!(std::mem::size_of::<utmp>(), 312);
41 }