Documentation ¶
Overview ¶
Package symlink provides symlink-related util functions for container extraction.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RemoveObsoleteSymlinks ¶
RemoveObsoleteSymlinks removes symlinks that point to a destination file or directory path that does not exist. Note: There are three terms used in this function: symlink, target link, and destination file.
symlink: Refers to the symlink file itself. target link: The link stored in a symlink file that points to another file (or symlink). destination file: The last file pointed to by a symlink. That is, if there is a chain of symlinks, the destination file is the file pointed to by the last symlink.
Example: In this file system, the symlink, sym3, points to a destination file that doesn't exist
(b.txt). This function would remove the sym3.txt file. root dir1 a.txt sym1.txt -> ../dir2/sym2.txt dir2 sym2.txt -> ../dir1/a.txt sym3.txt -> ../dir1/b.txt (would be removed since b.txt does not exist)
func ResolveInterLayerSymlinks ¶
ResolveInterLayerSymlinks resolves absolute and relative symlinks in a layer sub-directory with a given layer digest by redirecting the symlink target path to point to the SQUASHED layer's symlink target path if it exists.
The structure of the layered directory before resolving symlinks is as follows:
root layer1digest dir1 sample.txt layer2digest dir2 relative-symlink.txt -> ../sample.txt (notice how ../sample.txt wouldn't be found due to the layering approach) absolute-symlink.txt -> /dir1/sample.txt (the /dir1/sample.txt target file also wouldn't be found) SQUASHED dir1 sample.txt dir2 relative-symlink.txt -> /root/SQUASHED/dir1/sample.txt absolute-symlink.txt -> /root/SQUASHED/dir1/sample.txt
After resolving the layer with layer digest of "layer2digest", the file system is as follows:
root layer1digest dir1 sample.txt layer2digest dir2 relative-symlink.txt -> /root/SQUASHED/dir2/relative-symlink.txt absolute-symlink.txt -> /root/SQUASHED/dir2/relative-symlink.txt SQUASHED dir1 sample.txt dir2 relative-symlink.txt -> /root/SQUASHED/dir1/sample.txt absolute-symlink.txt -> /root/SQUASHED/dir1/sample.txt
func TargetOutsideRoot ¶
TargetOutsideRoot checks if the target of a symlink points outside of the root directory of that symlink's path. For example, if a symlink with path `a/symlink.txt“ points to “../../file.text“, then this function would return true because the target file is outside of the root directory.
Types ¶
This section is empty.