-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from Red54/bsd-no-reflect
mountinfo: BSDs no longer need cgo nor reflect
- Loading branch information
Showing
5 changed files
with
54 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//go:build freebsd || darwin | ||
// +build freebsd darwin | ||
|
||
package mountinfo | ||
|
||
import "golang.org/x/sys/unix" | ||
|
||
func getMountinfo(entry *unix.Statfs_t) *Info { | ||
var mountinfo Info | ||
mountinfo.Mountpoint = unix.ByteSliceToString(entry.Mntonname[:]) | ||
mountinfo.FSType = unix.ByteSliceToString(entry.Fstypename[:]) | ||
mountinfo.Source = unix.ByteSliceToString(entry.Mntfromname[:]) | ||
return &mountinfo | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package mountinfo | ||
|
||
import "golang.org/x/sys/unix" | ||
|
||
func int8SliceToString(is []int8) string { | ||
var bs []byte | ||
for _, i := range is { | ||
if i == 0 { | ||
break | ||
} | ||
bs = append(bs, byte(i)) | ||
} | ||
return string(bs) | ||
} | ||
|
||
func getMountinfo(entry *unix.Statfs_t) *Info { | ||
var mountinfo Info | ||
mountinfo.Mountpoint = int8SliceToString(entry.F_mntonname[:]) | ||
mountinfo.FSType = int8SliceToString(entry.F_fstypename[:]) | ||
mountinfo.Source = int8SliceToString(entry.F_mntfromname[:]) | ||
return &mountinfo | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters