From 9822173354d755a0ab7a319228643435018c44d9 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Thu, 25 Feb 2021 15:02:10 +0900 Subject: [PATCH] cap: rename FromUint64 to FromBitmap Signed-off-by: Akihiro Suda --- pkg/cap/cap_linux.go | 8 ++++---- pkg/cap/cap_linux_test.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/cap/cap_linux.go b/pkg/cap/cap_linux.go index e14acad76..08124730f 100644 --- a/pkg/cap/cap_linux.go +++ b/pkg/cap/cap_linux.go @@ -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//status file +// ParseProcPIDStatus returns uint64 bitmap value from /proc//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 } diff --git a/pkg/cap/cap_linux_test.go b/pkg/cap/cap_linux_test.go index 2c474339b..0cf62f610 100644 --- a/pkg/cap/cap_linux_test.go +++ b/pkg/cap/cap_linux_test.go @@ -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)