pkg/bootparam: add bootparam pkg
This adds the bootparam package which can marshal and unmarshal the Linux
kernel command line into boot parameters and a rest section passed to
init.
This is a very quirky format, thus there is a fuzz testing harness
against the reference implementation from the kernel included to verify
correctness.
A set of weird edge cases is rejected by Unmarshal instead of parsing
to nonsensical data as the reference implementation does to save on
complexity in the parser.
Change-Id: I6debfa67e69ae8db4e0356f34ecb127ea27d18de
Reviewed-on: https://review.monogon.dev/c/monogon/+/1125
Tested-by: Jenkins CI
Reviewed-by: Serge Bazanski <serge@monogon.tech>
diff --git a/metropolis/pkg/bootparam/BUILD.bazel b/metropolis/pkg/bootparam/BUILD.bazel
new file mode 100644
index 0000000..33a9d91
--- /dev/null
+++ b/metropolis/pkg/bootparam/BUILD.bazel
@@ -0,0 +1,19 @@
+load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+
+go_library(
+ name = "bootparam",
+ srcs = ["bootparam.go"],
+ importpath = "source.monogon.dev/metropolis/pkg/bootparam",
+ visibility = ["//visibility:public"],
+)
+
+go_test(
+ name = "bootparam_test",
+ srcs = ["bootparam_test.go"],
+ gc_goopts = ["-d=libfuzzer"],
+ deps = [
+ ":bootparam",
+ "//metropolis/pkg/bootparam/ref",
+ "@com_github_google_go_cmp//cmp",
+ ],
+)