Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Factory:Rebuild
thunar-volman
thunar-volman-use-udisks-hints.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File thunar-volman-use-udisks-hints.diff of Package thunar-volman
diff --git a/thunar-volman/tvm-block-device.c b/thunar-volman/tvm-block-device.c index edb6cad..5397bbc 100644 --- a/thunar-volman/tvm-block-device.c +++ b/thunar-volman/tvm-block-device.c @@ -754,7 +754,44 @@ tvm_block_device_mount (TvmContext *context) return FALSE; } - +static gboolean +tvm_block_device_removable (TvmContext *context) +{ + /* traverse sysfs to find out if the device has the removable flag set */ + /* this would be much easier with udisks, but udisks2 dropped the udev */ + /* property settings... */ + const gchar *partn; + gchar *devpath; + gchar *removable; + gboolean ret = TRUE; /* default to handling the device */ + partn = g_udev_device_get_property (context->device, "PARTN"); + devpath = g_strdup(g_udev_device_get_property (context->device, "DEVPATH")); + if (! devpath) + goto out; + if (partn) + { /* partition, one directory up */ + gchar *p = strrchr(devpath, '/'); + if (! p) + goto out; + *p = 0; + } + removable = g_strdup_printf("/sys%s/removable", devpath); + if (removable) + { + gchar *contents; + if (g_file_get_contents(removable, &contents, NULL, NULL)) + { + ret = (*contents == '1'); + g_free (contents); + } + else + g_message("%s: g_file_get_contents of %s failed", __func__, removable); + g_free(removable); + } +out: + g_free(devpath); + return ret; +} void tvm_block_device_added (TvmContext *context) @@ -763,11 +800,13 @@ tvm_block_device_added (TvmContext *context) const gchar *id_type; const gchar *media_state; const gchar *id_fs_usage; + const gchar *udisks_nopolicy; gboolean is_cdrom; gboolean is_partition; gboolean is_volume; gboolean automount; gboolean autoplay; + gboolean u_nopolicy; guint64 audio_tracks; guint64 data_tracks; GError *error = NULL; @@ -779,12 +818,28 @@ tvm_block_device_added (TvmContext *context) devtype = g_udev_device_get_property (context->device, "DEVTYPE"); id_type = g_udev_device_get_property (context->device, "ID_TYPE"); id_fs_usage = g_udev_device_get_property (context->device, "ID_FS_USAGE"); + udisks_nopolicy = g_udev_device_get_property (context->device, "UDISKS_PRESENTATION_NOPOLICY"); /* distinguish device types */ is_cdrom = (g_strcmp0 (id_type, "cd") == 0); is_partition = (g_strcmp0 (devtype, "partition") == 0); is_volume = (g_strcmp0 (devtype, "disk") == 0) && (g_strcmp0 (id_fs_usage, "filesystem") == 0); + u_nopolicy = (g_strcmp0 (udisks_nopolicy, "1") == 0); + + /* if udisks properties are avaible, use them; if not, check the removable flag in sysfs */ + if (udisks_nopolicy == NULL && !tvm_block_device_removable(context)) + { + g_message("%s: non-removable device ignored", __func__); + tvm_device_handler_finished (context); + return; + } + if (u_nopolicy) + { + g_message("%s: ignoring device with UDISKS_PRESENTATION_NOPOLICY=1", __func__); + tvm_device_handler_finished (context); + return; + } if (is_cdrom) {
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor