mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-06-26 18:18:24 +00:00
Add symlinks package with Resolve function
This change adds a symlinks.Resolve function for resolving symlinks and updates usages across the code to make use of it. Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
@@ -29,6 +29,7 @@ import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/lookup/symlinks"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -288,16 +289,7 @@ func (c *ldcache) resolve(target string) (string, error) {
|
||||
|
||||
c.logger.Debugf("checking %v", string(name))
|
||||
|
||||
info, err := os.Lstat(name)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get file info: %v", info)
|
||||
}
|
||||
if info.Mode()&os.ModeSymlink == 0 {
|
||||
c.logger.Debugf("Resolved regular file: %v", name)
|
||||
return name, nil
|
||||
}
|
||||
|
||||
link, err := os.Readlink(name)
|
||||
link, err := symlinks.Resolve(name)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to resolve symlink: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user