aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/host
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2023-02-23 14:28:18 +0100
committerGitHub <noreply@github.com>2023-02-23 14:28:18 +0100
commit4359978ef22a22ddd5a19adf18cbc80cb44244fb (patch)
tree7952da94e27417b39ddf952d9e0bab431dafc4c5 /pkg/host
parent9e2ebb3c174f1e168bc1fbadd5f02f2e25e314fc (diff)
all: ioutil is deprecated in go1.19 (#3718)
Diffstat (limited to 'pkg/host')
-rw-r--r--pkg/host/machine_info_linux.go9
-rw-r--r--pkg/host/syscalls_linux.go7
2 files changed, 7 insertions, 9 deletions
diff --git a/pkg/host/machine_info_linux.go b/pkg/host/machine_info_linux.go
index fb05382ba..fc3664c42 100644
--- a/pkg/host/machine_info_linux.go
+++ b/pkg/host/machine_info_linux.go
@@ -7,7 +7,6 @@ import (
"bufio"
"bytes"
"fmt"
- "io/ioutil"
"os"
"path/filepath"
"regexp"
@@ -86,7 +85,7 @@ func allEqual(slice []string) bool {
}
func readKVMInfo(buffer *bytes.Buffer) error {
- files, err := ioutil.ReadDir("/sys/module/")
+ files, err := os.ReadDir("/sys/module/")
if err != nil {
return err
}
@@ -98,7 +97,7 @@ func readKVMInfo(buffer *bytes.Buffer) error {
}
paramPath := filepath.Join("/sys", "module", name, "parameters")
- params, err := ioutil.ReadDir(paramPath)
+ params, err := os.ReadDir(paramPath)
if err != nil {
if os.IsNotExist(err) {
continue
@@ -113,7 +112,7 @@ func readKVMInfo(buffer *bytes.Buffer) error {
fmt.Fprintf(buffer, "/sys/module/%s:\n", name)
for _, key := range params {
keyName := key.Name()
- data, err := ioutil.ReadFile(filepath.Join(paramPath, keyName))
+ data, err := os.ReadFile(filepath.Join(paramPath, keyName))
if err != nil {
return err
}
@@ -127,7 +126,7 @@ func readKVMInfo(buffer *bytes.Buffer) error {
func getModulesInfo() ([]KernelModule, error) {
var modules []KernelModule
- modulesText, _ := ioutil.ReadFile("/proc/modules")
+ modulesText, _ := os.ReadFile("/proc/modules")
re := regexp.MustCompile(`(\w+) .*(0[x|X][a-fA-F0-9]+)[^\n]*`)
for _, m := range re.FindAllSubmatch(modulesText, -1) {
addr, err := strconv.ParseUint(string(m[2]), 0, 64)
diff --git a/pkg/host/syscalls_linux.go b/pkg/host/syscalls_linux.go
index 6425fcce7..67efd9295 100644
--- a/pkg/host/syscalls_linux.go
+++ b/pkg/host/syscalls_linux.go
@@ -6,7 +6,6 @@ package host
import (
"bytes"
"fmt"
- "io/ioutil"
"os"
"regexp"
"runtime"
@@ -58,7 +57,7 @@ func isSupportedSyscall(c *prog.Syscall, target *prog.Target) (bool, string) {
// Kallsyms seems to be the most reliable and fast. That's what we use first.
// If kallsyms is not present, we fallback to execution of syscalls.
kallsymsOnce.Do(func() {
- kallsyms, _ := ioutil.ReadFile("/proc/kallsyms")
+ kallsyms, _ := os.ReadFile("/proc/kallsyms")
if len(kallsyms) == 0 {
return
}
@@ -390,7 +389,7 @@ func isSupportedSyzOpenDev(sandbox string, c *prog.Syscall) (bool, string) {
func isSupportedLSM(c *prog.Syscall) string {
lsmOnce.Do(func() {
- data, err := ioutil.ReadFile("/sys/kernel/security/lsm")
+ data, err := os.ReadFile("/sys/kernel/security/lsm")
if err != nil {
// securityfs may not be mounted, but it does not mean
// that no LSMs are enabled.
@@ -522,7 +521,7 @@ func isSupportedMount(c *prog.Syscall, sandbox string) (bool, string) {
func isSupportedFilesystem(fstype string) (bool, string) {
filesystemsOnce.Do(func() {
- filesystems, _ = ioutil.ReadFile("/proc/filesystems")
+ filesystems, _ = os.ReadFile("/proc/filesystems")
})
if !bytes.Contains(filesystems, []byte("\t"+fstype+"\n")) {
return false, fmt.Sprintf("/proc/filesystems does not contain %v", fstype)