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"
|
"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", ...}.
|
// []{"CAP_SYS_ADMIN", ...}.
|
||||||
//
|
//
|
||||||
// Unknown cap numbers are returned as []int.
|
// Unknown cap numbers are returned as []int.
|
||||||
func FromUint64(v uint64) ([]string, []int) {
|
func FromBitmap(v uint64) ([]string, []int) {
|
||||||
var (
|
var (
|
||||||
res []string
|
res []string
|
||||||
unknown []int
|
unknown []int
|
||||||
@ -57,7 +57,7 @@ func FromUint64(v uint64) ([]string, []int) {
|
|||||||
return res, unknown
|
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) {
|
func ParseProcPIDStatus(r io.Reader) (map[capability.CapType]uint64, error) {
|
||||||
res := make(map[capability.CapType]uint64)
|
res := make(map[capability.CapType]uint64)
|
||||||
scanner := bufio.NewScanner(r)
|
scanner := bufio.NewScanner(r)
|
||||||
@ -113,7 +113,7 @@ func Current() ([]string, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
capEff := caps[capability.EFFECTIVE]
|
capEff := caps[capability.EFFECTIVE]
|
||||||
names, _ := FromUint64(capEff)
|
names, _ := FromBitmap(capEff)
|
||||||
return names, nil
|
return names, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ func TestCapsList(t *testing.T) {
|
|||||||
assert.Len(t, caps59, 41)
|
assert.Len(t, caps59, 41)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFromUint64(t *testing.T) {
|
func TestFromBitmap(t *testing.T) {
|
||||||
type testCase struct {
|
type testCase struct {
|
||||||
comment string
|
comment string
|
||||||
v uint64
|
v uint64
|
||||||
@ -72,7 +72,7 @@ func TestFromUint64(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
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",
|
t.Logf("[%s] v=0x%x, got=%+v (%d entries), unknown=%v",
|
||||||
tc.comment, tc.v, knownNames, len(knownNames), unknown)
|
tc.comment, tc.v, knownNames, len(knownNames), unknown)
|
||||||
assert.Equal(t, tc.knownNames, knownNames)
|
assert.Equal(t, tc.knownNames, knownNames)
|
||||||
|
Loading…
Reference in New Issue
Block a user