Commit graph

8 commits

Author SHA1 Message Date
Christian Kellner
373f474769 loop: use python 3 style base class initialization
Use the canonical Python3 usage of "super" without any arguments.
pylint 2.6.0 started to actually warn about this.
2020-10-30 17:28:31 +01:00
David Rheinsberg
5d40010d3c loop: fix FD leak in mknod()
The mknod() method currently allows passing no dir_fd, in which case an
internal one is opened. This FD is then never closed, though.

Fix this by simply making the dir_fd mandatory. All callers pass it
(there is actually only a single caller), so no need for the fallback.
2020-04-21 13:02:29 +02:00
Lars Karlitski
b487126bb8 loop: explicitly close fds to loop devices
Don't wait until python's garbage collector closes the file descriptors
to loop devices. Close them when the `LoopServer` context manager exits,
after an assembler has finished running.
2020-01-19 22:19:25 +01:00
Lars Karlitski
47dc1b5b92 loop: don't leak open fd to /dev
Close the file descriptor to `/dev` when we opened it.
2020-01-19 22:19:25 +01:00
Lars Karlitski
977f0a465b loop: fix typo in LoopInfo member 2020-01-19 22:19:25 +01:00
Christian Kellner
24f41495d9 loop: fix a few typos
Some minor spelling corrections and a correction to the API doc in
one place.
2019-12-13 18:15:08 +01:00
Tom Gundersen
79b2f37cbc loop: add direct-io support
Support the LOOP_SET_DIRECT_IO ioctl, which alows us to control
whether or not a loopback device should perform its own buffering
or rely on the one done by the underlying backing file.

Enabling this should improve both throughput and memory consumption,
it is not currently hooked up as more testing would be required.
2019-07-25 23:55:43 +02:00
Tom Gundersen
c124ab264b loop: add helpers to use IPC to create loop devices
loop.py is a simple wrapper around the kernel loop API. remoteloop.py
uses this to create a server/clinet pair that communicates over an
AF_UNIX/SOCK_DGRAM socket to allow the server to create loop devices
for the client.

The client passes a fd that should be bound to the resulting loop
device, and a dir-fd where the loop device node should be created.
The server returns the name of the device node to the client.

The idea is that the client is run from whithin a container without
access to devtmpfs (and hence /dev/loop-control), and the server
runs on the host. The client would typically pass its (fake) /dev
as the output directory.

For the client this will be similar to `losetup -f foo.img --show`.

[@larskarlitski: pylint: ignore the new LoopInfo class, because it
only has dynamic attributes. Also disable attribute-defined-outside-init,
which (among other problems) is not ignored for that class.]

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-07-19 00:51:12 +02:00