Debian Codegraph @

src/x32.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 #[derive(FromBytes, Immutable, KnownLayout, Clone, Copy, Debug)]
6 #[repr(C)]
7 pub struct timeval {
8 /// Seconds
9 pub tv_sec: i32,
10 /// Microseconds
11 pub tv_usec: i32,
12 }
13
14
•15 #[derive(Clone, Copy, FromBytes, Immutable, KnownLayout)]
16 #[repr(C)]
17 pub struct utmp {
18 /// Device name of tty - `"/dev/"`
19 pub ut_line: [u8; UT_LINESIZE],
20 /// Username
21 pub ut_user: [u8; UT_NAMESIZE],
22 /// Hostname for remote login, or kernel version for run-level message
23 pub ut_host: [u8; UT_HOSTSIZE],
24 /// Time entry was made
25 pub ut_tv: timeval,
26 }
27
28 impl fmt::Debug for utmp {
29 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
30 fmt.debug_struct("utmp")
31 .field("ut_line", &cstr_from_bytes(&self.ut_line))
32 .field("ut_user", &cstr_from_bytes(&self.ut_user))
33 .field("ut_host", &cstr_from_bytes(&self.ut_host))
34 .field("ut_tv", &self.ut_tv)
35 .finish()
36 }
37 }
38
39 #[test]
40 fn test_size_of_utmp_x32() {
41 assert_eq!(std::mem::size_of::<utmp>(), 304);
42 }