brezerk / q4wine

Q4Wine is a Qt GUI for W.I.N.E. It will help you manage wine prefixes and installed applications.
http://q4wine.brezblock.org.ua/
GNU General Public License v3.0
204 stars 40 forks source link

Mounting images via UDisks2 #184

Open gasinvein opened 3 years ago

gasinvein commented 3 years ago

UDisks is a privileged daemon with D-Bus API for for manipulating block devices and filesystems. Q4Wine could ask UDisks2 to mount a disk image for it. This gives several advantages over exec'ing CLI tools for mount:

Key difference from current mount approach, as I see it, is that UDisks2 sets up a mountpoint for us automatically (usually in /media or /run/media/) when mounting a filesystem, which means we can't select it ourselves.

To mount an image, client app would need to call two D-Bus methods sequentially: org.freedesktop.UDisks2.Manager.LoopSetup to create a block device backed by given image (returns object path of the created device), and then org.freedesktop.UDisks2.Filesystem.Mount (method of the block device object we just created) to mount the filesystem (returns path to the mount point).

brezerk commented 3 years ago

as per: https://wiki.archlinux.org/title/udisks seems like there are two ways to interact with udisks: dbus and cli. cli probably would be much easier to implement.

brezerk commented 3 years ago

or seems like there is much interesting way: https://doc.qt.io/qt-5/qdbusinterface.html

gasinvein commented 3 years ago

I believe DBus API is the proper way to integrate apps with udisks2. udisksctl is just a very limited console UI, it's probably not supposed to be invoked from apps.

or seems like there is much interesting way: https://doc.qt.io/qt-5/qdbusinterface.html

Yeah, Qt DBus module should do.

brezerk commented 3 years ago

api reference: http://storaged.org/doc/udisks2-api/latest/

gasinvein commented 3 years ago

Yeah, we don't need much of the API here, just two interfaces and two method calls. Probably the only thing to note is that when calling LoopSetup method on org.freedesktop.UDisks2.Manager interface, we should set no-part-scan option to true, so the filesystem interface appears for the whole loopback block device and we won't need to poke into partitions to mount the filesystem.