Add support for setting UUID (#667278)

Add the ability to set a new random UUID on file systems that provide
the appropriate tools to perform this action.

Update the help manual to include this new functionality.  Also add
reference links to "setting a partition label" and "changing a
partition UUID" in the "copying and pasting a partition" section.

This patch does not include setting the UUID on an NTFS file system.

Bug #667278 - Add support for setting UUID

Bug #608308 - fix documentation - Copying and Pasting a Partition
This commit is contained in:
Rogier Goossens 2012-01-22 13:49:52 -07:00 committed by Curtis Gedak
parent c9c045ed3f
commit 9e96159bb2
50 changed files with 770 additions and 8 deletions

View File

@ -1116,6 +1116,32 @@
</para>
</sect3>
<!-- ============= To Change a Partition's UUID ========================== -->
<sect3 id="gparted-changing-partition-uuid">
<title>Changing a Partition UUID</title>
<para>
To change the UUID of a partition:
<orderedlist>
<listitem>
<para>
Select an unmounted partition.
See <xref linkend="gparted-select-partition"/>.
</para>
</listitem>
<listitem>
<para>
Choose:
<menuchoice><guimenu>Partition</guimenu>
<guimenuitem>New UUID</guimenuitem></menuchoice>.
The application displays the set a new random UUID
operation in the <guilabel>Operations Pending</guilabel>
pane.
</para>
</listitem>
</orderedlist>
</para>
</sect3>
<!-- ============= Specifying Partition Details ====================== -->
<sect3 id="gparted-specify-partition-details">
<title>Specifying Partition Details</title>
@ -1650,8 +1676,12 @@
<listitem>
<para>
Change the UUID of the partition.
See <xref linkend="gparted-changing-partition-uuid"/>.
</para>
<para>
If the partition label is not blank, change the label
of the partition.
See <xref linkend="gparted-setting-partition-label"/>.
</para>
</listitem>
<listitem>

View File

@ -56,6 +56,7 @@ private:
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > copy ;
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > check ;
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > label ;
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > uuid ;
Gtk::TreeModelColumn<Glib::ustring> software ;
treeview_filesystems_Columns()
@ -68,6 +69,7 @@ private:
add( copy ) ;
add( check ) ;
add( label ) ;
add( uuid ) ;
add( software ) ;
}
};

View File

