diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-12-10 16:53:21 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-12-11 15:22:17 +0000 |
| commit | baa3289d16dccd357662a0d20b98aa62837d147b (patch) | |
| tree | f98bb706f7aa8ff78760f9dfc01dfc25de9260fc /pkg/declextract | |
| parent | 51cc7d239d57fbdf7b64a618b7c6128bf7588876 (diff) | |
pkg/declextract: generated single openat for all related files
Diffstat (limited to 'pkg/declextract')
| -rw-r--r-- | pkg/declextract/fileops.go | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/pkg/declextract/fileops.go b/pkg/declextract/fileops.go index a18566647..da1a74dc0 100644 --- a/pkg/declextract/fileops.go +++ b/pkg/declextract/fileops.go @@ -30,34 +30,17 @@ func (ctx *context) createFops(fops *FileOps, files []string) { ctx.fmt("resource %v[fd]\n", fdt) } suffix := autoSuffix + "_" + fops.Name - if len(files) == 1 { - ctx.fmt("openat%v(fd const[AT_FDCWD], file ptr[in, string[\"%s\"]],"+ - " flags flags[open_flags], mode const[0]) %v\n", suffix, files[0], fdt) - } else { - // If there are too many files, split them into parts. - // First, compiler currently sets limit of 2000 values for string flags; - // second, it should provide additional prioritization signal for the fuzzer - // (if there are multiple openat calls, it should call them more often than a single call). - const partSize = 100 - singlePart := len(files) <= partSize - for partID := 0; len(files) != 0; partID++ { - part := files[:min(100, len(files))] - files = files[len(part):] - partSuffix := "" - if !singlePart { - partSuffix = fmt.Sprint(partID) - } - fileFlags := fmt.Sprintf("%v_files%v", fops.Name, partSuffix) - ctx.fmt("%v = ", fileFlags) - for i, file := range part { - ctx.fmt("%v \"%v\"", comma(i), file) - } - ctx.fmt("\n") - ctx.fmt("openat%v%v(fd const[AT_FDCWD], file ptr[in, string[%v]],"+ - " flags flags[open_flags], mode const[0]) %v\n", - suffix, partSuffix, fileFlags, fdt) + fileFlags := fmt.Sprintf("\"%s\"", files[0]) + if len(files) > 1 { + fileFlags = fmt.Sprintf("%v_files", fops.Name) + ctx.fmt("%v = ", fileFlags) + for i, file := range files { + ctx.fmt("%v \"%v\"", comma(i), file) } + ctx.fmt("\n") } + ctx.fmt("openat%v(fd const[AT_FDCWD], file ptr[in, string[%v]], flags flags[open_flags], mode const[0]) %v\n", + suffix, fileFlags, fdt) if fops.Read != "" { ctx.fmt("read%v(fd %v, buf ptr[out, array[int8]], len bytesize[buf])\n", suffix, fdt) } |
