[virt-tools-list] [libosinfo 2/2] Add Udev support

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Mon Aug 29 20:30:14 UTC 2011


From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>

If enabled, provide a udev rule to listen to insertion/removal of
ISO9660 media and sets some helpful (to apps) properties on the device
if media is bootable.
---
 configure.ac            |    5 +++++
 data/95-osinfo.rules.in |   21 +++++++++++++++++++++
 data/Makefile.am        |   11 ++++++++++-
 3 files changed, 36 insertions(+), 1 deletions(-)
 create mode 100644 data/95-osinfo.rules.in

diff --git a/configure.ac b/configure.ac
index 324c0a1..32487d5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -93,6 +93,11 @@ if test "x$enable_introspection" != "xno" ; then
 fi
 AM_CONDITIONAL([WITH_GOBJECT_INTROSPECTION], [test "x$enable_introspection" = "xyes"])
 
+AC_ARG_ENABLE([udev],
+        AS_HELP_STRING([--enable-udev], [enable Udev support]),
+        [], [enable_udev=no])
+AM_CONDITIONAL([ENABLE_UDEV], [test "x$enable_udev" = "xyes"])
+
 AC_ARG_ENABLE([coverage],
         AS_HELP_STRING([--enable-coverage], [enable GCC code coverage]),
         [], [enable_coverage=no])
diff --git a/data/95-osinfo.rules.in b/data/95-osinfo.rules.in
new file mode 100644
index 0000000..c97491c
--- /dev/null
+++ b/data/95-osinfo.rules.in
@@ -0,0 +1,21 @@
+# USB flash drives
+ACTION=="add|remove", \
+ SUBSYSTEM=="block", \
+ ENV{ID_FS_TYPE}=="iso9660", \
+ IMPORT{program}="@bindir@/osinfo-detect -e $tempnode"
+
+# CDROMs
+
+# Disk inserted
+ACTION=="change", \
+ SUBSYSTEM=="block", \
+ ENV{ID_FS_TYPE}=="iso9660", \
+ IMPORT{program}="@bindir@/osinfo-detect -e $tempnode"
+
+# Disk ejected
+ACTION=="change", \
+ SUBSYSTEM=="block", \
+ ENV{ID_FS_TYPE}!="iso9660", \
+ OSINFO_BOOTABLE="", \
+ OSINFO_INSTALLER=""
+
diff --git a/data/Makefile.am b/data/Makefile.am
index 657916a..c49abed 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,11 +1,20 @@
 
 SUBDIRS = devices oses hypervisors
 
-EXTRA_DIST = usb.ids pci.ids
+EXTRA_DIST = usb.ids pci.ids $(udev_DATA)
 
 databasedir = $(pkgdatadir)/data/
 database_DATA = usb.ids pci.ids
 
+if ENABLE_UDEV
+udevdir = /lib/udev/rules.d/
+udev_DATA = 95-osinfo.rules
+BUILT_SOURCES = 95-osinfo.rules
+
+95-osinfo.rules: 95-osinfo.rules.in
+	sed 's,\@bindir\@,$(exec_prefix)/bin,' 95-osinfo.rules.in > 95-osinfo.rules
+endif
+
 CLEANFILES = usb.ids pci.ids
 
 usb.ids:
-- 
1.7.6




More information about the virt-tools-list mailing list