Fixed bug #324220 with the following changes:

- Removed gparted-disable-automount.fdi handling.
- Renamed gparted binary to gpartedbin to permit a calling script to be named gparted.
- Added new calling script gparted.in to permit using hal-lock to acuiqre device locks to prevent automounting while executing gpartedbin.
- Renamed gparted.desktop.in to gparted.desktop.in.in to permit parsing installdir.

svn path=/trunk/; revision=826
This commit is contained in:
Curtis Gedak 2008-04-21 15:22:00 +00:00
parent 1eb4e1aea5
commit 605e1f4cdc
9 changed files with 81 additions and 58 deletions

View File

@ -1,3 +1,28 @@
2008-04-21 Curtis Gedak <gedakc@gmail.com>
* Makefile.am: Enhanced for new calling script gparted
- Added gparted script installation in sbin
- Added installdir parsing for gparted and gparted.desktop
* gparted.desktop.in: Renamed gparted.desktop.in
to gparted.desktop.in.in
- This is to permit installdir parsing in gparted.desktop
* gparted.in: Added new calling script gparted
- This is to permit using hal-lock to acquire device
locks to prevent automounting prior to executing gpartedbin.
- Closes GParted bug #324220
* src/GParted_Core.cc: Removed gparted-disable-automount.fdi handling
- Removed signal handler patch from 2008-01-28
- Removed initial work on disabling automount from 2006-08-09
- /usr/share/hal/fdi/policy/gparted-disable-automount.fdi is
no longer created.
- This is to permit preferred alternative of using hal-lock.
* src/Makefile.am: Renamed gparted binary to gpartedbin
- This is to permit a calling script to be named gparted.
2008-04-20 Curtis Gedak <gedakc@gmail.com> 2008-04-20 Curtis Gedak <gedakc@gmail.com>
* src/Dialog_Disklabel.cc: Improved ability to translate text * src/Dialog_Disklabel.cc: Improved ability to translate text

View File

@ -2,18 +2,32 @@ SUBDIRS = compose doc include pixmaps po src
@INTLTOOL_DESKTOP_RULE@ @INTLTOOL_DESKTOP_RULE@
DESKTOP_IN_IN_FILES = gparted.desktop.in.in
DESKTOP_IN_FILES = gparted.desktop.in DESKTOP_IN_FILES = gparted.desktop.in
DESKTOP_FILES =$(DESKTOP_IN_FILES:.desktop.in=.desktop) DESKTOP_FILES =$(DESKTOP_IN_FILES:.desktop.in=.desktop)
desktopdir = $(datadir)/applications desktopdir = $(datadir)/applications
desktop_DATA = $(DESKTOP_FILES) desktop_DATA = $(DESKTOP_FILES)
sbin_SCRIPTS = gparted
CLEANFILES = $(sbin_SCRIPTS) $(DESKTOP_IN_FILES)
do_subst = sed -e 's,[@]installdir[@],$(sbindir),g'
gparted.desktop.in: gparted.desktop.in.in Makefile
$(do_subst) < $(srcdir)/gparted.desktop.in.in > gparted.desktop.in
gparted: gparted.in Makefile
$(do_subst) < $(srcdir)/gparted.in > gparted
chmod +x gparted
EXTRA_DIST = \ EXTRA_DIST = \
$(DESKTOP_IN_FILES) \ $(DESKTOP_IN_IN_FILES) \
$(DESKTOP_FILES) \ $(DESKTOP_FILES) \
intltool-extract.in \ intltool-extract.in \
intltool-merge.in \ intltool-merge.in \
intltool-update.in intltool-update.in \
gparted.in
DISTCLEANFILES = \ DISTCLEANFILES = \
intltool-extract \ intltool-extract \

View File

@ -1,7 +1,7 @@
[Desktop Entry] [Desktop Entry]
_Name=GParted Partition Editor _Name=GParted Partition Editor
_Comment=Create, reorganize, and delete partitions _Comment=Create, reorganize, and delete partitions
Exec=gksu gparted Exec=gksu @installdir@/gparted
Icon=gparted Icon=gparted
Terminal=false Terminal=false
Type=Application Type=Application

