Howto gvfs monior device to manage device by hal

The frndamental of gvfs monitor device change like below items:

1. summary first, launch a daemon /usr/libexec/gvfsd which emit "mount-changed" "mount-added"... to backend. backend example: /usr/libexec/gvfs-hal-volume-monitor to monitor hal, can get the "mount-changed" "mount-added"... singal, and try to mount device by tool of gnome-mount. 

2. user insert a usb device

3. get notify by hal,also get the device properties

4. mount device as command of "gnome-mount -b -d [device-path]"

5. update the device properties, emit a singal "mount_changed" to GVolumeMonitor

6. why GVolumeMonitor class which belong "glib/gio" can be used like:

    g_signal_connect (monitor, "mount-changed", G_CALLBACK (mount_changed), NULL);

    we can find the monitor init source like:

  GHalVolumeMonitor * monitor->mount_monitor = g_unix_mount_monitor_new ();

  g_signal_connect (monitor->mount_monitor,
                    "mounts_changed", G_CALLBACK (mounts_changed),
                    monitor);

  g_signal_connect (monitor->mount_monitor,
                    "mountpoints_changed", G_CALLBACK (mountpoints_changed),
                    monitor);

  g_signal_connect (monitor->pool,
                    "device_added", G_CALLBACK (hal_changed),
                    monitor);

  g_signal_connect (monitor->pool,
                    "device_removed", G_CALLBACK (hal_changed),
                    monitor);
 

    Because GVolumeMonitor call the backend which monitor /etc/fstab /etc/mtab or /proc/mounts check the mount point of device and so on . when device mount/unmount these files will changed, then singal be wrapped and received by the GVolumeMonitor.

 

7.umount the device

8. monitor get notify by hal

9. use command of "gnome-mount -u -b -d [device]"  to umount device

 

detail source see:

gvfs-1.2.3/monitor/*

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值