summaryrefslogtreecommitdiff
path: root/linuxnamespaces
diff options
context:
space:
mode:
Diffstat (limited to 'linuxnamespaces')
-rw-r--r--linuxnamespaces/atlocation.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/linuxnamespaces/atlocation.py b/linuxnamespaces/atlocation.py
index 6f0b8d9..70f9a77 100644
--- a/linuxnamespaces/atlocation.py
+++ b/linuxnamespaces/atlocation.py
@@ -217,6 +217,29 @@ class AtLocation:
follow_symlinks=follow_symlinks,
)
+ def link(self, dst: "AtLocationLike") -> None:
+ """Wrapper for os.link supplying src_dir_fd, dst_dir_fd and
+ follow_symlinks.
+ """
+ if self.flags & AtFlags.AT_NO_AUTOMOUNT != AtFlags.NONE:
+ raise NotImplementedError(
+ "link on AtFlags with unsupported source flags"
+ )
+ dst = AtLocation(dst)
+ if dst.flags != AtFlags.NONE:
+ raise NotImplementedError(
+ "link on AtFlags with unsupported destination flags"
+ )
+ os.link(
+ self.location,
+ dst.location,
+ src_dir_fd=self.fd_or_none,
+ dst_dir_fd=dst.fd_or_none,
+ follow_symlinks=(
+ self.flags & AtFlags.AT_SYMLINK_NOFOLLOW != AtFlags.NONE
+ ),
+ )
+
def mkdir(self, mode: int = 0o777) -> None:
"""Wrapper for os.mkdir supplying path and dir_fd."""
if self.flags != AtFlags.NONE: