Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
GIO failure in C++ but runs perfectly from Terminal
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
ONEEYEMAN
Advocate
Advocate


Joined: 01 Mar 2005
Posts: 3650

PostPosted: Sun Sep 15, 2024 12:41 am    Post subject: GIO failure in C++ but runs perfectly from Terminal Reply with quote

Hi, ALL,
Code:

igor@WaylandGnome ~/dbhandler $ gio mount --list --detail
Drive(0): HGST HTS721010A9E630
  Type: GProxyDrive (GProxyVolumeMonitorUDisks2)
  ids:
   unix-device: '/dev/sda'
  themed icons:  [drive-harddisk]  [drive]  [drive-harddisk-symbolic]  [drive-symbolic]
  symbolic themed icons:  [drive-harddisk-symbolic]  [drive-symbolic]  [drive-harddisk]  [drive]
  is_removable=0
  is_media_removable=0
  has_media=1
  is_media_check_automatic=1
  can_poll_for_media=0
  can_eject=0
  can_start=0
  can_stop=0
  start_stop_type=shutdown
  sort_key=00coldplug/00fixed/sd____a


This runs from Terminal and gives me some info.

However when I try to call it from my C++ software, it fails:

Code:

(gdb)
16       auto monitor = g_volume_monitor_get();
(gdb)
17       GList *volumelist = g_volume_monitor_get_volumes( monitor ), *volumes;
(gdb) p monitor
$1 = 0x555555ee6a20
(gdb) n
18       for( volumes = volumelist; volumes != NULL; volumes = volumes->next )
(gdb) p volumelist
$2 = 0x0


What could be the reason?

And more interestingly - where can I find the code for the gio functions?

Maybe all I need is to reinstall something with the "debug" USE-flag and try to run gdb on my program?

Thank you.

EDIT:

Forgot to mention:
GTK 3.24.29 on X/GNOME.
Back to top
View user's profile Send private message
netfab
Veteran
Veteran


Joined: 03 Mar 2005
Posts: 1956
Location: 127.0.0.1

PostPosted: Sun Sep 15, 2024 8:34 am    Post subject: Re: GIO failure in C++ but runs perfectly from Terminal Reply with quote

ONEEYEMAN wrote:

And more interestingly - where can I find the code for the gio functions?

https://gitlab.gnome.org/GNOME/glib/-/tree/main/gio
https://gitlab.gnome.org/GNOME/glib/-/blob/main/gio/gio-tool-mount.c#L938
Back to top
View user's profile Send private message
ONEEYEMAN
Advocate
Advocate


Joined: 01 Mar 2005
Posts: 3650

PostPosted: Sun Sep 15, 2024 4:54 pm    Post subject: Reply with quote

Hi,
Could someone please explain the following:

Code:

igor@WaylandGnome ~/wxFork/buildGTK/tests $ python
Python 3.11.8 (main, Mar 24 2024, 02:40:39) [GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>> from gi.repository import Gio
>>> volume_monitor = Gio.VolumeMonitor.get()
>>> print(f'Number of drives: {len(volume_monitor.get_connected_drives())}')
Number of drives: 1
>>> print(f'Number of drives: {len(volume_monitor.get_volumes())}')
Number of drives: 0
>>> print(f'Number of drives: {len(volume_monitor.get_mounts())}')
Number of drives: 0
>>>


I have a drive connected, but it is not mounted?

How is it possible?

My dev-libs/glib is at 2.78.3.

Thank you.
Back to top
View user's profile Send private message
netfab
Veteran
Veteran


Joined: 03 Mar 2005
Posts: 1956
Location: 127.0.0.1

PostPosted: Sun Sep 15, 2024 6:52 pm    Post subject: Reply with quote

I'm getting a similar result :
Code:

$ python
Python 3.12.3 (main, Jun 10 2024, 12:32:47) [GCC 13.2.1 20240210] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>> from gi.repository import Gio
>>> volume_monitor = Gio.VolumeMonitor.get()
>>> print(f'Number of drives: {len(volume_monitor.get_connected_drives())}')
Number of drives: 8
>>> print(f'Number of drives: {len(volume_monitor.get_volumes())}')
Number of drives: 0
>>> print(f'Number of drives: {len(volume_monitor.get_mounts())}')
Number of drives: 0

I guess that connected_drives and mounts definitions in glib are not what we expect.
Back to top
View user's profile Send private message
ONEEYEMAN
Advocate
Advocate


Joined: 01 Mar 2005
Posts: 3650

PostPosted: Mon Sep 16, 2024 6:09 pm    Post subject: Reply with quote

Hi,
I will try to set up my machine for debugging glib according to the instructions here and see what is happening..

Unless you will beat me to it...

Thank you.
Back to top
View user's profile Send private message
netfab
Veteran
Veteran


Joined: 03 Mar 2005
Posts: 1956
Location: 127.0.0.1

PostPosted: Tue Sep 17, 2024 10:17 pm    Post subject: Reply with quote

Hi,

It seems that all mounted partitions are hidden by default in gvfs and then in gio utility (don't ask me why).
If you add comment=x-gvfs-show in your fstab to the partitions options :
Code:

$ grep x-gvfs-show /etc/fstab
UUID=f0853ad0-1c8f-45c1-ac54-6d059acd66e9   /   ext4   noatime,comment=x-gvfs-show      0 1
UUID=2c2c456d-1a0b-4ebc-bde9-a798e961c6c6   /home   ext4   noatime,comment=x-gvfs-show      0 2
192.168.1.77:/                  /data/cubieboard2   nfs4   rw,noatime,soft,retry=0,comment=x-gvfs-show   0 0


The result is different :
Code:

$ python
Python 3.12.3 (main, Jun 10 2024, 12:32:47) [GCC 13.2.1 20240210] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>> from gi.repository import Gio
>>> volume_monitor = Gio.VolumeMonitor.get()
>>> print(f'Number of drives: {len(volume_monitor.get_connected_drives())}')
Number of drives: 8
>>> print(f'Number of volumes: {len(volume_monitor.get_volumes())}')
Number of volumes: 3
>>> print(f'Number of mounts: {len(volume_monitor.get_mounts())}')
Number of mounts: 3
Back to top
View user's profile Send private message
ONEEYEMAN
Advocate
Advocate


Joined: 01 Mar 2005
Posts: 3650

PostPosted: Wed Sep 18, 2024 12:44 am    Post subject: Reply with quote

Hi,
Yes, thank you.
Mystery solved.

;-)
Back to top
View user's profile Send private message
ONEEYEMAN
Advocate
Advocate


Joined: 01 Mar 2005
Posts: 3650

PostPosted: Wed Sep 18, 2024 4:46 am    Post subject: Reply with quote

Hi,
netfab wrote:

Hi,

It seems that all mounted partitions are hidden by default in gvfs and then in gio utility (don't ask me why).
If you add comment=x-gvfs-show in your fstab to the partitions options :
Code:

$ grep x-gvfs-show /etc/fstab
UUID=f0853ad0-1c8f-45c1-ac54-6d059acd66e9   /   ext4   noatime,comment=x-gvfs-show      0 1
UUID=2c2c456d-1a0b-4ebc-bde9-a798e961c6c6   /home   ext4   noatime,comment=x-gvfs-show      0 2
192.168.1.77:/                  /data/cubieboard2   nfs4   rw,noatime,soft,retry=0,comment=x-gvfs-show   0 0


The result is different :
Code:

$ python
Python 3.12.3 (main, Jun 10 2024, 12:32:47) [GCC 13.2.1 20240210] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>> from gi.repository import Gio
>>> volume_monitor = Gio.VolumeMonitor.get()
>>> print(f'Number of drives: {len(volume_monitor.get_connected_drives())}')
Number of drives: 8
>>> print(f'Number of volumes: {len(volume_monitor.get_volumes())}')
Number of volumes: 3
>>> print(f'Number of mounts: {len(volume_monitor.get_mounts())}')
Number of mounts: 3


Yes with that modifications it works correctly.
Moreover, some system do mount "shown" partitions during the boot-up.

Thank you for a suggestion.
Back to top
View user's profile Send private message
netfab
Veteran
Veteran


Joined: 03 Mar 2005
Posts: 1956
Location: 127.0.0.1

PostPosted: Wed Sep 18, 2024 7:58 am    Post subject: Reply with quote

This behavior is documented in a txt file in gvfs repository :
Code:

         CONTROLLING WHAT IS SHOWN IN THE USER INTERFACE
         ===============================================

The gvfs-udisks2-volume-monitor process is responsible for the disks,
media, mounts and fstab entries shown in the desktop user
interface.

[...]

If the directory for a device is known and outside /media, $HOME
(typically /home/foo) or /run/media/$USER then the device is not shown
in the user interface. Additionally, if any of component directories
in its directory starts with a dot ("."), the device is not shown
either. This policy may be overriden by use of the options x-gvfs-show
and x-gvfs-hide.

[...]
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum