summaryrefslogtreecommitdiff
path: root/linuxnamespaces
diff options
context:
space:
mode:
Diffstat (limited to 'linuxnamespaces')
-rw-r--r--linuxnamespaces/atlocation.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/linuxnamespaces/atlocation.py b/linuxnamespaces/atlocation.py
index 08c0de5..c534150 100644
--- a/linuxnamespaces/atlocation.py
+++ b/linuxnamespaces/atlocation.py
@@ -313,6 +313,23 @@ class AtLocation:
assert self.location
return os.rmdir(self.location, dir_fd=self.fd_or_none)
+ def stat(self) -> os.stat_result:
+ """Wrapper for os.stat supplying dir_fd and follow_symlinks."""
+ if self.flags == AtFlags.AT_EMPTY_PATH:
+ return os.stat(self.fd)
+ follow_symlinks = True
+ if self.flags == AtFlags.AT_SYMLINK_NOFOLLOW:
+ follow_symlinks = True
+ elif self.flags != AtFlags.NONE:
+ raise NotImplementedError(
+ "stat is not supported for an AtFlags with given flags"
+ )
+ return os.stat(
+ self.location,
+ dir_fd=self.fd_or_none,
+ follow_symlinks=follow_symlinks,
+ )
+
def symlink_to(self, linktarget: PathConvertible) -> None:
"""Create a symlink at self pointing to linktarget. Note that this
method has its arguments reversed compared to the usual os.symlink,