aboutsummaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-09-05 10:38:22 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-09-05 10:38:22 +0200
commit5db39ab95395b60c5629a84812086f720adc9ccf (patch)
tree75fac9b668196f734366d219ca35613576596bd6 /sys
parentc34180fca06cc29d2a29f3c1eec3131c6a0caf16 (diff)
sys: rename Call to Syscall
In preparation for moving sys types to prog to avoid confusion between sys.Call and prog.Call.
Diffstat (limited to 'sys')
-rw-r--r--sys/decl.go40
-rw-r--r--sys/decl_test.go26
-rw-r--r--sys/sys_386.go2
-rw-r--r--sys/sys_amd64.go2
-rw-r--r--sys/sys_arm.go2
-rw-r--r--sys/sys_arm64.go2
-rw-r--r--sys/sys_ppc64le.go2
-rw-r--r--sys/syz-sysgen/syscallnr.go2
-rw-r--r--sys/syz-sysgen/sysgen.go2
9 files changed, 40 insertions, 40 deletions
diff --git a/sys/decl.go b/sys/decl.go
index 1ea98a13a..82d27e915 100644
--- a/sys/decl.go
+++ b/sys/decl.go
@@ -7,7 +7,7 @@ import (
"fmt"
)
-type Call struct {
+type Syscall struct {
ID int
NR uint64 // kernel syscall number
Name string
@@ -268,9 +268,9 @@ func (t *UnionType) FieldName() string {
}
var (
- CallMap = make(map[string]*Call)
- Resources map[string]*ResourceDesc
- ctors = make(map[string][]*Call)
+ SyscallMap = make(map[string]*Syscall)
+ Resources map[string]*ResourceDesc
+ ctors = make(map[string][]*Syscall)
)
type StructDesc struct {
@@ -299,7 +299,7 @@ func initStructFields() {
keyedStructs[desc.Key] = desc.Desc
}
- for _, c := range Calls {
+ for _, c := range Syscalls {
ForeachType(c, func(t Type) {
switch s := t.(type) {
case *StructType:
@@ -318,7 +318,7 @@ func initStructFields() {
}
// ResourceConstructors returns a list of calls that can create a resource of the given kind.
-func ResourceConstructors(name string) []*Call {
+func ResourceConstructors(name string) []*Syscall {
return ctors[name]
}
@@ -327,7 +327,7 @@ func initResources() {
for _, res := range resourceArray {
Resources[res.Name] = res
}
- for _, c := range Calls {
+ for _, c := range Syscalls {
ForeachType(c, func(t Type) {
if r, ok := t.(*ResourceType); ok {
r.Desc = Resources[r.TypeName]
@@ -339,10 +339,10 @@ func initResources() {
}
}
-func resourceCtors(kind []string, precise bool) []*Call {
+func resourceCtors(kind []string, precise bool) []*Syscall {
// Find calls that produce the necessary resources.
- var metas []*Call
- for _, meta := range Calls {
+ var metas []*Syscall
+ for _, meta := range Syscalls {
// Recurse into arguments to see if there is an out/inout arg of necessary type.
ok := false
ForeachType(meta, func(typ Type) {
@@ -399,7 +399,7 @@ func isCompatibleResource(dst, src []string, precise bool) bool {
return true
}
-func (c *Call) InputResources() []*ResourceType {
+func (c *Syscall) InputResources() []*ResourceType {
var resources []*ResourceType
ForeachType(c, func(typ Type) {
switch typ1 := typ.(type) {
@@ -412,13 +412,13 @@ func (c *Call) InputResources() []*ResourceType {
return resources
}
-func TransitivelyEnabledCalls(enabled map[*Call]bool) map[*Call]bool {
- supported := make(map[*Call]bool)
+func TransitivelyEnabledCalls(enabled map[*Syscall]bool) map[*Syscall]bool {
+ supported := make(map[*Syscall]bool)
for c := range enabled {
supported[c] = true
}
- inputResources := make(map[*Call][]*ResourceType)
- ctors := make(map[string][]*Call)
+ inputResources := make(map[*Syscall][]*ResourceType)
+ ctors := make(map[string][]*Syscall)
for c := range supported {
inputs := c.InputResources()
inputResources[c] = inputs
@@ -431,7 +431,7 @@ func TransitivelyEnabledCalls(enabled map[*Call]bool) map[*Call]bool {
}
for {
n := len(supported)
- haveGettime := supported[CallMap["clock_gettime"]]
+ haveGettime := supported[SyscallMap["clock_gettime"]]
for c := range supported {
canCreate := true
for _, res := range inputResources[c] {
@@ -467,7 +467,7 @@ func TransitivelyEnabledCalls(enabled map[*Call]bool) map[*Call]bool {
return supported
}
-func ForeachType(meta *Call, f func(Type)) {
+func ForeachType(meta *Syscall, f func(Type)) {
seen := make(map[*StructDesc]bool)
var rec func(t Type)
rec = func(t Type) {
@@ -512,11 +512,11 @@ func init() {
initResources()
structDescs = nil
- for _, c := range Calls {
- if CallMap[c.Name] != nil {
+ for _, c := range Syscalls {
+ if SyscallMap[c.Name] != nil {
println(c.Name)
panic("duplicate syscall")
}
- CallMap[c.Name] = c
+ SyscallMap[c.Name] = c
}
}
diff --git a/sys/decl_test.go b/sys/decl_test.go
index aa81f33e6..a156f4f61 100644
--- a/sys/decl_test.go
+++ b/sys/decl_test.go
@@ -8,7 +8,7 @@ import (
)
func TestResourceCtors(t *testing.T) {
- for _, c := range Calls {
+ for _, c := range Syscalls {
for _, res := range c.InputResources() {
if len(resourceCtors(res.Desc.Kind, true)) == 0 {
t.Errorf("call %v requires input resource %v, but there are no calls that can create this resource", c.Name, res.Desc.Name)
@@ -19,8 +19,8 @@ func TestResourceCtors(t *testing.T) {
func TestTransitivelyEnabledCalls(t *testing.T) {
t.Parallel()
- calls := make(map[*Call]bool)
- for _, c := range Calls {
+ calls := make(map[*Syscall]bool)
+ for _, c := range Syscalls {
calls[c] = true
}
if trans := TransitivelyEnabledCalls(calls); len(calls) != len(trans) {
@@ -31,30 +31,30 @@ func TestTransitivelyEnabledCalls(t *testing.T) {
}
t.Fatalf("can't create some resource")
}
- delete(calls, CallMap["epoll_create"])
+ delete(calls, SyscallMap["epoll_create"])
if trans := TransitivelyEnabledCalls(calls); len(calls) != len(trans) {
t.Fatalf("still must be able to create epoll fd with epoll_create1")
}
- delete(calls, CallMap["epoll_create1"])
+ delete(calls, SyscallMap["epoll_create1"])
trans := TransitivelyEnabledCalls(calls)
if len(calls)-5 != len(trans) ||
- trans[CallMap["epoll_ctl$EPOLL_CTL_ADD"]] ||
- trans[CallMap["epoll_ctl$EPOLL_CTL_MOD"]] ||
- trans[CallMap["epoll_ctl$EPOLL_CTL_DEL"]] ||
- trans[CallMap["epoll_wait"]] ||
- trans[CallMap["epoll_pwait"]] {
+ trans[SyscallMap["epoll_ctl$EPOLL_CTL_ADD"]] ||
+ trans[SyscallMap["epoll_ctl$EPOLL_CTL_MOD"]] ||
+ trans[SyscallMap["epoll_ctl$EPOLL_CTL_DEL"]] ||
+ trans[SyscallMap["epoll_wait"]] ||
+ trans[SyscallMap["epoll_pwait"]] {
t.Fatalf("epoll fd is not disabled")
}
}
func TestClockGettime(t *testing.T) {
t.Parallel()
- calls := make(map[*Call]bool)
- for _, c := range Calls {
+ calls := make(map[*Syscall]bool)
+ for _, c := range Syscalls {
calls[c] = true
}
// Removal of clock_gettime should disable all calls that accept timespec/timeval.
- delete(calls, CallMap["clock_gettime"])
+ delete(calls, SyscallMap["clock_gettime"])
trans := TransitivelyEnabledCalls(calls)
if len(trans)+10 > len(calls) {
t.Fatalf("clock_gettime did not disable enough calls: before %v, after %v", len(calls), len(trans))
diff --git a/sys/sys_386.go b/sys/sys_386.go
index e0909aebf..f0eebd212 100644
--- a/sys/sys_386.go
+++ b/sys/sys_386.go
@@ -5892,7 +5892,7 @@ var structDescs = []*KeyedStruct{
}}},
}
-var Calls = []*Call{
+var Syscalls = []*Syscall{
{NR: 18446744073709551615, Name: "accept", CallName: "accept", Args: []Type{
&ResourceType{TypeCommon: TypeCommon{TypeName: "sock", FldName: "fd", TypeSize: 4}},
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "peer", TypeSize: 4, IsOptional: true}, Type: &UnionType{Key: StructKey{Name: "sockaddr_storage", Dir: 1}}},
diff --git a/sys/sys_amd64.go b/sys/sys_amd64.go
index e38558dde..0b85dda44 100644
--- a/sys/sys_amd64.go
+++ b/sys/sys_amd64.go
@@ -5941,7 +5941,7 @@ var structDescs = []*KeyedStruct{
}}},
}
-var Calls = []*Call{
+var Syscalls = []*Syscall{
{NR: 43, Name: "accept", CallName: "accept", Args: []Type{
&ResourceType{TypeCommon: TypeCommon{TypeName: "sock", FldName: "fd", TypeSize: 4}},
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "peer", TypeSize: 8, IsOptional: true}, Type: &UnionType{Key: StructKey{Name: "sockaddr_storage", Dir: 1}}},
diff --git a/sys/sys_arm.go b/sys/sys_arm.go
index 05d7852f7..adcd5dbef 100644
--- a/sys/sys_arm.go
+++ b/sys/sys_arm.go
@@ -5892,7 +5892,7 @@ var structDescs = []*KeyedStruct{
}}},
}
-var Calls = []*Call{
+var Syscalls = []*Syscall{
{NR: 9437469, Name: "accept", CallName: "accept", Args: []Type{
&ResourceType{TypeCommon: TypeCommon{TypeName: "sock", FldName: "fd", TypeSize: 4}},
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "peer", TypeSize: 4, IsOptional: true}, Type: &UnionType{Key: StructKey{Name: "sockaddr_storage", Dir: 1}}},
diff --git a/sys/sys_arm64.go b/sys/sys_arm64.go
index c8500c537..435eb92b6 100644
--- a/sys/sys_arm64.go
+++ b/sys/sys_arm64.go
@@ -5941,7 +5941,7 @@ var structDescs = []*KeyedStruct{
}}},
}
-var Calls = []*Call{
+var Syscalls = []*Syscall{
{NR: 202, Name: "accept", CallName: "accept", Args: []Type{
&ResourceType{TypeCommon: TypeCommon{TypeName: "sock", FldName: "fd", TypeSize: 4}},
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "peer", TypeSize: 8, IsOptional: true}, Type: &UnionType{Key: StructKey{Name: "sockaddr_storage", Dir: 1}}},
diff --git a/sys/sys_ppc64le.go b/sys/sys_ppc64le.go
index 245dfb101..52a8bca35 100644
--- a/sys/sys_ppc64le.go
+++ b/sys/sys_ppc64le.go
@@ -5941,7 +5941,7 @@ var structDescs = []*KeyedStruct{
}}},
}
-var Calls = []*Call{
+var Syscalls = []*Syscall{
{NR: 330, Name: "accept", CallName: "accept", Args: []Type{
&ResourceType{TypeCommon: TypeCommon{TypeName: "sock", FldName: "fd", TypeSize: 4}},
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "peer", TypeSize: 8, IsOptional: true}, Type: &UnionType{Key: StructKey{Name: "sockaddr_storage", Dir: 1}}},
diff --git a/sys/syz-sysgen/syscallnr.go b/sys/syz-sysgen/syscallnr.go
index 793877b83..02c676cf0 100644
--- a/sys/syz-sysgen/syscallnr.go
+++ b/sys/syz-sysgen/syscallnr.go
@@ -26,7 +26,7 @@ var archs = []*Arch{
{"ppc64le", 8, []string{"__ppc64__", "__PPC64__", "__powerpc64__"}},
}
-func generateExecutorSyscalls(arch *Arch, syscalls []*sys.Call) []byte {
+func generateExecutorSyscalls(arch *Arch, syscalls []*sys.Syscall) []byte {
data := ArchData{
CARCH: arch.CARCH,
}
diff --git a/sys/syz-sysgen/sysgen.go b/sys/syz-sysgen/sysgen.go
index 2730655ce..7381f1edb 100644
--- a/sys/syz-sysgen/sysgen.go
+++ b/sys/syz-sysgen/sysgen.go
@@ -133,7 +133,7 @@ func generate(arch string, prog *compiler.Prog, consts map[string]uint64, out io
serializer.Write(out, prog.StructDescs)
fmt.Fprintf(out, "\n\n")
- fmt.Fprintf(out, "var Calls = ")
+ fmt.Fprintf(out, "var Syscalls = ")
serializer.Write(out, prog.Syscalls)
fmt.Fprintf(out, "\n\n")