@ -38,6 +38,8 @@ public:
virtual void set_used_sectors( Partition & partition ) = 0 ;
virtual void read_label( Partition & partition ) = 0 ;
virtual bool write_label( const Partition & partition, OperationDetail & operationdetail ) = 0 ;
virtual void read_uuid( Partition & partition ) = 0 ;
virtual bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) = 0 ;
virtual bool create( const Partition & new_partition, OperationDetail & operationdetail ) = 0 ;
virtual bool resize( const Partition & partition_new,
OperationDetail & operationdetail,

View File

@ -71,6 +71,7 @@ private:
void set_device_partitions( Device & device ) ;
GParted::FILESYSTEM get_filesystem() ;
void read_label( Partition & partition ) ;
void read_uuid( Partition & partition ) ;
void insert_unallocated( const Glib::ustring & device_path,
std::vector<Partition> & partitions,
Sector start,
@ -95,6 +96,8 @@ private:
bool label_partition( const Partition & partition, OperationDetail & operation_detail ) ;
bool change_uuid( const Partition & partition, OperationDetail & operation_detail ) ;
bool resize_move( const Device & device,
const Partition & partition_old,
Partition & partition_new,

View File

@ -29,6 +29,7 @@ EXTRA_DIST = \
OperationDetail.h \
OperationFormat.h \
OperationResizeMove.h \
OperationChangeUUID.h \
OperationLabelPartition.h \
Partition.h \
Proc_Partitions_Info.h \

View File

@ -32,7 +32,8 @@ enum OperationType {
OPERATION_RESIZE_MOVE = 3,
OPERATION_FORMAT = 4,
OPERATION_COPY = 5,
OPERATION_LABEL_PARTITION = 6
OPERATION_LABEL_PARTITION = 6,
OPERATION_CHANGE_UUID = 7
};
class Operation

View File

@ -0,0 +1,42 @@
/* Copyright (C) 2012 Rogier Goossens
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef OPERATIONCHANGEUUID_H_
#define OPERATIONCHANGEUUID_H_
#include "../include/Operation.h"
namespace GParted
{
class OperationChangeUUID : public Operation
{
public:
OperationChangeUUID( const Device & device
, const Partition & partition_orig
, const Partition & partition_new
) ;
void apply_to_visual( std::vector<Partition> & partitions ) ;
private:
void create_description() ;
} ;
} //GParted
#endif //OPERATIONCHANGEUUID_H_

View File

@ -34,6 +34,8 @@
#include <ctime>
#include <vector>
#define UUID_STRING_LENGTH 36
namespace GParted
{
@ -106,6 +108,8 @@ struct FS
Support read ; //can we get the amount of used sectors?
Support read_label ;
Support write_label ;
Support read_uuid ;
Support write_uuid ;
Support create ;
Support grow ;
Support shrink ;
@ -118,7 +122,7 @@ struct FS
FS()
{
read = read_label = write_label = create = grow = shrink = move = check = copy = NONE;
read = read_label = write_label = read_uuid = write_uuid = create = grow = shrink = move = check = copy = NONE;
MIN = MAX = 0 ;
}
} ;
@ -163,6 +167,7 @@ public:
std::vector<Glib::ustring>& tokens,
const Glib::ustring& delimiters ) ;
static int convert_to_int(const Glib::ustring & src);
static Glib::ustring generate_uuid(void);
};

View File

@ -105,6 +105,9 @@ private:
void allow_label_partition( bool state ) {
toggle_item( state, MENU_LABEL_PARTITION ) ; }
void allow_change_uuid( bool state ) {
toggle_item( state, MENU_CHANGE_UUID ) ; }
void allow_info( bool state ) {
toggle_item( state, MENU_INFO ) ; }
@ -167,6 +170,7 @@ private:
void activate_attempt_rescue_data();
void activate_manage_flags() ;
void activate_check() ;
void activate_change_uuid() ;
void activate_label_partition() ;
void activate_undo();
@ -235,7 +239,8 @@ private:
MENU_MOUNT,
MENU_FLAGS,
MENU_CHECK,
MENU_LABEL_PARTITION,
MENU_LABEL_PARTITION,
MENU_CHANGE_UUID,
MENU_INFO,
TOOLBAR_UNDO,
TOOLBAR_APPLY ;

View File

@ -31,6 +31,8 @@ public:
void set_used_sectors( Partition & partition ) ;
void read_label( Partition & partition ) ;
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
void read_uuid( Partition & partition ) ;
bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool move( const Partition & partition_new

View File

@ -31,6 +31,8 @@ public:
void set_used_sectors( Partition & partition ) ;
void read_label( Partition & partition ) ;
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
void read_uuid( Partition & partition ) ;
bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new
, OperationDetail & operationdetail

View File

@ -32,6 +32,8 @@ public:
void set_used_sectors( Partition & partition ) ;
void read_label( Partition & partition ) ;
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
void read_uuid( Partition & partition ) ;
bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool move( const Partition & partition_new

View File

@ -32,6 +32,8 @@ public:
void set_used_sectors( Partition & partition ) ;
void read_label( Partition & partition ) ;
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
void read_uuid( Partition & partition ) ;
bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool move( const Partition & partition_new

View File

@ -31,6 +31,8 @@ public:
void set_used_sectors( Partition & partition ) ;
void read_label( Partition & partition ) ;
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
void read_uuid( Partition & partition ) ;
bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool move( const Partition & partition_new

View File

@ -32,6 +32,8 @@ public:
void set_used_sectors( Partition & partition ) ;
void read_label( Partition & partition ) ;
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
void read_uuid( Partition & partition ) ;
bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool move( const Partition & partition_new

View File

@ -32,6 +32,8 @@ public:
void set_used_sectors( Partition & partition ) ;
void read_label( Partition & partition ) ;
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
void read_uuid( Partition & partition ) ;
bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool move( const Partition & partition_new

View File

@ -32,6 +32,8 @@ public:
void set_used_sectors( Partition & partition ) ;
void read_label( Partition & partition ) ;
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
void read_uuid( Partition & partition ) ;
bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool move( const Partition & partition_new

View File

@ -32,6 +32,8 @@ public:
void set_used_sectors( Partition & partition ) ;
void read_label( Partition & partition ) ;
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
void read_uuid( Partition & partition ) ;
bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool move( const Partition & partition_new

View File

@ -32,6 +32,8 @@ public:
void set_used_sectors( Partition & partition ) ;
void read_label( Partition & partition ) ;
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
void read_uuid( Partition & partition ) ;
bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool move( const Partition & partition_new

View File

@ -32,6 +32,8 @@ public:
void set_used_sectors( Partition & partition ) ;
void read_label( Partition & partition ) ;
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
void read_uuid( Partition & partition ) ;
bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool move( const Partition & partition_new

View File

@ -31,6 +31,8 @@ public:
void set_used_sectors( Partition & partition ) ;
void read_label( Partition & partition ) ;
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
void read_uuid( Partition & partition ) ;
bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool move( const Partition & partition_new

View File

@ -32,6 +32,8 @@ public:
void set_used_sectors( Partition & partition ) ;
void read_label( Partition & partition ) ;
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
void read_uuid( Partition & partition ) ;
bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool move( const Partition & partition_new

View File

@ -32,6 +32,8 @@ public:
void set_used_sectors( Partition & partition ) ;
void read_label( Partition & partition ) ;
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
void read_uuid( Partition & partition ) ;
bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool move( const Partition & partition_new

View File

@ -32,6 +32,8 @@ public:
void set_used_sectors( Partition & partition ) ;
void read_label( Partition & partition ) ;
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
void read_uuid( Partition & partition ) ;
bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool move( const Partition & partition_new

View File

@ -32,6 +32,8 @@ public:
void set_used_sectors( Partition & partition ) ;
void read_label( Partition & partition ) ;
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
void read_uuid( Partition & partition ) ;
bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool move( const Partition & partition_new

View File

@ -32,6 +32,8 @@ public:
void set_used_sectors( Partition & partition ) ;
void read_label( Partition & partition ) ;
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
void read_uuid( Partition & partition ) ;
bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool move( const Partition & partition_new

View File

@ -16,6 +16,7 @@ src/DMRaid.cc
src/FileSystem.cc
src/GParted_Core.cc
src/HBoxOperations.cc
src/OperationChangeUUID.cc
src/OperationCopy.cc
src/OperationCheck.cc
src/OperationCreate.cc

View File

@ -40,6 +40,7 @@ DialogFeatures::DialogFeatures()
treeview_filesystems .append_column( _("Copy"), treeview_filesystems_columns .copy );
treeview_filesystems .append_column( _("Check"), treeview_filesystems_columns .check );
treeview_filesystems .append_column( _("Label"), treeview_filesystems_columns .label );
treeview_filesystems .append_column( _("UUID"), treeview_filesystems_columns .uuid );
treeview_filesystems .append_column( _("Required Software"), treeview_filesystems_columns .software );
treeview_filesystems .get_selection() ->set_mode( Gtk::SELECTION_NONE );
treeview_filesystems .set_rules_hint( true ) ;
@ -145,6 +146,7 @@ void DialogFeatures::show_filesystem( const FS & fs )
treerow[ treeview_filesystems_columns .copy ] = fs .copy ? icon_yes : icon_no ;
treerow[ treeview_filesystems_columns .check ] = fs .check ? icon_yes : icon_no ;
treerow[ treeview_filesystems_columns .label ] = fs .write_label ? icon_yes : icon_no ;
treerow[ treeview_filesystems_columns .uuid ] = fs .write_uuid ? icon_yes : icon_no ;
treerow[ treeview_filesystems_columns .software ] = Utils::get_filesystem_software( fs .filesystem ) ;
}

View File

@ -26,6 +26,7 @@
#include "../include/OperationDelete.h"
#include "../include/OperationFormat.h"
#include "../include/OperationResizeMove.h"
#include "../include/OperationChangeUUID.h"
#include "../include/OperationLabelPartition.h"
#include "../include/Proc_Partitions_Info.h"
@ -631,6 +632,9 @@ bool GParted_Core::apply_operation_to_disk( Operation * operation )
case OPERATION_LABEL_PARTITION:
succes = label_partition( operation ->partition_new, operation ->operation_detail ) ;
break ;
case OPERATION_CHANGE_UUID:
succes = change_uuid( operation ->partition_new, operation ->operation_detail ) ;
break ;
}
if ( libparted_messages .size() > 0 )
@ -1010,7 +1014,13 @@ void GParted_Core::set_device_partitions( Device & device )
bool label_found = false ;
partition_temp .label = fs_info .get_label( partition_temp .get_path(), label_found ) ;
}
partition_temp .uuid = fs_info .get_uuid( partition_temp .get_path() ) ;
//Retrieve file system UUID
read_uuid( partition_temp ) ;
if ( partition_temp .uuid .empty() )
{
partition_temp .uuid = fs_info .get_uuid( partition_temp .get_path() ) ;
}
}
partition_temp .messages .insert( partition_temp .messages .end(),
@ -1250,6 +1260,23 @@ void GParted_Core::read_label( Partition & partition )
}
}
void GParted_Core::read_uuid( Partition & partition )
{
if ( partition .type != TYPE_EXTENDED )
{
switch( get_fs( partition .filesystem ) .read_uuid )
{
case FS::EXTERNAL:
if ( set_proper_filesystem( partition .filesystem ) )
p_filesystem ->read_uuid( partition ) ;
break ;
default:
break ;
}
}
}
void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
std::vector<Partition> & partitions,
Sector start,
@ -1731,6 +1758,33 @@ bool GParted_Core::label_partition( const Partition & partition, OperationDetail
return succes ;
}
bool GParted_Core::change_uuid( const Partition & partition, OperationDetail & operationdetail )
{
operationdetail .add_child( OperationDetail( String::ucompose(
_("Set UUID on %1 to a new, random value"),
partition .get_path()
) ) ) ;
bool succes = false ;
if ( partition .type != TYPE_EXTENDED )
{
switch( get_fs( partition .filesystem ) .write_uuid )
{
case FS::EXTERNAL:
succes = set_proper_filesystem( partition .filesystem ) &&
p_filesystem ->write_uuid( partition, operationdetail .get_last_child() ) ;
break ;
default:
break;
}
}
operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
return succes ;
}
bool GParted_Core::resize_move( const Device & device,
const Partition & partition_old,
Partition & partition_new,

View File

@ -32,6 +32,7 @@ gpartedbin_SOURCES = \
GParted_Core.cc \
HBoxOperations.cc \
Operation.cc \
OperationChangeUUID.cc \
OperationCopy.cc \
OperationCheck.cc \
OperationCreate.cc \

View File

@ -0,0 +1,65 @@
/* Copyright (C) 2012 Rogier Goossens
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "../include/OperationChangeUUID.h"
namespace GParted
{
OperationChangeUUID::OperationChangeUUID( const Device & device
, const Partition & partition_orig
, const Partition & partition_new
)
{
type = OPERATION_CHANGE_UUID ;
this ->device = device ;
this ->partition_original = partition_orig ;
this ->partition_new = partition_new ;
}
void OperationChangeUUID::apply_to_visual( std::vector<Partition> & partitions )
{
if ( partition_original .inside_extended )
{
index_extended = find_index_extended( partitions ) ;
if ( index_extended >= 0 )
index = find_index_original( partitions[ index_extended ] .logicals ) ;
if ( index >= 0 )
partitions[ index_extended ] .logicals[ index ] = partition_new ;
}
else
{
index = find_index_original( partitions ) ;
if ( index >= 0 )
partitions[ index ] = partition_new ;
}
}
void OperationChangeUUID::create_description()
{
/*TO TRANSLATORS: looks like Set a new random UUID on ext4 file system on /dev/sda1 */
description = String::ucompose( _("Set a new random UUID on %1 file system on %2")
, Utils::get_filesystem_string( partition_new .filesystem )
, partition_new .get_path()
) ;
}
} //GParted

View File

@ -23,6 +23,7 @@
#include <iomanip>
#include <glibmm/regex.h>
#include <locale.h>
#include <uuid/uuid.h>
namespace GParted
@ -553,5 +554,17 @@ int Utils::convert_to_int(const Glib::ustring & src)
return ret_val;
}
// Create a new UUID
Glib::ustring Utils::generate_uuid(void)
{
uuid_t uuid;
char uuid_str[UUID_STRING_LENGTH+1];
uuid_generate(uuid);
uuid_unparse(uuid,uuid_str);
return uuid_str;
}
} //GParted..

