aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/subsystem/extract.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2022-12-16 00:01:51 +0100
committerAleksandr Nogikh <wp32pw@gmail.com>2022-12-16 10:22:43 +0100
commitfcac021fe5ed726e926d2e585e7a2f59d8827f21 (patch)
tree6d0c71e92b2494c53014124ca0197c760889453d /pkg/subsystem/extract.go
parentbd797b29e63755f6d6fceb2b8ef5430e7def9551 (diff)
pkg/subsystem: extract filesystems from guilty path
As we can easily do the subsystem <-> path mapping, let's also use it for determining the actual involved filesystem.
Diffstat (limited to 'pkg/subsystem/extract.go')
-rw-r--r--pkg/subsystem/extract.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/pkg/subsystem/extract.go b/pkg/subsystem/extract.go
index 4d952011f..1908f5e54 100644
--- a/pkg/subsystem/extract.go
+++ b/pkg/subsystem/extract.go
@@ -5,6 +5,7 @@ package subsystem
import (
"regexp"
+ "sync"
"github.com/google/syzkaller/prog"
)
@@ -58,9 +59,24 @@ func linuxPathToSubsystems(path string) []string {
if vfsPathRegexp.MatchString(path) {
ret = append(ret, "vfs")
}
+ linuxSubsystemsOnce.Do(func() {
+ for name, info := range linuxSubsystems {
+ linuxSubsystemRegexps[name] = regexp.MustCompile("^/?" + info.path + ".*")
+ }
+ })
+ for name, pattern := range linuxSubsystemRegexps {
+ if pattern.MatchString(path) {
+ ret = append(ret, name)
+ }
+ }
return ret
}
+var (
+ linuxSubsystemsOnce sync.Once
+ linuxSubsystemRegexps = map[string]*regexp.Regexp{}
+)
+
func linuxCallToSubsystems(call string) []string {
name := linuxCallToSubsystemsMap[call]
if name != "" {