aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource/options.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-10-26 10:51:06 +0100
committerDmitry Vyukov <dvyukov@google.com>2020-10-26 15:44:28 +0100
commite6e35dba937599d098fc034eff2686e5ddc409e9 (patch)
tree802be708d0bc84dee01b9285639690a53f1f6f94 /pkg/csource/options.go
parentd46bc75207fea1d7671c1277dd660cf1a4d7847b (diff)
sys/targets: add OS/Arch name consts
We use strings to identify OS/Arch. These strings are duplicated throughout the code base massively. golangci-lint points to possiblity of typos and duplication. We already had to define these names in pkg/csource and disable checking for prog package. A future change triggers such warnings in another package. Add OS/Arch name consts to sys/targets so that they can be used to refer to OS/Arch. Use the consts everywhere.
Diffstat (limited to 'pkg/csource/options.go')
-rw-r--r--pkg/csource/options.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/pkg/csource/options.go b/pkg/csource/options.go
index ba74eb37c..7f2bc5109 100644
--- a/pkg/csource/options.go
+++ b/pkg/csource/options.go
@@ -12,6 +12,7 @@ import (
"strings"
"github.com/google/syzkaller/pkg/mgrconfig"
+ "github.com/google/syzkaller/sys/targets"
)
// Options control various aspects of source generation.
@@ -113,10 +114,10 @@ func (opts Options) Check(OS string) error {
}
func (opts Options) checkLinuxOnly(OS string) error {
- if OS == linux {
+ if OS == targets.Linux {
return nil
}
- if opts.NetInjection && !(OS == openbsd || OS == freebsd || OS == netbsd) {
+ if opts.NetInjection && !(OS == targets.OpenBSD || OS == targets.FreeBSD || OS == targets.NetBSD) {
return fmt.Errorf("option NetInjection is not supported on %v", OS)
}
if opts.NetDevices {
@@ -150,7 +151,7 @@ func (opts Options) checkLinuxOnly(OS string) error {
return fmt.Errorf("option Wifi is not supported on %v", OS)
}
if opts.Sandbox == sandboxNamespace ||
- (opts.Sandbox == sandboxSetuid && !(OS == openbsd || OS == freebsd || OS == netbsd)) ||
+ (opts.Sandbox == sandboxSetuid && !(OS == targets.OpenBSD || OS == targets.FreeBSD || OS == targets.NetBSD)) ||
opts.Sandbox == sandboxAndroid {
return fmt.Errorf("option Sandbox=%v is not supported on %v", opts.Sandbox, OS)
}
@@ -183,7 +184,7 @@ func DefaultOpts(cfg *mgrconfig.Config) Options {
HandleSegv: true,
Repro: true,
}
- if cfg.TargetOS != linux {
+ if cfg.TargetOS != targets.Linux {
opts.NetInjection = false
opts.NetDevices = false
opts.NetReset = false