View File

@ -33,6 +33,7 @@
#include "../include/OperationDelete.h"
#include "../include/OperationFormat.h"
#include "../include/OperationResizeMove.h"
#include "../include/OperationChangeUUID.h"
#include "../include/OperationLabelPartition.h"
#include "../config.h"
@ -65,6 +66,7 @@ Win_GParted::Win_GParted( const std::vector<Glib::ustring> & user_devices )
MENU_FLAGS =
MENU_INFO =
MENU_LABEL_PARTITION =
MENU_CHANGE_UUID =
TOOLBAR_UNDO =
TOOLBAR_APPLY = -1 ;
@ -381,6 +383,11 @@ void Win_GParted::init_partition_menu()
sigc::mem_fun( *this, &Win_GParted::activate_label_partition ) ) );
MENU_LABEL_PARTITION = index++ ;
menu_partition .items() .push_back(
Gtk::Menu_Helpers::MenuElem( _("New UU_ID"),
sigc::mem_fun( *this, &Win_GParted::activate_change_uuid ) ) );
MENU_CHANGE_UUID = index++ ;
menu_partition .items() .push_back( Gtk::Menu_Helpers::SeparatorElem() ) ;
index++ ;
@ -678,6 +685,7 @@ void Win_GParted::Add_Operation( Operation * operation, int index )
if ( operation ->type == OPERATION_DELETE ||
operation ->type == OPERATION_FORMAT ||
operation ->type == OPERATION_CHECK ||
operation ->type == OPERATION_CHANGE_UUID ||
operation ->type == OPERATION_LABEL_PARTITION ||
gparted_core .snap_to_alignment( operation ->device, operation ->partition_new, error )
)
@ -753,6 +761,20 @@ bool Win_GParted::Merge_Operations( unsigned int first, unsigned int second )
return true;
}
// Two change-uuid change operations on the same partition
else if ( operations[ first ]->type == OPERATION_CHANGE_UUID &&
operations[ second ]->type == OPERATION_CHANGE_UUID &&
operations[ first ]->partition_new == operations[ second ]->partition_original
)
{
operations[ first ]->partition_new.uuid = operations[ second ]->partition_new.uuid;
operations[ first ]->create_description() ;
remove_operation( second );
Refresh_Visual();
return true;
}
// Two check operations of the same partition
else if ( operations[ first ]->type == OPERATION_CHECK &&
operations[ second ]->type == OPERATION_CHECK &&
@ -879,7 +901,7 @@ void Win_GParted::set_valid_operations()
allow_new( false ); allow_delete( false ); allow_resize( false ); allow_copy( false );
allow_paste( false ); allow_format( false ); allow_toggle_swap_mount_state( false ) ;
allow_manage_flags( false ) ; allow_check( false ) ; allow_label_partition( false ) ;
allow_info( false ) ;
allow_change_uuid( false ); allow_info( false ) ;
dynamic_cast<Gtk::Label*>( menu_partition .items()[ MENU_TOGGLE_MOUNT_SWAP ] .get_child() )
->set_label( _("_Unmount") ) ;
@ -1017,6 +1039,10 @@ void Win_GParted::set_valid_operations()
if ( selected_partition .status == GParted::STAT_REAL && fs .write_label )
allow_label_partition( true ) ;
//only allow changing UUID of real partitions that support it
if ( selected_partition .status == GParted::STAT_REAL && fs .write_uuid )
allow_change_uuid( true ) ;
if ( selected_partition .get_mountpoints() .size() )
{
allow_toggle_swap_mount_state( true ) ;
@ -1596,6 +1622,7 @@ void Win_GParted::activate_paste()
Partition partition_new = selected_partition ;
partition_new .filesystem = copied_partition .filesystem ;
partition_new .label = copied_partition .label ;
partition_new .uuid = copied_partition .uuid ;
partition_new .color = copied_partition .color ;
partition_new .set_used( copied_partition .sectors_used ) ;
partition_new .messages .clear() ;
@ -2310,6 +2337,7 @@ void Win_GParted::activate_label_partition()
part_temp .set_used( selected_partition.sectors_used );
part_temp .label = dialog .get_new_label();
part_temp .uuid = selected_partition .uuid ;
Operation * operation = new OperationLabelPartition( devices[ current_device ],
selected_partition, part_temp ) ;
@ -2329,6 +2357,41 @@ void Win_GParted::activate_label_partition()
}
}
void Win_GParted::activate_change_uuid()
{
//Make a duplicate of the selected partition (used in UNDO)
Partition part_temp ;
part_temp .Set( devices[ current_device ] .get_path(),
selected_partition .get_path(),
selected_partition .partition_number,
selected_partition .type,
selected_partition .filesystem,
selected_partition .sector_start,
selected_partition .sector_end,
devices[ current_device ] .sector_size,
selected_partition .inside_extended,
false ) ;
part_temp .label = selected_partition .label ;
part_temp .uuid = _("(New UUID - will be randomly generated)") ;
Operation * operation = new OperationChangeUUID( devices[ current_device ],
selected_partition, part_temp ) ;
operation ->icon = render_icon( Gtk::Stock::EXECUTE, Gtk::ICON_SIZE_MENU );
Add_Operation( operation ) ;
// Verify if the two operations can be merged
for ( unsigned int t = 0 ; t < operations .size() - 1 ; t++ )
{
if ( operations[ t ] ->type == OPERATION_CHANGE_UUID )
{
if( Merge_Operations( t, operations .size() -1 ) )
break;
}
}
}
void Win_GParted::activate_undo()
{
//when undoing a creation it's safe to decrease the newcount by one

View File

@ -44,6 +44,7 @@ FS btrfs::get_filesystem_support()
fs .read = GParted::FS::EXTERNAL ;
fs .read_label = FS::EXTERNAL ;
fs .read_uuid = FS::EXTERNAL ;
//Resizing of btrfs requires mount, umount and kernel
// support as well as btrfs filesystem resize
@ -160,6 +161,11 @@ bool btrfs::write_label( const Partition & partition, OperationDetail & operatio
return ! execute_command( "btrfs filesystem label " + partition .get_path() + " \"" + partition .label + "\"", operationdetail ) ;
}
bool btrfs::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
return true ;
}
bool btrfs::move( const Partition & partition_new
, const Partition & partition_old
, OperationDetail & operationdetail
@ -264,4 +270,33 @@ void btrfs::read_label( Partition & partition )
}
}
void btrfs::read_uuid( Partition & partition )
{
if ( btrfs_found )
{
exit_status = Utils::execute_command( "btrfs filesystem show " + partition .get_path(), output, error, true ) ;
if ( ! exit_status )
{
partition .uuid = Utils::regexp_label( output, "uuid:[[:blank:]]*([^[:space:]]*)" );
}
}
else
{
exit_status = Utils::execute_command( "btrfs-show " + partition .get_path(), output, error, true ) ;
if ( ! exit_status )
{
partition .uuid = Utils::regexp_label( output, "uuid:[[:blank:]]*([^[:space:]]*)" );
}
}
if ( exit_status )
{
if ( ! output .empty() )
partition .messages .push_back( output ) ;
if ( ! error .empty() )
partition .messages .push_back( error ) ;
}
}
} //GParted

