Hi,

I just created a patch for gparted to improve things slightly:

  * Add debian/patches/02_fdi_robustification.patch:
    - Install a signal handler for cleaning up the automount disabling FDI, so
      that it will be cleaned up on program crashes, too.
    - Use storage.automount_enabled_hint instead of volume.ignore for the
      automount disabling FDI. That way, the new drives will at least appear
      in Gnome and the user can mount them manually.
    - LP: #134712

I also sent this patch to Gnome #324220.

Additionally, I'll change the hal init script to delete this file on
startup. Yes, I know, a hack, but until hal offers a proper native
interface for temporarily disabling automount, this will have to do.


Martin

-- 
Martin Pitt        http://www.piware.de
Ubuntu Developer   http://www.ubuntu.com
Debian Developer   http://www.debian.org
diff -Nur gparted-0.3.3/src/GParted_Core.cc gparted-0.3.3.new/src/GParted_Core.cc
--- gparted-0.3.3/src/GParted_Core.cc	2006-12-05 20:39:31.000000000 +0100
+++ gparted-0.3.3.new/src/GParted_Core.cc	2007-10-01 08:34:03.000000000 +0200
@@ -38,6 +38,8 @@
 #include "../include/ufs.h"
 
 #include <cerrno>
+#include <cstdio>
+#include <csignal>
 #include <sys/statvfs.h>	
 
 std::vector<Glib::ustring> libparted_messages ; //see ped_exception_handler()
@@ -45,6 +47,13 @@
 namespace GParted
 {
 
+// Clean up the fdi when terminating
+void sig_fdi_cleanup( int signum )
+{
+	remove( "/usr/share/hal/fdi/policy/gparted-disable-automount.fdi" );
+	raise( signum );
+}
+
 GParted_Core::GParted_Core() 
 {
 	lp_device = NULL ;
@@ -53,6 +62,29 @@
 	p_filesystem = NULL ;
 
 	ped_exception_set_handler( ped_exception_handler ) ; 
+
+	//make sure that the fdi is cleaned up on all but the most forceful
+	//program exits
+	struct sigaction sa;
+	sa.sa_handler = sig_fdi_cleanup;
+	sigemptyset( &sa.sa_mask );
+	sa.sa_flags = SA_RESETHAND;
+	if( sigaction( SIGHUP, &sa, NULL ) == -1 ||
+	    sigaction( SIGINT, &sa, NULL ) == -1 ||
+	    sigaction( SIGQUIT, &sa, NULL ) == -1 ||
+	    sigaction( SIGILL, &sa, NULL ) == -1 ||
+	    sigaction( SIGABRT, &sa, NULL ) == -1 ||
+	    sigaction( SIGFPE, &sa, NULL ) == -1 ||
+	    sigaction( SIGSEGV, &sa, NULL ) == -1 ||
+	    sigaction( SIGPIPE, &sa, NULL ) == -1 ||
+	    sigaction( SIGALRM, &sa, NULL ) == -1 ||
+	    sigaction( SIGTERM, &sa, NULL ) == -1 ||
+	    sigaction( SIGUSR1, &sa, NULL ) == -1 ||
+	    sigaction( SIGUSR2, &sa, NULL ) == -1 ||
+	    sigaction( SIGBUS, &sa, NULL ) == -1 ||
+	    sigaction( SIGXCPU, &sa, NULL ) == -1 ||
+	    sigaction( SIGXFSZ, &sa, NULL ) == -1 )
+		perror( "Could not set signal handler" );
 	
 	//disable automount //FIXME: temporary hack, till i find a better solution...
 	std::ofstream fdi_file( "/usr/share/hal/fdi/policy/gparted-disable-automount.fdi" ) ;
@@ -60,8 +92,8 @@
 	{
 		fdi_file << "<deviceinfo version='0.2'>" ;
 		fdi_file << "<device>" ;
-		fdi_file << "<match key='@block.storage_device:storage.hotpluggable' bool='true'>" ;
-		fdi_file << "<merge key='volume.ignore' type='bool'>true</merge>" ;
+		fdi_file << "<match key='storage.hotpluggable' bool='true'>" ;
+		fdi_file << "<merge key='storage.automount_enabled_hint' type='bool'>false</merge>" ;
 		fdi_file << "</match>" ;
 		fdi_file << "</device>" ;
 		fdi_file << "</deviceinfo>" ;

Attachment: signature.asc
Description: Digital signature

Reply via email to