From 5ca014a29eab3dcdecd58d34c0a332fa78958872 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 20 Jan 2023 18:00:47 +0100 Subject: pkg/subsystem: add the basic caller-facing interface Users of the pkg/subsystem are only interested in 1) Fetching the list of subsystems for a given OS. 2) Matching a crash against the extracted set of subsystems. --- pkg/subsystem/list.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 pkg/subsystem/list.go (limited to 'pkg/subsystem/list.go') diff --git a/pkg/subsystem/list.go b/pkg/subsystem/list.go new file mode 100644 index 000000000..737ab859e --- /dev/null +++ b/pkg/subsystem/list.go @@ -0,0 +1,32 @@ +// Copyright 2023 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +package subsystem + +import ( + "github.com/google/syzkaller/pkg/subsystem/entity" +) + +// In general, it's not correct to assume that subsystems are only determined by target.OS, +// because subsystems are related not to the user interface of the OS kernel, but rather to +// the OS kernel implementation. +// +// For example, during fuzzing we can treat gVisor in the same way as any other Linux kernel. +// In reality, however, not a single MAINTAINERS-based rule will work on the gVisor codebase. +// +// Therefore, subsystem lists have to be a completely different entity. + +var ( + lists = make(map[string][]*entity.Subsystem) +) + +func RegisterList(name string, list []*entity.Subsystem) { + if _, ok := lists[name]; ok { + panic(name + " subsystem list already exists!") + } + lists[name] = list +} + +func GetList(name string) []*entity.Subsystem { + return lists[name] +} -- cgit mrf-deployment