View File

@ -46,6 +46,15 @@ bool exfat::write_label( const Partition & partition, OperationDetail & operatio
return true ;
}
void exfat::read_uuid( Partition & partition )
{
}
bool exfat::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
return true ;
}
bool exfat::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return true ;

View File

@ -29,6 +29,11 @@ FS ext2::get_filesystem_support()
if ( ! Glib::find_program_in_path( "dumpe2fs" ) .empty() )
fs .read = FS::EXTERNAL ;
if ( ! Glib::find_program_in_path( "tune2fs" ) .empty() ) {
fs .read_uuid = FS::EXTERNAL ;
fs .write_uuid = FS::EXTERNAL ;
}
if ( ! Glib::find_program_in_path( "e2label" ) .empty() ) {
fs .read_label = FS::EXTERNAL ;
fs .write_label = FS::EXTERNAL ;
@ -105,6 +110,30 @@ bool ext2::write_label( const Partition & partition, OperationDetail & operation
return ! execute_command( "e2label " + partition .get_path() + " \"" + partition .label + "\"", operationdetail ) ;
}
void ext2::read_uuid( Partition & partition )
{
if ( ! Utils::execute_command( "tune2fs -l " + partition .get_path(), output, error, true ) )
{
partition .uuid = Utils::regexp_label( output, "^Filesystem UUID:[[:blank:]]*([^[:space:]]*)" ) ;
if (partition .uuid == "<none>")
partition .uuid .clear() ;
}
else
{
if ( ! output .empty() )
partition .messages .push_back( output ) ;
if ( ! error .empty() )
partition .messages .push_back( error ) ;
}
}
bool ext2::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
return ! execute_command( "tune2fs -U random " + partition .get_path(), operationdetail ) ;
}
bool ext2::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkfs.ext2 -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;

View File

@ -30,6 +30,11 @@ FS ext3::get_filesystem_support()
if ( ! Glib::find_program_in_path( "dumpe2fs" ) .empty() )
fs .read = GParted::FS::EXTERNAL ;
if ( ! Glib::find_program_in_path( "tune2fs" ) .empty() ) {
fs .read_uuid = FS::EXTERNAL ;
fs .write_uuid = FS::EXTERNAL ;
}
if ( ! Glib::find_program_in_path( "e2label" ) .empty() ) {
fs .read_label = FS::EXTERNAL ;
fs .write_label = FS::EXTERNAL ;
@ -106,6 +111,29 @@ bool ext3::write_label( const Partition & partition, OperationDetail & operation
return ! execute_command( "e2label " + partition .get_path() + " \"" + partition .label + "\"", operationdetail ) ;
}
void ext3::read_uuid( Partition & partition )
{
if ( ! Utils::execute_command( "tune2fs -l " + partition .get_path(), output, error, true ) )
{
partition .uuid = Utils::regexp_label( output, "^Filesystem UUID:[[:blank:]]*([^[:space:]]*)" ) ;
if (partition .uuid == "<none>")
partition .uuid .clear() ;
}
else
{
if ( ! output .empty() )
partition .messages .push_back( output ) ;
if ( ! error .empty() )
partition .messages .push_back( error ) ;
}
}
bool ext3::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
return ! execute_command( "tune2fs -U random " + partition .get_path(), operationdetail ) ;
}
bool ext3::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkfs.ext3 -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;

View File

