[][src]Struct linux_taskstats::taskstats

#[repr(C)]pub struct taskstats {
    pub version: c_ushort,
    pub ac_exitcode: c_uint,
    pub ac_flag: c_uchar,
    pub ac_nice: c_uchar,
    pub cpu_count: c_ulonglong,
    pub cpu_delay_total: c_ulonglong,
    pub blkio_count: c_ulonglong,
    pub blkio_delay_total: c_ulonglong,
    pub swapin_count: c_ulonglong,
    pub swapin_delay_total: c_ulonglong,
    pub cpu_run_real_total: c_ulonglong,
    pub cpu_run_virtual_total: c_ulonglong,
    pub ac_comm: [c_char; 32],
    pub ac_sched: c_uchar,
    pub ac_pad: [c_uchar; 3],
    pub __unused_padding: u32,
    pub ac_uid: c_uint,
    pub ac_gid: c_uint,
    pub ac_pid: c_uint,
    pub ac_ppid: c_uint,
    pub ac_btime: c_uint,
    pub ac_etime: c_ulonglong,
    pub ac_utime: c_ulonglong,
    pub ac_stime: c_ulonglong,
    pub ac_minflt: c_ulonglong,
    pub ac_majflt: c_ulonglong,
    pub coremem: c_ulonglong,
    pub virtmem: c_ulonglong,
    pub hiwater_rss: c_ulonglong,
    pub hiwater_vm: c_ulonglong,
    pub read_char: c_ulonglong,
    pub write_char: c_ulonglong,
    pub read_syscalls: c_ulonglong,
    pub write_syscalls: c_ulonglong,
    pub read_bytes: c_ulonglong,
    pub write_bytes: c_ulonglong,
    pub cancelled_write_bytes: c_ulonglong,
    pub nvcsw: c_ulonglong,
    pub nivcsw: c_ulonglong,
    pub ac_utimescaled: c_ulonglong,
    pub ac_stimescaled: c_ulonglong,
    pub cpu_scaled_run_real_total: c_ulonglong,
    pub freepages_count: c_ulonglong,
    pub freepages_delay_total: c_ulonglong,
}

This is custom copy of the generated struct taskstats from linux version 3.10.0 and in this crate this type is used to read binary data transferred from linux kernel. The reason of doing this despite the bindgen generates rust bindings including struct taskstats is due to potential corruption of on-memory struct layout likely caused by old clang version. ref: https://github.com/rust-lang/rust-bindgen/issues/867 Specifically, when bindgen generates struct taskstats with older clang version, the resulting struct defined in generated rust source code contains size padding as the last member of the struct causing offset of members after ac_uid to shift 4-byte or more and the result data becomes unreliable. The bindgen generated definition works well in environment that uses newer clang versions, but I decided to use copied definition of this struct for the time being by following considerations:

  • The struct definition rarely evolves.
  • Returning corrupted data silently is critical and much worse than not providing from the beginning.
  • If user of this crate still needs to access the exactly original definition generated by bindgen, it might still be possible by casting type to __bindgen_taskstats exported by this crate.

Fields

version: c_ushortac_exitcode: c_uintac_flag: c_ucharac_nice: c_ucharcpu_count: c_ulonglongcpu_delay_total: c_ulonglongblkio_count: c_ulonglongblkio_delay_total: c_ulonglongswapin_count: c_ulonglongswapin_delay_total: c_ulonglongcpu_run_real_total: c_ulonglongcpu_run_virtual_total: c_ulonglongac_comm: [c_char; 32]ac_sched: c_ucharac_pad: [c_uchar; 3]__unused_padding: u32ac_uid: c_uintac_gid: c_uintac_pid: c_uintac_ppid: c_uintac_btime: c_uintac_etime: c_ulonglongac_utime: c_ulonglongac_stime: c_ulonglongac_minflt: c_ulonglongac_majflt: c_ulonglongcoremem: c_ulonglongvirtmem: c_ulonglonghiwater_rss: c_ulonglonghiwater_vm: c_ulonglongread_char: c_ulonglongwrite_char: c_ulonglongread_syscalls: c_ulonglongwrite_syscalls: c_ulonglongread_bytes: c_ulonglongwrite_bytes: c_ulonglongcancelled_write_bytes: c_ulonglongnvcsw: c_ulonglongnivcsw: c_ulonglongac_utimescaled: c_ulonglongac_stimescaled: c_ulonglongcpu_scaled_run_real_total: c_ulonglongfreepages_count: c_ulonglongfreepages_delay_total: c_ulonglong

Trait Implementations

impl Clone for taskstats[src]

impl Copy for taskstats[src]

impl Debug for taskstats[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.