-
Notifications
You must be signed in to change notification settings - Fork 76
Description
Hey there maybe I am just to silly to read the docs right, but I have trouble accessing org.freedesktop.UDisks2.Manager
using the LoopSetup
Method.
Looking at the docs the signature looks as follows:
LoopSetup (IN h fd,
IN a{sv} options,
OUT o resulting_device);
- Is the file descriptor
- Some Options
- The resulting device
While options expects the following:
auth.no_user_interaction (of type 'b'),
offset (of type 't'),
size (of type 't'),
read-only (of type 'b'),
no-part-scan (of type 'b'),
sector-size (of type 't').
According to pydbus it looks like this in python:
Help on method LoopSetup in module pydbus.proxy_method:
LoopSetup(fd:h, options:a{sv}) -> o method of DBUS.org.freedesktop.UDisks2.Manager instance
According to DSpy it looks like this:

Very similar to pydbus representation.
We have the File Descriptor followed by the options.
So I do the following in code
bus = SystemBus()
udisks2_bus = bus.get('org.freedesktop.UDisks2', '/org/freedesktop/UDisks2')
udisks2_manager = bus.get('org.freedesktop.UDisks2', '/org/freedesktop/UDisks2/Manager')
def mount_iso_image(file):
fd = os.open(file.get_path(), os.O_RDONLY) # Get the File Descriptor based on the file path
# Creating Glib.Variants of options
auth = GLib.Variant('b', 0)
offset = GLib.Variant('t', 0)
size = GLib.Variant('t', 0)
readonly = GLib.Variant('b', 1)
scan = GLib.Variant('b', 0)
sector = GLib.Variant('t', 0)
fd_variant = GLib.Variant('h', fd)
options = {'auth.no_user_interaction': auth,
'offset': offset,
'size': size,
'read-only': readonly,
'no-part-scan': scan,
'sector-size': sector,
}
# Get the Manager
manager_interface = udisks2_manager['org.freedesktop.UDisks2.Manager']
# Call LoopSetup
manager_interface.LoopSetup(fd, options)
But I get:
Traceback (most recent call last):
File "/app/share/win2go/win2go/ui/main_window.py", line 46, in on_image_opened
mount_iso_image(self.image_file)
File "/app/share/win2go/win2go/utils/udisks2.py", line 45, in mount_iso_image
manager_interface.LoopSetup(fd, options)
File "/app/lib/python3.12/site-packages/pydbus/proxy_method.py", line 72, in __call__
ret = instance._bus.con.call_sync(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gi.repository.GLib.GError: g-io-error-quark: GDBus.Error:org.freedesktop.UDisks2.Error.Failed: Expected to use fd at index 23, but message has only 0 fds (36)
My under standing is that the file descriptor is already there. It is the very first parameter fd
passed to LoopSetup which to my knowledge is just a regular INT which is what os.open() does return and "should" just work.
Tried adding the file descriptor also to the options dictionary to no avail. Which doesn't surprise it is not expected as per documentation.
What am I missing here? Wrapping my head around this since two days and I seem to run in circles here. Where to put the fd?