diff options
author | 2022-11-16 15:40:30 -0500 | |
---|---|---|
committer | 2022-11-16 15:40:30 -0500 | |
commit | 6c44da8e4e52cbba928709b4b6512bb51b5b2753 (patch) | |
tree | f54d635dcefb8ae66c79a62f1d88b7a918f7e39c | |
parent | Refactor to use individual tmpfs (diff) |
Formatting
-rw-r--r-- | snekbox/memfs.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/snekbox/memfs.py b/snekbox/memfs.py index e09cee7..b7295a6 100644 --- a/snekbox/memfs.py +++ b/snekbox/memfs.py @@ -19,17 +19,27 @@ log = logging.getLogger(__name__) def mount_tmpfs(name: str) -> Path: """Create and mount a tmpfs directory.""" - tmp = Path("/snekbox/memfs", name) + namespace = Path("/snekbox/memfs") + tmp = namespace / name if not tmp.exists() or not tmp.is_dir(): # Create the directory tmp.mkdir(parents=True, exist_ok=True) tmp.chmod(0o777) # Mount the tmpfs subprocess.check_call( - ["mount", "-t", "tmpfs", "-o", f"size={MemFSOptions.MEMFS_SIZE}", "tmpfs", str(tmp)] + [ + "mount", + "-t", + "tmpfs", + "-o", + f"size={MemFSOptions.MEMFS_SIZE}", + "tmpfs", + str(tmp), + ] ) # Execute only access for other users tmp.chmod(0o711) + namespace.chmod(0o711) return tmp |