@ -34,7 +34,12 @@ FS ext4::get_filesystem_support()
if ( ! Glib::find_program_in_path( "dumpe2fs" ) .empty() )
fs .read = GParted::FS::EXTERNAL ;
if ( ! Glib::find_program_in_path( "tune2fs" ) .empty() ) {
fs .read_uuid = FS::EXTERNAL ;
fs .write_uuid = FS::EXTERNAL ;
}
if ( ! Glib::find_program_in_path( "e2label" ) .empty() ) {
fs .read_label = FS::EXTERNAL ;
fs .write_label = FS::EXTERNAL ;
@ -109,6 +114,29 @@ bool ext4::write_label( const Partition & partition, OperationDetail & operation
return ! execute_command( "e2label " + partition .get_path() + " \"" + partition .label + "\"", operationdetail ) ;
}
void ext4::read_uuid( Partition & partition )
{
if ( ! Utils::execute_command( "tune2fs -l " + partition .get_path(), output, error, true ) )
{
partition .uuid = Utils::regexp_label( output, "^Filesystem UUID:[[:blank:]]*([^[:space:]]*)" ) ;
if (partition .uuid == "<none>")
partition .uuid .clear() ;
}
else
{
if ( ! output .empty() )
partition .messages .push_back( output ) ;
if ( ! error .empty() )
partition .messages .push_back( error ) ;
}
}
bool ext4::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
return ! execute_command( "tune2fs -U random " + partition .get_path(), operationdetail ) ;
}
bool ext4::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkfs.ext4 -j -O extent -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;

View File

@ -44,9 +44,13 @@ FS fat16::get_filesystem_support()
fs .read = GParted::FS::EXTERNAL ;
}
if ( ! Glib::find_program_in_path( "mdir" ) .empty() )
fs .read_uuid = FS::EXTERNAL ;
if ( ! Glib::find_program_in_path( "mlabel" ) .empty() ) {
fs .read_label = FS::EXTERNAL ;
fs .write_label = FS::EXTERNAL ;
fs .write_uuid = FS::EXTERNAL ;
}
#ifndef HAVE_LIBPARTED_3_0_0_PLUS
@ -155,6 +159,62 @@ bool fat16::write_label( const Partition & partition, OperationDetail & operatio
return ( exit_status == 0 );
}
void fat16::read_uuid( Partition & partition )
{
//Create mtools config file
char fname[] = "/tmp/gparted-XXXXXXXX" ;
char dletter = 'H' ;
Glib::ustring err_msg = "" ;
err_msg = Utils::create_mtoolsrc_file( fname, dletter, partition.get_path() ) ;
if( err_msg.length() != 0 )
partition .messages .push_back( err_msg );
Glib::ustring cmd = String::ucompose( "export MTOOLSRC=%1 && mdir -f %2:", fname, dletter ) ;
if ( ! Utils::execute_command( cmd, output, error, true ) )
{
partition .uuid = Utils::regexp_label( output, "Volume Serial Number is[[:blank:]]([^[:space:]]+)" ) ;
if ( partition .uuid == "0000-0000" )
partition .uuid .clear() ;
}
else
{
if ( ! output .empty() )
partition .messages .push_back( output ) ;
if ( ! error .empty() )
partition .messages .push_back( error ) ;
}
}
bool fat16::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
//Create mtools config file
char fname[] = "/tmp/gparted-XXXXXXXX" ;
char dletter = 'H' ;
Glib::ustring err_msg = "" ;
err_msg = Utils::create_mtoolsrc_file( fname, dletter, partition.get_path() ) ;
// Wait some time - 'random' UUIDs turn out identical if generated in quick succession...
sleep(1);
Glib::ustring cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -s -n %2:", fname, dletter ) ;
operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
int exit_status = Utils::execute_command( cmd, output, error ) ;
if ( ! output .empty() )
operationdetail .get_last_child() .add_child( OperationDetail( output, STATUS_NONE, FONT_ITALIC ) ) ;
if ( ! error .empty() )
operationdetail .get_last_child() .add_child( OperationDetail( error, STATUS_NONE, FONT_ITALIC ) ) ;
//Delete mtools config file
err_msg = Utils::delete_mtoolsrc_file( fname );
return ( exit_status == 0 );
}
bool fat16::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkdosfs -F16 -v -n \"" + Utils::fat_compliant_label( new_partition .label ) + "\" " + new_partition .get_path(), operationdetail ) ;

View File

@ -44,9 +44,13 @@ FS fat32::get_filesystem_support()
fs .read = GParted::FS::EXTERNAL ;
}
if ( ! Glib::find_program_in_path( "mdir" ) .empty() )
fs .read_uuid = FS::EXTERNAL ;
if ( ! Glib::find_program_in_path( "mlabel" ) .empty() ) {
fs .read_label = FS::EXTERNAL ;
fs .write_label = FS::EXTERNAL ;
fs .write_uuid = FS::EXTERNAL ;
}
#ifndef HAVE_LIBPARTED_3_0_0_PLUS
@ -154,6 +158,63 @@ bool fat32::write_label( const Partition & partition, OperationDetail & operatio
return ( exit_status == 0 );
}
void fat32::read_uuid( Partition & partition )
{
//Create mtools config file
char fname[] = "/tmp/gparted-XXXXXXXX" ;
char dletter = 'H' ;
Glib::ustring err_msg = "" ;
err_msg = Utils::create_mtoolsrc_file( fname, dletter, partition.get_path() ) ;
if( err_msg.length() != 0 )
partition .messages .push_back( err_msg );
Glib::ustring cmd = String::ucompose( "export MTOOLSRC=%1 && mdir -f %2:", fname, dletter ) ;
if ( ! Utils::execute_command( cmd, output, error, true ) )
{
partition .uuid = Utils::regexp_label( output, "Volume Serial Number is[[:blank:]]([^[:space:]]+)" ) ;
if ( partition .uuid == "0000-0000" )
partition .uuid .clear() ;
}
else
{
if ( ! output .empty() )
partition .messages .push_back( output ) ;
if ( ! error .empty() )
partition .messages .push_back( error ) ;
}
}
bool fat32::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
//Create mtools config file
char fname[] = "/tmp/gparted-XXXXXXXX" ;
char dletter = 'H' ;
Glib::ustring err_msg = "" ;
err_msg = Utils::create_mtoolsrc_file( fname, dletter, partition.get_path() ) ;
// Wait some time - 'random' UUIDs turn out identical if generated in quick succession...
sleep(1);
Glib::ustring cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -s -n %2:", fname, dletter ) ;
operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
int exit_status = Utils::execute_command( cmd, output, error ) ;
if ( ! output .empty() )
operationdetail .get_last_child() .add_child( OperationDetail( output, STATUS_NONE, FONT_ITALIC ) ) ;
if ( ! error .empty() )
operationdetail .get_last_child() .add_child( OperationDetail( error, STATUS_NONE, FONT_ITALIC ) ) ;
//Delete mtools config file
err_msg = Utils::delete_mtoolsrc_file( fname );
return ( exit_status == 0 );
}
bool fat32::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkdosfs -F32 -v -n \"" + Utils::fat_compliant_label( new_partition .label ) + "\" " + new_partition .get_path(), operationdetail ) ;

