types

package
v0.0.0-...-63b2ac5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2019 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	C_UT_LINESIZE = 32
	C_UT_NAMESIZE = 32
	C_UT_HOSTSIZE = 256
	C_utmp_size   = 384
)

Variables

This section is empty.

Functions

This section is empty.

Types

type C_char

type C_char byte

type C_exit_status

type C_exit_status struct {
	C_e_termination int16 // C_short /* Process termination status */
	C_e_exit        int16 // C_short /* Process exit status */
}

type C_int32_t

type C_int32_t int32

type C_pid_t

type C_pid_t int32

type C_short

type C_short int16

type C_timeval

type C_timeval struct {
	/* Seconds */
	C_tv_sec uint32 // C_int32_t

	/* Microseconds */
	C_tv_usec uint32 // C_int32_t
}

type C_utmp

type C_utmp struct {
	/* Type of record */
	// C_ut_type C_short
	// TODO 文档描述中是short,实际上 好像是int32
	C_ut_type uint32 // C_int32_t

	/* PID of login process */
	C_ut_pid uint32

	/* Device name of tty - "/dev/" */
	C_ut_line [C_UT_LINESIZE]byte

	/* Terminal name suffix, or inittab(5) ID */
	C_ut_id [4]byte

	/* Username */
	C_ut_user [C_UT_NAMESIZE]byte

	/* Hostname for remote login, or kernel version for run-level messages */
	C_ut_host [C_UT_HOSTSIZE]byte

	/* Exit status of a process marked as DEAD_PROCESS; not used by Linux init (1 */
	C_ut_exit C_exit_status

	/* Session ID (getsid(2)),used for windowing */
	C_ut_session uint32

	/* Time entry was made */
	C_ut_tv C_timeval

	/* Internet address of remote host; IPv4 address uses just ut_addr_v6[0] */
	C_ut_addr_v6 [4]uint32

	/* Reserved for future use */
	C__unused [20]byte
}

func (C_utmp) MarshalBinary

func (cu C_utmp) MarshalBinary() (data []byte, err error)

func (C_utmp) String

func (cu C_utmp) String() string

func (*C_utmp) UnmarshalBinary

func (cu *C_utmp) UnmarshalBinary(data []byte) error

type C_utmpList

type C_utmpList []C_utmp

func (*C_utmpList) UnmarshalBinary

func (cus *C_utmpList) UnmarshalBinary(data []byte) error

type Exit_status

type Exit_status struct {
	TerminationCode int16 /* Process termination status */
	ExitCode        int16 /* Process exit status */
}

type RecordTypeConst

type RecordTypeConst int32
const (
	/* Record does not contain valid info (formerly known as UT_UNKNOWN on Linux) */
	EMPTY RecordTypeConst = iota
	/* Change in system run-level (see init(8)) */
	RUN_LVL
	/* Time of system boot (in ut_tv) */
	BOOT_TIME

	/* Time after system clock change (in ut_tv) */
	NEW_TIME

	/* Time before system clock change (in ut_tv) */
	OLD_TIME
	/* Process spawned by init(8) */
	INIT_PROCESS
	/* Session leader process for user login */
	LOGIN_PROCESS
	/* Normal process */
	USER_PROCESS
	/* Terminated process */
	DEAD_PROCESS
	/* Not implemented */
	ACCOUNTING
)

type Utmp

type Utmp struct {
	// 记录类型
	RecordType RecordTypeConst
	// 进程id
	Pid int32
	// 32个字节类型, 设备名称
	DeviceName string
	// 4个字节
	TerminalId string
	// 32个字节
	UserName string
	// 256个字节
	HostName string
	// 进程退出状态
	ExitStatus Exit_status

	SessionId int32

	Timeval time.Time

	RemoteIP net.IP
	// contains filtered or unexported fields
}

解析原始数据类型,并转为 可读易识别的对象

func (Utmp) Parse

func (ut Utmp) Parse(C_utmp)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL