diff --git a/fdisk/edit_disk.cgi b/fdisk/edit_disk.cgi index 3b192858b..5527520a0 100755 --- a/fdisk/edit_disk.cgi +++ b/fdisk/edit_disk.cgi @@ -12,6 +12,10 @@ $d || &error($text{'disk_egone'}); @parts = @{$d->{'parts'}}; &ui_print_header($d->{'desc'}, $text{'disk_title'}, "", undef, @disks == 1 ? 1 : 0, @disks == 1 ? 1 : 0); +$caneditpart = + $d->{'table'} ne 'gpt' || + ($d->{'table'} eq 'gpt' && + &has_command('parted')); # Work out links to add partitions foreach $p (@parts) { @@ -28,17 +32,22 @@ foreach $p (@parts) { $anyfree++; } } -if ($regular < 4 || $disk->{'table'} ne 'msdos') { - push(@edlinks, "{'index'}&new=1\">". - $text{'index_addpri'}.""); +if ($caneditpart) { + if ($regular < 4 || $disk->{'table'} ne 'msdos') { + push(@edlinks, "{'index'}&new=1\">". + $text{'index_addpri'}.""); + } + if ($extended) { + push(@edlinks, "{'index'}&new=2\">". + $text{'index_addlog'}.""); + } + elsif ($regular < 4 && &supports_extended()) { + push(@edlinks, "{'index'}&new=3\">". + $text{'index_addext'}.""); + } } -if ($extended) { - push(@edlinks, "{'index'}&new=2\">". - $text{'index_addlog'}.""); - } -elsif ($regular < 4 && &supports_extended()) { - push(@edlinks, "{'index'}&new=3\">". - $text{'index_addext'}.""); +else { + $wantsparted = 1; } if ($d->{'table'} eq 'unknown') { # Must create a partition table first @@ -64,6 +73,10 @@ if ($d->{'table'}) { } print &ui_links_row(\@info),"

\n"; +if ($wantsparted) { + print "

$text{'edit_edisk'}

\n"; + } + # Show table of partitions, if any if (@parts) { print &ui_links_row(\@edlinks); diff --git a/fdisk/edit_part.cgi b/fdisk/edit_part.cgi index 3565152b9..91e3f21c2 100755 --- a/fdisk/edit_part.cgi +++ b/fdisk/edit_part.cgi @@ -121,7 +121,7 @@ if ($pinfo->{'extended'} || $in{'new'} == 3) { # Extended, cannot change print &ui_table_row($text{'edit_type'}, $text{'extended'}); } -elsif (($pinfo->{'edittype'} || $in{'new'}) && !$mounted) { +elsif (($pinfo->{'edittype'} == 1 || $in{'new'}) && !$mounted) { # Can change print &ui_table_row($text{'edit_type'}, &ui_select("type", @@ -203,7 +203,7 @@ if (($has_e2label || $has_xfs_db) && &supports_label($pinfo) && !$in{'new'}) { } # Show field for partition name -if (&supports_name($dinfo) && !$mounted) { +if (&supports_name($dinfo) && !$mounted && $pinfo->{'edittype'} != 2) { print &ui_table_row($text{'edit_name'}, &ui_textbox("name", $pinfo->{'name'}, 20)); } @@ -218,17 +218,18 @@ print &ui_table_end(); if ($in{'new'}) { print &ui_form_end([ [ undef, $text{'create'} ] ]); } -elsif (@stat && $stat[2]) { +elsif (@stat && $stat[2] && + $pinfo->{'edittype'} != 2) { print &ui_form_end(); print "$text{'edit_inuse'}\n"; } -else { +elsif ($pinfo->{'edittype'} != 2) { print &ui_form_end([ $pinfo->{'extended'} ? ( ) : ( [ undef, $text{'save'} ] ), [ 'delete', $text{'delete'} ] ]); } -if (!$in{'new'} && !$pinfo->{'extended'}) { +if (!$in{'new'} && !$pinfo->{'extended'} && $pinfo->{'edittype'} != 2) { my $ui_buttons_content; if (!@stat || $stat[2] == 0) { @@ -291,6 +292,9 @@ if (!$in{'new'} && !$pinfo->{'extended'}) { print $ui_buttons_content; print &ui_buttons_end(); } + } elsif (!$mounted && + $pinfo->{'edittype'} == 2) { + print "$text{'edit_eparted'}\n"; } &ui_print_footer("edit_disk.cgi?device=$dinfo->{'device'}", diff --git a/fdisk/fdisk-lib.pl b/fdisk/fdisk-lib.pl index 3b8d0e955..be66da2a8 100755 --- a/fdisk/fdisk-lib.pl +++ b/fdisk/fdisk-lib.pl @@ -517,7 +517,7 @@ while() { 'blocks' => "$+{blocks}", 'index' => scalar(@{$disk->{'parts'}}), 'dtable' => $disk->{'table'}, - 'edittype' => 1, }; + 'edittype' => 2, }; $part->{'desc'} = &partition_description($part->{'device'}); $part->{'size'} = ($part->{'end'} - $part->{'start'} + 1) * $disk->{'cylsize'}; diff --git a/fdisk/lang/en b/fdisk/lang/en index 10846eedc..808a1deeb 100644 --- a/fdisk/lang/en +++ b/fdisk/lang/en @@ -98,6 +98,8 @@ edit_name=Partition name edit_volid=Volume ID edit_blocks=$1 blocks edit_inuse=This partition cannot be changed as it is currently in use or configured for use. +edit_eparted=This partition cannot be changed unless parted command is installed. +edit_edisk=This disk cannot be edited unless parted command is installed. edit_mkfs=Create New Filesystem edit_mkfs2=Create Filesystem: edit_mkfsmsg=Builds a new $1 filesystem on this partition, permanently erasing any existing files. You must do this after creating a new partition or changing an existing one.