View File

@ -78,6 +78,15 @@ bool hfs::write_label( const Partition & partition, OperationDetail & operationd
return true ;
}
void hfs::read_uuid( Partition & partition )
{
}
bool hfs::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
return true ;
}
bool hfs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
Glib::ustring cmd = "";

View File

@ -76,6 +76,15 @@ bool hfsplus::write_label( const Partition & partition, OperationDetail & operat
return true ;
}
void hfsplus::read_uuid( Partition & partition )
{
}
bool hfsplus::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
return true ;
}
bool hfsplus::create( const Partition & new_partition, OperationDetail & operationdetail )
{
Glib::ustring cmd = "";

View File

@ -29,12 +29,15 @@ FS jfs::get_filesystem_support()
FS fs ;
fs .filesystem = GParted::FS_JFS ;
if ( ! Glib::find_program_in_path( "jfs_debugfs" ) .empty() )
if ( ! Glib::find_program_in_path( "jfs_debugfs" ) .empty() ) {
fs .read = GParted::FS::EXTERNAL ;
fs .read_uuid = GParted::FS::EXTERNAL ;
}
if ( ! Glib::find_program_in_path( "jfs_tune" ) .empty() ) {
fs .read_label = FS::EXTERNAL ;
fs .write_label = FS::EXTERNAL ;
fs .write_uuid = FS::EXTERNAL ;
}
if ( ! Glib::find_program_in_path( "mkfs.jfs" ) .empty() )
@ -113,6 +116,29 @@ bool jfs::write_label( const Partition & partition, OperationDetail & operationd
return ! execute_command( "jfs_tune -L \"" + partition .label + "\" " + partition .get_path(), operationdetail ) ;
}
void jfs::read_uuid( Partition & partition )
{
if ( ! Utils::execute_command( "echo su | jfs_debugfs " + partition .get_path(), output, error, true ) )
{
partition .uuid = Utils::regexp_label( output, "s_uuid:[[:blank:]]*([^[:space:]]+)" ) ;
if ( partition .uuid == "00000000-0000-0000-0000-000000000000" )
partition .uuid .clear() ;
}
else
{
if ( ! output .empty() )
partition .messages .push_back( output ) ;
if ( ! error .empty() )
partition .messages .push_back( error ) ;
}
}
bool jfs::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
return ! execute_command( "jfs_tune -U random " + partition .get_path(), operationdetail ) ;
}
bool jfs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkfs.jfs -q -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;

View File

@ -38,7 +38,10 @@ FS linux_swap::get_filesystem_support()
fs .read_label = FS::EXTERNAL ;
if ( ! Glib::find_program_in_path( "swaplabel" ) .empty() )
fs .write_label = FS::EXTERNAL ;
{
fs .read_uuid = FS::EXTERNAL ;
fs .write_uuid = FS::EXTERNAL ;
}
fs .copy = GParted::FS::EXTERNAL ;
fs .move = GParted::FS::EXTERNAL ;
@ -71,6 +74,28 @@ bool linux_swap::write_label( const Partition & partition, OperationDetail & ope
return ! execute_command( "swaplabel -L \"" + partition .label + "\" " + partition .get_path(), operationdetail ) ;
}
void linux_swap::read_uuid( Partition & partition )
{
if ( ! Utils::execute_command( "swaplabel " + partition .get_path(), output, error, true ) )
{
partition .uuid = Utils::regexp_label( output, "^UUID:[[:blank:]]*([^[:space:]]*)" ) ;
}
else
{
if ( ! output .empty() )
partition .messages .push_back( output ) ;
if ( ! error .empty() )
partition .messages .push_back( error ) ;
}
}
bool linux_swap::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
return ! execute_command( "swaplabel -U \"" + Utils::generate_uuid() + "\" " + partition .get_path(), operationdetail ) ;
}
bool linux_swap::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkswap -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;

View File

