loop: add Loop.is_bound_to helper

Add a `Loop.is_bound_to` helper that checks if the looback device is
bound if is so if the backing file refers to the same file as `fd`.
The latter is done by comparing the device and inode information.
This commit is contained in:
Christian Kellner 2021-08-11 19:20:47 +02:00 committed by Tom Gundersen
parent d6c421faf3
commit a367a0df1d
2 changed files with 33 additions and 0 deletions

View file

@ -37,6 +37,8 @@ def test_basic(tempdir):
f.flush()
lo = ctl.loop_for_fd(f.fileno(), autoclear=True)
assert lo.is_bound_to(f.fileno())
sb = os.fstat(f.fileno())
assert lo