udisks2 - How to get basic functionality we had in old udisks?
genlist at faert.net
Tue Nov 17 00:23:51 PST 2015
On 16.11.2015 17:16, .. ink .. wrote:
> On Mon, Nov 16, 2015 at 5:47 PM, Guy <genlist at faert.net> wrote:
>> - An example: Good old udisks told us the name of files associated with loop
>> devices. This information is queried directly from the loop device driver,
>> by using an ioctl call. The consequence is, that this info only is available
>> when running as root.
> It is possible to get a name of a file associated with a loop device
> without root's privileges.
> The path of the backing file of loop device "/dev/loop0" for
> example,can be obtained by reading:
Yes, in deed! Thanks for the hint! I copied the ioctl-call from the
udisks source - but your solution is much better!
I updated my test program on faert.net/jangdeblannen/udevblk.c accordingly.
> A few comments about your code:
> 1. No need to cast return value of malloc() as the language will
> automatically do it for you.
Lint and g++ are not satisfied without casting. I always do this in
order to get rid of all the warnings.
> 2. Its perfectly fine to free a NULL pointer and hence no need to
> check if a variable is not NULL
> before passing it to free()
Maybe. Depends on your philosophy. I do not rely on it; old school,
wasn't allowed when I started programming a long long time ago ;-)
More information about the devkit-devel