23 lines
726 B
Python
23 lines
726 B
Python
# Disk exhaustion: the scratch tmpfs and the file size limit refuse writes
|
|
# long before the host is affected.
|
|
import os
|
|
|
|
block = b"x" * (1 << 20)
|
|
refused = []
|
|
try:
|
|
with open("/tmp/one-big-file", "wb") as stream:
|
|
for _ in range(64):
|
|
stream.write(block)
|
|
stream.flush()
|
|
except OSError as error:
|
|
refused.append("file:" + os.strerror(error.errno))
|
|
os.remove("/tmp/one-big-file")
|
|
try:
|
|
for index in range(64):
|
|
with open(f"/tmp/part-{index}", "wb") as stream:
|
|
for _ in range(4):
|
|
stream.write(block)
|
|
except OSError as error:
|
|
refused.append("tmpfs:" + os.strerror(error.errno))
|
|
print("refused" if len(refused) == 2 else f"wrote everything {refused}")
|