[host]freebsd: update freebsd_amd64

This commit is contained in:
WAKAYAMA shirou 2016-04-23 23:10:23 +09:00
parent d8317f10e9
commit d9e994bec8
3 changed files with 9 additions and 7 deletions

View File

@ -101,13 +101,11 @@ func Users() ([]UserStat, error) {
return ret, err
}
u := Utmpx{}
entrySize := int(unsafe.Sizeof(u)) - 3
entrySize = 197 // TODO: why should 197
entrySize := sizeOfUtmpx
count := len(buf) / entrySize
for i := 0; i < count; i++ {
b := buf[i*entrySize : i*entrySize+entrySize]
b := buf[i*sizeOfUtmpx : (i+1)*sizeOfUtmpx]
var u Utmpx
br := bytes.NewReader(b)
err := binary.Read(br, binary.LittleEndian, &u)

View File

@ -9,6 +9,7 @@ const (
sizeofInt = 0x4
sizeofLong = 0x8
sizeofLongLong = 0x8
sizeOfUtmpx = 197 // TODO: why should 197, not 0x118
)
type (
@ -24,17 +25,19 @@ type Utmp struct {
Host [16]int8
Time int32
}
type Utmpx struct {
Type int16
Tv Timeval
ID [8]int8
Id [8]int8
Pid int32
User [32]int8
Line [16]int8
Host [125]int8
// Host [128]int8
// X__ut_spare [64]int8
// Host [128]int8
// X__ut_spare [64]int8
}
type Timeval struct {
Sec [4]byte
Usec [3]byte

View File

@ -27,6 +27,7 @@ const (
sizeofInt = C.sizeof_int
sizeofLong = C.sizeof_long
sizeofLongLong = C.sizeof_longlong
sizeOfUtmpx = C.sizeof_struct_utmpx
)
// Basic types