[gvfs] gdu volume monitor: Mark bootable mounts as such



commit d39d6ef1cc600799dc6e5d17ffb4f01e9d7448ec
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Sep 15 04:25:50 2011 +0300

    gdu volume monitor: Mark bootable mounts as such
    
    Add appropriate content-type for bootable mounts. Although 'bootability'
    information is coming from libosinfo[1], we are not adding a dependency
    on it with this patch since libosinfo sets a boolean property on the udev
    device for us. We can then just query that property using gudev.
    
    [1] https://fedorahosted.org/libosinfo/
    
    https://bugzilla.gnome.org/show_bug.cgi?id=659109

 monitor/gdu/Makefile.am |    2 ++
 monitor/gdu/ggdumount.c |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/monitor/gdu/Makefile.am b/monitor/gdu/Makefile.am
index cb64944..c9c9195 100644
--- a/monitor/gdu/Makefile.am
+++ b/monitor/gdu/Makefile.am
@@ -18,6 +18,7 @@ gvfs_gdu_volume_monitor_CFLAGS =		\
 	-I$(top_srcdir)/monitor/proxy           \
 	$(GLIB_CFLAGS)                          \
 	$(GDU_CFLAGS)                           \
+	$(GUDEV_CFLAGS)                         \
 	$(DBUS_CFLAGS)                          \
 	-DGIO_MODULE_DIR=\"$(GIO_MODULE_DIR)\"	\
 	-DGVFS_LOCALEDIR=\""$(localedir)"\"	\
@@ -31,6 +32,7 @@ gvfs_gdu_volume_monitor_LDFLAGS =	\
 gvfs_gdu_volume_monitor_LDADD  =		     			      	\
 	$(GLIB_LIBS)                                 			      	\
 	$(GDU_LIBS)                                  			      	\
+	$(GUDEV_LIBS)                                  			      	\
 	$(DBUS_LIBS)                                 				\
 	$(top_builddir)/common/libgvfscommon.la 			      	\
 	$(top_builddir)/monitor/proxy/libgvfsproxyvolumemonitordaemon-noin.la 	\
diff --git a/monitor/gdu/ggdumount.c b/monitor/gdu/ggdumount.c
index 83c1847..b7e8545 100644
--- a/monitor/gdu/ggdumount.c
+++ b/monitor/gdu/ggdumount.c
@@ -34,6 +34,10 @@
 
 #include <gvfsmountinfo.h>
 
+#ifdef HAVE_GUDEV
+#include <gudev/gudev.h>
+#endif
+
 #include "ggduvolumemonitor.h"
 #include "ggdumount.h"
 #include "ggduvolume.h"
@@ -1362,6 +1366,35 @@ g_gdu_mount_guess_content_type_sync (GMount              *_mount,
         }
     }
 
+#ifdef HAVE_GUDEV
+  /* Check if its bootable */
+  if (device != NULL)
+    {
+      const gchar *device_file;
+
+      device_file = gdu_device_get_device_file (device);
+      if (device_file != NULL)
+        {
+          GUdevClient *client;
+          GUdevDevice *gudev_device;
+          const gchar *subsystems[] = {"block", NULL};
+
+          client = g_udev_client_new (subsystems);
+          gudev_device = g_udev_client_query_by_device_file (client, device_file);
+          if (gudev_device != NULL)
+            {
+              if (g_udev_device_get_property_as_boolean (gudev_device,
+                                                         "OSINFO_BOOTABLE"))
+                  g_ptr_array_add (p, g_strdup ("x-content/bootable-media"));
+
+              g_object_unref (gudev_device);
+            }
+
+          g_object_unref (client);
+        }
+    }
+#endif
+
   if (p->len == 0)
     {
       result = NULL;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]