cap: rename FromUint64 to FromBitmap
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
parent
af4c55fa4a
commit
9822173354
@ -28,11 +28,11 @@ import (
|
||||
"github.com/syndtr/gocapability/capability"
|
||||
)
|
||||
|
||||
// FromUint64 parses an integer into string slice like
|
||||
// FromBitmap parses an uint64 bitmap into string slice like
|
||||
// []{"CAP_SYS_ADMIN", ...}.
|
||||
//
|
||||
// Unknown cap numbers are returned as []int.
|
||||
func FromUint64(v uint64) ([]string, []int) {
|
||||
func FromBitmap(v uint64) ([]string, []int) {
|
||||
var (
|
||||
res []string
|
||||
unknown []int
|
||||
@ -57,7 +57,7 @@ func FromUint64(v uint64) ([]string, []int) {
|
||||
return res, unknown
|
||||
}
|
||||
|
||||
// ParseProcPIDStatus returns uint64 value from /proc/<PID>/status file
|
||||
// ParseProcPIDStatus returns uint64 bitmap value from /proc/<PID>/status file
|
||||
func ParseProcPIDStatus(r io.Reader) (map[capability.CapType]uint64, error) {
|
||||
res := make(map[capability.CapType]uint64)
|
||||
scanner := bufio.NewScanner(r)
|
||||
@ -113,7 +113,7 @@ func Current() ([]string, error) {
|
||||
return nil, err
|
||||
}
|
||||
capEff := caps[capability.EFFECTIVE]
|
||||
names, _ := FromUint64(capEff)
|
||||
names, _ := FromBitmap(capEff)
|
||||
return names, nil
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ func TestCapsList(t *testing.T) {
|
||||
assert.Len(t, caps59, 41)
|
||||
}
|
||||
|
||||
func TestFromUint64(t *testing.T) {
|
||||
func TestFromBitmap(t *testing.T) {
|
||||
type testCase struct {
|
||||
comment string
|
||||
v uint64
|
||||
@ -72,7 +72,7 @@ func TestFromUint64(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
knownNames, unknown := FromUint64(tc.v)
|
||||
knownNames, unknown := FromBitmap(tc.v)
|
||||
t.Logf("[%s] v=0x%x, got=%+v (%d entries), unknown=%v",
|
||||
tc.comment, tc.v, knownNames, len(knownNames), unknown)
|
||||
assert.Equal(t, tc.knownNames, knownNames)
|
||||
|
Loading…
Reference in New Issue
Block a user