mirror of
https://github.com/containers/podman.git
synced 2025-10-17 11:14:40 +08:00
refactor: use os.ReadDir
for lightweight directory reading
`os.ReadDir` was added in Go 1.16 as part of the deprecation of `ioutil` package. It is a more efficient implementation than `ioutil.ReadDir`. Reference: https://pkg.go.dev/io/ioutil#ReadDir Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@ -4,7 +4,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -119,7 +118,7 @@ func AddPrivilegedDevices(g *generate.Generator) error {
|
||||
|
||||
// based on getDevices from runc (libcontainer/devices/devices.go)
|
||||
func getDevices(path string) ([]spec.LinuxDevice, error) {
|
||||
files, err := ioutil.ReadDir(path)
|
||||
files, err := os.ReadDir(path)
|
||||
if err != nil {
|
||||
if rootless.IsRootless() && os.IsPermission(err) {
|
||||
return nil, nil
|
||||
@ -146,7 +145,7 @@ func getDevices(path string) ([]spec.LinuxDevice, error) {
|
||||
}
|
||||
case f.Name() == "console":
|
||||
continue
|
||||
case f.Mode()&os.ModeSymlink != 0:
|
||||
case f.Type()&os.ModeSymlink != 0:
|
||||
continue
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user