diff options
author | Tomas Bzatek <tbzatek@redhat.com> | 2009-04-22 17:52:11 +0200 |
---|---|---|
committer | Tomas Bzatek <tbzatek@redhat.com> | 2009-04-27 15:06:36 +0200 |
commit | 4f21a995a67bcdf54a0874416f920232d936f9de (patch) | |
tree | 225643b81978ca32e951d5386f007efa677ab48d | |
parent | a94e16504ba76796caed8ea74448a534fa900a9e (diff) | |
download | gnome-disk-utility-4f21a995a67bcdf54a0874416f920232d936f9de.tar.gz gnome-disk-utility-4f21a995a67bcdf54a0874416f920232d936f9de.tar.xz gnome-disk-utility-4f21a995a67bcdf54a0874416f920232d936f9de.zip |
double-check for valid presentable
-rw-r--r-- | src/gdu-nautilus-extension/nautilus-gdu.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/gdu-nautilus-extension/nautilus-gdu.c b/src/gdu-nautilus-extension/nautilus-gdu.c index 8809377..0d41b2a 100644 --- a/src/gdu-nautilus-extension/nautilus-gdu.c +++ b/src/gdu-nautilus-extension/nautilus-gdu.c @@ -47,6 +47,33 @@ static GType nautilus_gdu_type = 0; #define G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE "mountable::unix-device-file" +/* test if we're able to correctly find presentable from a device file */ +static gboolean +test_proper_device (char *device_file) +{ + GduPool *pool; + GduDevice *device; + GduPresentable *presentable = NULL; + gboolean res = FALSE; + + if (device_file == NULL || strlen (device_file) <= 1) + return FALSE; + + pool = gdu_pool_new (); + device = gdu_pool_get_by_device_file (pool, device_file); + if (device) { + presentable = gdu_pool_get_volume_by_device (pool, device); + if (presentable) { + res = TRUE; + g_object_unref (presentable); + } + g_object_unref (device); + } + g_object_unref (pool); + + return res; +} + /* caller must unref the returned string */ static char * find_device_from_nautilus_file (NautilusFileInfo *nautilus_file) @@ -93,7 +120,10 @@ find_device_from_nautilus_file (NautilusFileInfo *nautilus_file) } } - g_print ("nautilus-gdu: matching device %s\n", device_file); + if (! test_proper_device (device_file)) { + g_free (device_file); + return FALSE; + } return device_file; } |