summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-11-18 11:26:47 +0100
committerJürg Billeter <j@bitron.ch>2019-11-25 09:45:22 +0100
commitf439c47deb6ea79e0b17b8e0429d0b834ce15e05 (patch)
tree80d039a1705d6a2cf7f18fab1a76d20c6e581839
parentc6e2ea93a0bf8dcc34623339063e6a91b2eb3d51 (diff)
downloadbuildstream-f439c47deb6ea79e0b17b8e0429d0b834ce15e05.tar.gz
utils.py: Add get_umask() method
-rw-r--r--src/buildstream/utils.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/buildstream/utils.py b/src/buildstream/utils.py
index 181ea1df9..5bc1ce08f 100644
--- a/src/buildstream/utils.py
+++ b/src/buildstream/utils.py
@@ -65,6 +65,11 @@ _INITIAL_NUM_THREADS_IN_MAIN_PROCESS = 1
# Number of seconds to wait for background threads to exit.
_AWAIT_THREADS_TIMEOUT_SECONDS = 5
+# The process's file mode creation mask.
+# Impossible to retrieve without temporarily changing it on POSIX.
+_UMASK = os.umask(0o777)
+os.umask(_UMASK)
+
class UtilError(BstError):
"""Raised by utility functions when system calls fail.
@@ -638,6 +643,17 @@ def save_file_atomic(
raise
+# get_umask():
+#
+# Get the process's file mode creation mask without changing it.
+#
+# Returns:
+# (int) The process's file mode creation mask.
+#
+def get_umask():
+ return _UMASK
+
+
# _get_dir_size():
#
# Get the disk usage of a given directory in bytes.