From 0ee5518e766d5f509d405d86fb9d71dec70e0ed6 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sun, 9 Oct 2022 17:21:04 +0200 Subject: [PATCH] oci: use filepath.WalkDir instead of filepath.Walk WalkDir is more performant as it doesn't perform an os.Lstat on every visited file or directory. Signed-off-by: Sebastiaan van Stijn --- oci/devices_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oci/devices_linux.go b/oci/devices_linux.go index 6a3fa6be9f..5b6c6cf4a6 100644 --- a/oci/devices_linux.go +++ b/oci/devices_linux.go @@ -45,7 +45,7 @@ func DevicesFromPath(pathOnHost, pathInContainer, cgroupPermissions string) (dev if src, e := os.Stat(resolvedPathOnHost); e == nil && src.IsDir() { // mount the internal devices recursively // TODO check if additional errors should be handled or logged - _ = filepath.Walk(resolvedPathOnHost, func(dpath string, f os.FileInfo, _ error) error { + _ = filepath.WalkDir(resolvedPathOnHost, func(dpath string, f os.DirEntry, _ error) error { childDevice, e := coci.DeviceFromPath(dpath) if e != nil { // ignore the device