[host]freebsd: update freebsd_amd64

pull/191/head
WAKAYAMA shirou 9 years ago
parent d8317f10e9
commit d9e994bec8

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

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

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

Loading…
Cancel
Save