github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/pkg/subsystem/list.go (about)

     1  // Copyright 2023 syzkaller project authors. All rights reserved.
     2  // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  package subsystem
     5  
     6  // In general, it's not correct to assume that subsystems are only determined by target.OS,
     7  // because subsystems are related not to the user interface of the OS kernel, but rather to
     8  // the OS kernel implementation.
     9  //
    10  // For example, during fuzzing we can treat gVisor in the same way as any other Linux kernel.
    11  // In reality, however, not a single MAINTAINERS-based rule will work on the gVisor codebase.
    12  //
    13  // Therefore, subsystem lists have to be a completely different entity.
    14  
    15  var (
    16  	lists = make(map[string][]*Subsystem)
    17  )
    18  
    19  func RegisterList(name string, list []*Subsystem) {
    20  	if _, ok := lists[name]; ok {
    21  		panic(name + " subsystem list already exists!")
    22  	}
    23  	lists[name] = list
    24  }
    25  
    26  func GetList(name string) []*Subsystem {
    27  	return lists[name]
    28  }
    29  
    30  func ListService(name string) *Service {
    31  	return MustMakeService(lists[name])
    32  }