[Top][All Lists]

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

stopping libparted exceptions from aborting program

From: Michael Katzmann
Subject: stopping libparted exceptions from aborting program
Date: Mon, 8 Aug 2011 19:58:32 -0400

I have a program that formats USB drives upon insertion. It creates a thread for each drive that's inserted and can have multiple drives formatting at any time.

If a drive is removed or an error occurs libparted causes the whole program aborts with a backtrace(3)
How can I tell libparted to have the libparted routine just return with an error rather than aborting the program.

I can setup the exception handler but no matter what I return it still aborts (and I can't find out what thread called the exception).

Any help appreciated !

char sSCSIDevice[] = "/dev/sdc";  //eg only

PedExceptionOption libpartedExceptionHandler();

ped_exception_set_handler( libpartedExceptionHandler );
bWriteError = TRUE;
#define VAL(x) { if( (x)==0 ) goto PartedError; }
VAL( Device = ped_device_get( sSCSIDevice ) )
VAL( Disk = ped_disk_new_fresh( Device, ped_disk_type_get("msdos") ) )
VAL( FStype = ped_file_system_type_get("fat32") )
VAL( Partition = ped_partition_new( Disk, PED_PARTITION_NORMAL, FStype, 1, Device->length-1 ) )
VAL( rtn = ped_disk_add_partition( Disk, Partition, ped_constraint_new_from_max( &Partition->geom ) ) )
VAL( FS  = ped_file_system_create( &Partition->geom, FStype, NULL ) )
VAL( rtn = ped_disk_commit_to_dev( Disk ) )
VAL( rtn = ped_disk_commit_to_os( Disk ) )
bWriteError = FALSE;
ped_device_close( Device );
if( bWriteError )
goto WriteExit;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]