From 402a88020dc9a05fdd50ede1fd78a44354246af3 Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Fri, 9 Jan 2009 15:03:02 +0000 Subject: Add support for editing partition labels without formatting --- perl-install/NEWS | 4 ++ perl-install/diskdrake/interactive.pm | 16 ++++-- perl-install/fs/format.pm | 101 ++++++++++++++++++++++++++++------ perl-install/install/NEWS | 1 + perl-install/install/share/list.xml | 14 +++-- 5 files changed, 108 insertions(+), 28 deletions(-) diff --git a/perl-install/NEWS b/perl-install/NEWS index 60a3161f7..32a46962f 100644 --- a/perl-install/NEWS +++ b/perl-install/NEWS @@ -2,6 +2,10 @@ - diskdrake: o --smb: cifs must be used instead of smbfs (#42483) o ext4dev is now stable and called ext4 in 2.6.28+ + o allow editing partition label without formatting (bootloader config is not + yet updated) + o allow setting label on NTFS and reiser4 partitions + - harddrake: o fix displaying in proper category sound coprocessor & misc ACPI event keys - prevent mdkapplet from crashing (#46477) diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm index 6d40c2f0d..b23f9ff9d 100644 --- a/perl-install/diskdrake/interactive.pm +++ b/perl-install/diskdrake/interactive.pm @@ -397,7 +397,7 @@ sub part_possible_actions { N_("Mount point") => '$part->{real_mntpoint} || (!isBusy && !isSwap && !isNonMountable)', N_("Type") => '!isBusy && $::expert && (!readonly || $part->{pt_type} == 0x83)', N_("Options") => '!isSwap($part) && !isNonMountable && $::expert', - N_("Label") => '!isNonMountable && $::expert', + N_("Label") => '!isNonMountable && $::expert && fs::format::canEditLabel($part)', N_("Resize") => '!isBusy && !readonly && !isSpecial || isLVM($hd) && LVM_resizable', N_("Format") => '!isBusy && (!readonly && ($::expert || $::isStandalone) || fs::type::isRawLUKS($part))', N_("Mount") => '!isBusy && (hasMntpoint || isSwap) && maybeFormatted && ($::expert || $::isStandalone)', @@ -603,12 +603,20 @@ sub Type { sub Label { my ($in, $_hd, $part) = @_; - $in->ask_from(N("Which volume label?"), '', + my $old_label = $part->{device_LABEL}; + $in->ask_from(N("Set volume label"), N("Beware, this will be written to disk as soon as you validate!"), [ { label => N("Which volume label?"), title => 1 }, { label => N("Label:"), val => \$part->{device_LABEL} } ]) or return; + + if (!fs::format::check_package_is_installed_label($in->do_pkgs, $part->{fs_type})) { + $part->{device_LABEL} = $old_label; + return; + } $part->{prefer_device_LABEL} = to_bool($part->{device_LABEL}); + fs::format::clean_label($part); + fs::format::write_label($part); } sub Mount_point { @@ -1092,7 +1100,7 @@ sub check_type { return; } if ($::isStandalone && $type->{fs_type} && fs::format::known_type($type)) { - fs::format::check_package_is_installed($in->do_pkgs, $type->{fs_type}) or return; + fs::format::check_package_is_installed_format($in->do_pkgs, $type->{fs_type}) or return; } 1; } @@ -1167,7 +1175,7 @@ sub format_ { return &dmcrypt_format; } if ($::isStandalone) { - fs::format::check_package_is_installed($in->do_pkgs, $part->{fs_type}) or return; + fs::format::check_package_is_installed_format($in->do_pkgs, $part->{fs_type}) or return; } if ($::expert && !member($part->{fs_type}, 'reiserfs', 'xfs')) { $part->{toFormatCheck} = $in->ask_yesorno(N("Confirmation"), N("Check bad blocks?")); diff --git a/perl-install/fs/format.pm b/perl-install/fs/format.pm index 386acbad6..d621b6067 100644 --- a/perl-install/fs/format.pm +++ b/perl-install/fs/format.pm @@ -31,12 +31,33 @@ my %LABELs = ( #- option, length, handled_by_mount ext3 => [ '-L', 16, 1 ], ext4 => [ '-L', 16, 1 ], reiserfs => [ '-l', 16, 1 ], + reiser4 => [ '-L', 16, 1 ], xfs => [ '-L', 12, 1 ], jfs => [ '-L', 16, 1 ], hfs => [ '-l', 27, 0 ], dos => [ '-n', 11, 0 ], vfat => [ '-n', 11, 0 ], swap => [ '-L', 15, 1 ], + ntfs => [ '-L', 128, 0 ], + 'ntfs-3g' => [ '-L', 128, 0 ], +); + +my %edit_LABEL = ( # package, command, option +# If option is defined, run