[gparted] Make the partition label length dependent from the file system (#689318)
- From: Mike Fleetwood <mfleetwo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Make the partition label length dependent from the file system (#689318)
- Date: Sun, 30 Dec 2012 16:56:13 +0000 (UTC)
commit ecb1f57594e8aebb60fda3e0160921b83750c54f
Author: sinlu bes <e80f00 gmail com>
Date: Sun Dec 16 16:41:30 2012 +0100
Make the partition label length dependent from the file system (#689318)
fixes Bug #689318 - filesystem type specific support for partition name
maximum length
include/Utils.h | 1 +
src/Dialog_Partition_Label.cc | 2 +-
src/Dialog_Partition_New.cc | 4 ++-
src/Utils.cc | 48 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 53 insertions(+), 2 deletions(-)
---
diff --git a/include/Utils.h b/include/Utils.h
index c0e00b6..0cfbaab 100644
--- a/include/Utils.h
+++ b/include/Utils.h
@@ -158,6 +158,7 @@ public:
static Glib::ustring num_to_str( Sector number ) ;
static Glib::ustring get_color( FILESYSTEM filesystem ) ;
static Glib::RefPtr<Gdk::Pixbuf> get_color_as_pixbuf( FILESYSTEM filesystem, int width, int height ) ;
+ static int get_filesystem_label_maxlength( FILESYSTEM filesystem ) ;
static Glib::ustring get_filesystem_string( FILESYSTEM filesystem ) ;
static Glib::ustring get_filesystem_software( FILESYSTEM filesystem ) ;
static bool kernel_supports_fs( const Glib::ustring & fs ) ;
diff --git a/src/Dialog_Partition_Label.cc b/src/Dialog_Partition_Label.cc
index fa719a2..c31462c 100644
--- a/src/Dialog_Partition_Label.cc
+++ b/src/Dialog_Partition_Label.cc
@@ -44,7 +44,7 @@ Dialog_Partition_Label::Dialog_Partition_Label( const Partition & partition )
Gtk::FILL);
//Create Text entry box
entry = manage(new Gtk::Entry());
- entry->set_max_length(30);
+ entry->set_max_length( Utils::get_filesystem_label_maxlength( partition.filesystem ) ) ;
entry->set_width_chars(20);
entry->set_activates_default(true);
entry->set_text(partition.get_label());
diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc
index f713cde..43368a9 100644
--- a/src/Dialog_Partition_New.cc
+++ b/src/Dialog_Partition_New.cc
@@ -129,7 +129,6 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
table_create .attach( * Utils::mk_label( Glib::ustring( _("Label:") ) ),
0, 1, 3, 4, Gtk::FILL ) ;
//Create Text entry box
- entry .set_max_length( 30 );
entry .set_width_chars( 20 );
entry .set_activates_default( true );
entry .set_text( partition .get_label() );
@@ -316,6 +315,9 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
frame_resizer_base->set_rgb_partition_color(color_temp);
}
+ //set partition name entry box length
+ entry .set_max_length( Utils::get_filesystem_label_maxlength( fs.filesystem ) ) ;
+
frame_resizer_base ->Draw_Partition() ;
}
diff --git a/src/Utils.cc b/src/Utils.cc
index affbee4..e38a3da 100644
--- a/src/Utils.cc
+++ b/src/Utils.cc
@@ -118,6 +118,54 @@ Glib::RefPtr<Gdk::Pixbuf> Utils::get_color_as_pixbuf( FILESYSTEM filesystem, int
return pixbuf ;
}
+int Utils::get_filesystem_label_maxlength( FILESYSTEM filesystem )
+{
+ switch( filesystem )
+ {
+ //All file systems commented out are not supported for labelling
+ // by either the new partition or label partition operations.
+ case FS_BTRFS : return 255 ;
+ //case FS_EXFAT : return ;
+ case FS_EXT2 : return 16 ;
+ case FS_EXT3 : return 16 ;
+ case FS_EXT4 : return 16 ;
+ case FS_FAT16 : return 11 ;
+ case FS_FAT32 : return 11 ;
+ //mkfs.hfsplus can create hfs and hfs+ file systems with labels up to 255
+ // characters. However there is no specific tool to read the labels and
+ // blkid, the only tool currently available, only display the first 27
+ // and 63 character respectively.
+ // Reference:
+ // util-linux-2.20.1/libblkid/src/superblocks/hfs.c:struct hfs_mdb
+ case FS_HFS : return 27 ;
+ case FS_HFSPLUS : return 63 ;
+ //mkfs.jfs and jfs_tune can create and update labels to 16 characters but
+ // only displays the first 11 characters. This is because version 1 jfs
+ // file systems only have an 11 character field for the label but version
+ // 2 jfs has extra fields containing a 16 character label. mkfs.jfs
+ // writes the extra fields containing the 16 character label, but then
+ // sets it to version 1 jfs. It does this to be backwardly compatible
+ // with jfs before 1.0.18, released May 2002. Blkid does display the
+ // full 16 character label by just ignoring the file system version.
+ // As using jfs_tune to get the label stick with an 11 character limit.
+ // References:
+ // jfsutils-1.1.15/tune/tune.c:main()
+ // jfsutils-1.1.15/mkfs/mkfs.c:create_aggregate()
+ // http://jfs.cvs.sourceforge.net/viewvc/jfs/jfsutils/NEWS?revision=HEAD
+ case FS_JFS : return 11 ;
+ case FS_LINUX_SWAP : return 15 ;
+ //case FS_LVM2_PV : return ;
+ case FS_NILFS2 : return 80 ;
+ case FS_NTFS : return 128 ;
+ case FS_REISER4 : return 16 ;
+ case FS_REISERFS : return 16 ;
+ //case FS_UFS : return ;
+ case FS_XFS : return 12 ;
+
+ default : return 30 ;
+ }
+}
+
Glib::ustring Utils::get_filesystem_string( FILESYSTEM filesystem )
{
switch( filesystem )
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]