diff --git a/disk/disk_freebsd.go b/disk/disk_freebsd.go index 4ee8e66..5180b88 100644 --- a/disk/disk_freebsd.go +++ b/disk/disk_freebsd.go @@ -8,7 +8,6 @@ import ( "encoding/binary" "path" "strconv" - "unsafe" "golang.org/x/sys/unix" @@ -28,8 +27,8 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro return ret, err } - fs := make([]Statfs, count) - if _, err = Getfsstat(fs, unix.MNT_WAIT); err != nil { + fs := make([]unix.Statfs_t, count) + if _, err = unix.Getfsstat(fs, unix.MNT_WAIT); err != nil { return ret, err } @@ -158,27 +157,6 @@ func (b Bintime) Compute() float64 { // BT2LD(time) ((long double)(time).sec + (time).frac * BINTIME_SCALE) -// Getfsstat is borrowed from pkg/syscall/syscall_freebsd.go -// change Statfs_t to Statfs in order to get more information -func Getfsstat(buf []Statfs, flags int) (n int, err error) { - return GetfsstatWithContext(context.Background(), buf, flags) -} - -func GetfsstatWithContext(ctx context.Context, buf []Statfs, flags int) (n int, err error) { - var _p0 unsafe.Pointer - var bufsize uintptr - if len(buf) > 0 { - _p0 = unsafe.Pointer(&buf[0]) - bufsize = unsafe.Sizeof(Statfs{}) * uintptr(len(buf)) - } - r0, _, e1 := unix.Syscall(unix.SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags)) - n = int(r0) - if e1 != 0 { - err = e1 - } - return -} - func parseDevstat(buf []byte) (Devstat, error) { var ds Devstat br := bytes.NewReader(buf) diff --git a/disk/disk_freebsd_386.go b/disk/disk_freebsd_386.go index 5f39aa5..e2793a4 100644 --- a/disk/disk_freebsd_386.go +++ b/disk/disk_freebsd_386.go @@ -29,34 +29,6 @@ type ( _C_long_double int64 ) -type Statfs struct { - Version uint32 - Type uint32 - Flags uint64 - Bsize uint64 - Iosize uint64 - Blocks uint64 - Bfree uint64 - Bavail int64 - Files uint64 - Ffree int64 - Syncwrites uint64 - Asyncwrites uint64 - Syncreads uint64 - Asyncreads uint64 - Spare [10]uint64 - Namemax uint32 - Owner uint32 - Fsid Fsid - Charspare [80]int8 - Fstypename [16]int8 - Mntfromname [88]int8 - Mntonname [88]int8 -} -type Fsid struct { - Val [2]int32 -} - type Devstat struct { Sequence0 uint32 Allocated int32 diff --git a/disk/disk_freebsd_amd64.go b/disk/disk_freebsd_amd64.go index 752a35f..e9613dc 100644 --- a/disk/disk_freebsd_amd64.go +++ b/disk/disk_freebsd_amd64.go @@ -29,34 +29,6 @@ type ( _C_long_double int64 ) -type Statfs struct { - Version uint32 - Type uint32 - Flags uint64 - Bsize uint64 - Iosize uint64 - Blocks uint64 - Bfree uint64 - Bavail int64 - Files uint64 - Ffree int64 - Syncwrites uint64 - Asyncwrites uint64 - Syncreads uint64 - Asyncreads uint64 - Spare [10]uint64 - Namemax uint32 - Owner uint32 - Fsid Fsid - Charspare [80]int8 - Fstypename [16]int8 - Mntfromname [88]int8 - Mntonname [88]int8 -} -type Fsid struct { - Val [2]int32 -} - type Devstat struct { Sequence0 uint32 Allocated int32 diff --git a/disk/disk_freebsd_arm.go b/disk/disk_freebsd_arm.go index 5f39aa5..e2793a4 100644 --- a/disk/disk_freebsd_arm.go +++ b/disk/disk_freebsd_arm.go @@ -29,34 +29,6 @@ type ( _C_long_double int64 ) -type Statfs struct { - Version uint32 - Type uint32 - Flags uint64 - Bsize uint64 - Iosize uint64 - Blocks uint64 - Bfree uint64 - Bavail int64 - Files uint64 - Ffree int64 - Syncwrites uint64 - Asyncwrites uint64 - Syncreads uint64 - Asyncreads uint64 - Spare [10]uint64 - Namemax uint32 - Owner uint32 - Fsid Fsid - Charspare [80]int8 - Fstypename [16]int8 - Mntfromname [88]int8 - Mntonname [88]int8 -} -type Fsid struct { - Val [2]int32 -} - type Devstat struct { Sequence0 uint32 Allocated int32 diff --git a/disk/disk_freebsd_arm64.go b/disk/disk_freebsd_arm64.go index d03f1f6..1384131 100644 --- a/disk/disk_freebsd_arm64.go +++ b/disk/disk_freebsd_arm64.go @@ -31,34 +31,6 @@ type ( _C_long_double int64 ) -type Statfs struct { - Version uint32 - Type uint32 - Flags uint64 - Bsize uint64 - Iosize uint64 - Blocks uint64 - Bfree uint64 - Bavail int64 - Files uint64 - Ffree int64 - Syncwrites uint64 - Asyncwrites uint64 - Syncreads uint64 - Asyncreads uint64 - Spare [10]uint64 - Namemax uint32 - Owner uint32 - Fsid Fsid - Charspare [80]uint8 - Fstypename [16]int8 - Mntfromname [1024]int8 - Mntonname [1024]int8 -} -type Fsid struct { - Val [2]int32 -} - type Devstat struct { Sequence0 uint32 Allocated int32 diff --git a/disk/types_freebsd.go b/disk/types_freebsd.go index 525e9af..4cf6017 100644 --- a/disk/types_freebsd.go +++ b/disk/types_freebsd.go @@ -58,8 +58,5 @@ type ( _C_long_double C.longlong ) -type Statfs C.struct_statfs -type Fsid C.struct_fsid - type Devstat C.struct_devstat type Bintime C.struct_bintime