When loop.Loop() is called and a new loop device must be allocated there is no gurantee that the correct device node is available on the system. In containers /dev is often just a tmpfs with static device nodes. So when /dev/loopN is not available when the container is created the device node will be missing even if `get_unbound()` create a new loop device for us. This commit ensures that the device node is available. It creates it unconditionally and ignores any EEXIST errors to ensure there is no TOCTOU issue. Note that the test could have passed a `Loop(dir_fd=open(tmpdir))` instead of creating/patching loop.DEV_PATH but it seems slightly nicer to test the flow without a custom dir_path as this is what the real code that creates a loop device is also using. |
||
|---|---|---|
| .. | ||
| cases | ||
| data | ||
| mod | ||
| run | ||
| .gitignore | ||
| __init__.py | ||
| conftest.py | ||
| initrd.py | ||
| test.py | ||