@ -36,6 +36,8 @@ FS nilfs2::get_filesystem_support()
fs .read = GParted::FS::EXTERNAL ;
fs .read_label = GParted::FS::EXTERNAL ;
fs .write_label = GParted::FS::EXTERNAL ;
fs .read_uuid = GParted::FS::EXTERNAL ;
fs .write_uuid = GParted::FS::EXTERNAL ;
}
//Nilfs2 resizing is an online only operation and needs:
@ -127,6 +129,29 @@ bool nilfs2::write_label( const Partition & partition, OperationDetail & operati
return ! execute_command( "nilfs-tune -L \"" + partition .label + "\" " + partition .get_path(), operationdetail ) ;
}
void nilfs2::read_uuid( Partition & partition )
{
if ( ! Utils::execute_command( "nilfs-tune -l " + partition .get_path(), output, error, true ) )
{
partition .uuid = Utils::regexp_label( output, "^Filesystem UUID:[[:blank:]]*([^[:space:]]*)" ) ;
if (partition .uuid == "00000000-0000-0000-0000-000000000000")
partition .uuid .clear() ;
}
else
{
if ( ! output .empty() )
partition .messages .push_back( output ) ;
if ( ! error .empty() )
partition .messages .push_back( error ) ;
}
}
bool nilfs2::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
return ! execute_command( "nilfs-tune -U " + Utils::generate_uuid() + " " + partition .get_path(), operationdetail ) ;
}
bool nilfs2::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkfs.nilfs2 -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;

View File

@ -104,6 +104,15 @@ bool ntfs::write_label( const Partition & partition, OperationDetail & operation
return ! execute_command( "ntfslabel --force " + partition .get_path() + " \"" + partition .label + "\"", operationdetail ) ;
}
void ntfs::read_uuid( Partition & partition )
{
}
bool ntfs::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
return true ;
}
bool ntfs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkntfs -Q -v -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;

View File

@ -37,7 +37,10 @@ FS reiser4::get_filesystem_support()
fs .create = GParted::FS::EXTERNAL ;
if ( ! Glib::find_program_in_path( "fsck.reiser4" ) .empty() )
{
fs .read_uuid = GParted::FS::EXTERNAL ;
fs .check = GParted::FS::EXTERNAL ;
}
if ( fs .check )
@ -102,6 +105,27 @@ bool reiser4::write_label( const Partition & partition, OperationDetail & operat
return true ;
}
void reiser4::read_uuid( Partition & partition )
{
if ( ! Utils::execute_command( "fsck.reiser4 --check --yes " + partition .get_path(), output, error, true ) )
{
partition .uuid = Utils::regexp_label( error, "uuid:[[:blank:]]*([^[:space:]]*)" ) ;
}
else
{
if ( ! output .empty() )
partition .messages .push_back( output ) ;
if ( ! error .empty() )
partition .messages .push_back( error ) ;
}
}
bool reiser4::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
return true ;
}
bool reiser4::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkfs.reiser4 --yes --label \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;

View File

@ -34,7 +34,11 @@ FS reiserfs::get_filesystem_support()
}
if ( ! Glib::find_program_in_path( "reiserfstune" ) .empty() )
{
fs .write_label = FS::EXTERNAL ;
fs .read_uuid = FS::EXTERNAL ;
fs .write_uuid = FS::EXTERNAL ;
}
if ( ! Glib::find_program_in_path( "mkreiserfs" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
@ -112,6 +116,27 @@ bool reiserfs::write_label( const Partition & partition, OperationDetail & opera
return ! execute_command( "reiserfstune --label \"" + partition .label + "\" " + partition .get_path(), operationdetail ) ;
}
void reiserfs::read_uuid( Partition & partition )
{
if ( ! Utils::execute_command( "reiserfstune " + partition .get_path(), output, error, true ) )
{
partition .uuid = Utils::regexp_label( output, "^UUID:[[:blank:]]*([^[:space:]]*)" ) ;
}
else
{
if ( ! output .empty() )
partition .messages .push_back( output ) ;
if ( ! error .empty() )
partition .messages .push_back( error ) ;
}
}
bool reiserfs::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
return ! execute_command( "reiserfstune -u random " + partition .get_path(), operationdetail ) ;
}
bool reiserfs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkreiserfs -f --label \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;

View File

@ -47,6 +47,15 @@ bool ufs::write_label( const Partition & partition, OperationDetail & operationd
return true ;
}
void ufs::read_uuid( Partition & partition )
{
}
bool ufs::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
return true ;
}
bool ufs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return true ;

View File

@ -36,7 +36,11 @@ FS xfs::get_filesystem_support()
}
if ( ! Glib::find_program_in_path( "xfs_admin" ) .empty() )
{
fs .write_label = FS::EXTERNAL ;
fs .read_uuid = FS::EXTERNAL ;
fs .write_uuid = FS::EXTERNAL ;
}
if ( ! Glib::find_program_in_path( "mkfs.xfs" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
@ -126,6 +130,29 @@ bool xfs::write_label( const Partition & partition, OperationDetail & operationd
return ! execute_command( cmd, operationdetail ) ;
}
void xfs::read_uuid( Partition & partition )
{
if ( ! Utils::execute_command( "xfs_admin -u " + partition .get_path(), output, error, true ) )
{
partition .uuid = Utils::regexp_label( output, "^UUID[[:blank:]]*=[[:blank:]]*([^[:space:]]*)" ) ;
if (partition .uuid == "00000000-0000-0000-0000-000000000000")
partition .uuid .clear() ;
}
else
{
if ( ! output .empty() )
partition .messages .push_back( output ) ;
if ( ! error .empty() )
partition .messages .push_back( error ) ;
}
}
bool xfs::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
return ! execute_command( "xfs_admin -U generate " + partition .get_path(), operationdetail ) ;
}
bool xfs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
//mkfs.xfs will not create file system if label is longer than 12 characters, hence truncation.