remoteloop: remove dir_fd argument in create_device

If dir_fd wasn't passed, create_device() openend it to `/dev` and forgot
about closing it. To fix this, it would have to gain logic to only close
the fd if it wasn't passed in.

Side-step the problem by removing dir_fd, since nothing is using it
right now. We can add it back if something needs it.
This commit is contained in:
Lars Karlitski 2019-10-05 23:58:33 +02:00
parent 3d3ffda5d8
commit 356f62058f

View file

@ -112,12 +112,10 @@ class LoopClient:
def __init__(self, sock):
self.sock = sock
def create_device(self, fd, dir_fd=None, offset=None, sizelimit=None):
def create_device(self, fd, offset=None, sizelimit=None):
req = {}
fds = array.array("i")
if not dir_fd:
dir_fd = os.open("/dev", os.O_DIRECTORY)
dir_fd = os.open("/dev", os.O_DIRECTORY)
fds.append(fd)
req["fd"] = 0
@ -130,6 +128,8 @@ class LoopClient:
req["sizelimit"] = sizelimit
dump_fds(self.sock, req, fds)
os.close(dir_fd)
ret = json.loads(self.sock.recv(1024))
return ret["devname"]