23
gparted.in Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
#
# Purpose: Acquire device locks prior to running gparted.
# This is to prevent devices from being automounted.
# File system problems can occur if devices are mounted
# prior to the completion of GParted's operations.
# See GParted bug #324220
# http://bugzilla.gnome.org/show_bug.cgi?id=324220
#
#
# Following is a quote from HAL 0.5.10 Specification.
# http://people.freedesktop.org/~david/hal-spec/hal-spec.html#locking-guidelines
#
# In order to prevent HAL-based automounters from mounting partitions
# that are being prepared, applications that access block devices
# directly (and pokes the kernel to reload the partitioning table)
# should lock out automounters by either a) obtaining the
# org.freedesktop.Hal.Device.Storage lock on each drive being processed;
# or b) obtaining the global org.freedesktop.Hal.Device.Storage lock.
#
hal-lock --interface org.freedeskdesktop.Hal.Device.Storage --exclusive \
--run @installdir@/gpartedbin $*

View File

@ -1,3 +1,10 @@
2008-04-21 Curtis Gedak <gedakc@gmail.com>
* POTFILES.skip: Created file and added gparted.desktop.in
* POTFILES.in: Renamed gparted.desktop.in to gparted.desktop.in.in
- This is to permit parsing of installdir for gparted.desktop
2008-04-20 Vincent van Adrighem <adrighem@gnome.org> 2008-04-20 Vincent van Adrighem <adrighem@gnome.org>
* nl.po: Translation updated by Tino Meinen. * nl.po: Translation updated by Tino Meinen.

View File

@ -1,6 +1,6 @@
# List of source files containing translatable strings. # List of source files containing translatable strings.
# Please keep this file sorted alphabetically. # Please keep this file sorted alphabetically.
gparted.desktop.in gparted.desktop.in.in
src/Dialog_Base_Partition.cc src/Dialog_Base_Partition.cc
src/Dialog_Disklabel.cc src/Dialog_Disklabel.cc
src/Dialog_Partition_Copy.cc src/Dialog_Partition_Copy.cc

4
po/POTFILES.skip Normal file
View File

@ -0,0 +1,4 @@
# List of source files containing translatable strings, but should be skipped.
# Please keep this file sorted alphabetically.
gparted.desktop.in

View File

@ -39,8 +39,6 @@
#include "../include/ufs.h" #include "../include/ufs.h"
#include <cerrno> #include <cerrno>
#include <cstdio>
#include <csignal>
#include <sys/statvfs.h> #include <sys/statvfs.h>
std::vector<Glib::ustring> libparted_messages ; //see ped_exception_handler() std::vector<Glib::ustring> libparted_messages ; //see ped_exception_handler()
@ -48,13 +46,6 @@ std::vector<Glib::ustring> libparted_messages ; //see ped_exception_handler()
namespace GParted 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() GParted_Core::GParted_Core()
{ {
lp_device = NULL ; lp_device = NULL ;
@ -64,44 +55,6 @@ GParted_Core::GParted_Core()
ped_exception_set_handler( ped_exception_handler ) ; 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" ) ;
if ( fdi_file )
{
fdi_file << "<deviceinfo version='0.2'>" ;
fdi_file << "<device>" ;
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>" ;
fdi_file .close() ;
}
//get valid flags ... //get valid flags ...
for ( PedPartitionFlag flag = ped_partition_flag_next( static_cast<PedPartitionFlag>( NULL ) ) ; for ( PedPartitionFlag flag = ped_partition_flag_next( static_cast<PedPartitionFlag>( NULL ) ) ;
flag ; flag ;
@ -2371,9 +2324,6 @@ GParted_Core::~GParted_Core()
{ {
if ( p_filesystem ) if ( p_filesystem )
delete p_filesystem ; delete p_filesystem ;
//remove .fdi file..
remove( "/usr/share/hal/fdi/policy/gparted-disable-automount.fdi" ) ;
} }
} //GParted } //GParted

View File

@ -7,9 +7,9 @@ AM_CFLAGS = -Wall
AM_CXXFLAGS = -Wall AM_CXXFLAGS = -Wall
sbin_PROGRAMS = gparted sbin_PROGRAMS = gpartedbin
gparted_SOURCES = \ gpartedbin_SOURCES = \
Device.cc \ Device.cc \
Dialog_Base_Partition.cc \ Dialog_Base_Partition.cc \
Dialog_Disklabel.cc \ Dialog_Disklabel.cc \
@ -55,7 +55,7 @@ gparted_SOURCES = \
ufs.cc \ ufs.cc \
xfs.cc xfs.cc
gparted_LDFLAGS = -lparted -lgthread-2.0 gpartedbin_LDFLAGS = -lparted -lgthread-2.0
gparted_LDADD = $(GTKMM_LIBS) gpartedbin_LDADD = $(GTKMM_LIBS)