Changeset 3666 in MondoRescue


Ignore:
Timestamp:
Jun 7, 2017, 2:28:35 AM (7 years ago)
Author:
Bruno Cornec
Message:

Multiple mr-parted2fidsk fixes for parted usage

  • support the boot flag and now prints '*' accordingly in hte output
  • pnum for 83 is now fixed to ext3
  • Fix detection of lvm partitions using flag
  • Fix error messages when Bytes were returned as a measure
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi/mr-parted2fdisk

    r3664 r3666  
    121121my %end;
    122122my %type;
     123my %boot;
    123124my $fake = 0;
    124125my $mega = 1048576;
     
    236237# Reverse table of pid
    237238while (($i,$l) = each %pid) {
    238     next if ($i eq "ext2");
    239239    $pnum{$l} = $i;
    240240}
     241$pnum{"83"} = "ext3";
    241242
    242243# fdisk has a bug when handling more than 1024 disks, seen on RHEL
     
    346347                # parted needs MB
    347348                $end = $cylend * $un / $mega;
    348                 pb_log(1,"n $l $part $cylstart $cylend => mkpart primary $start $end\n");
     349                pb_log(1,"n $l $part $cylstart $cylend => mkpart primary ext2 $start $end\n");
    349350                pb_system("$parted -s $device mkpart primary ext2 $start $end\n") if ($fake == 0);
    350351                print "command (m for help) sent back to fake fdisk for mondorestore\n";
     
    358359                pb_log(1,"d $part => rm $part\n");
    359360                pb_system("$parted -s $device rm $part\n") if ($fake == 0);
    360                 get_parted($device,undef,\%start,\%end,undef);
     361                get_parted($device,undef,\%start,\%end);
    361362                print "command (m for help) sent back to fake fdisk for mondorestore\n";
    362363            } elsif ($i =~ /^w$/) {
     
    517518my $mstart;
    518519my $mend;
     520my $mboot;
    519521my $length;
    520522my $pid;
    521523my $cmt;
     524#   Device Boot      Start         End      Blocks   Id  System
     525#/dev/hda1               1       77579    39099374+  ee  EFI GPT
    522526format FLOG1 =
    523 @<<<<<<<<<<<< @>>>>>>>>>> @>>>>>>>>>> @>>>>>>>>>> @>>>  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    524 $part,       $mstart,   $mend,   $length,  $pid, $cmt
     527@<<<<<<<<< @> @>>>>>>>>>> @>>>>>>>>>> @>>>>>>>>>> @>>>  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<
     528$part,     $mboot, $mstart,   $mend,   $length,  $pid, $cmt
    525529.
    526530format FLOG2 =
    527531@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    528532$part,
    529              @>>>>>>>>>> @>>>>>>>>>> @>>>>>>>>>> @>>>  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    530              $mstart,   $mend,   $length,  $pid, $cmt
     533           @> @>>>>>>>>>> @>>>>>>>>>> @>>>>>>>>>> @>>>  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<
     534           $mboot, $mstart,   $mend,   $length,  $pid, $cmt
    531535.
    532536format STDOUT1 =
    533 @<<<<<<<<<<<< @>>>>>>>>>> @>>>>>>>>>> @>>>>>>>>>> @>>>  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    534 $part,       $mstart,   $mend,   $length,  $pid, $cmt
     537@<<<<<<<<< @> @>>>>>>>>>> @>>>>>>>>>> @>>>>>>>>>> @>>>  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<
     538$part,     $mboot, $mstart,   $mend,   $length,  $pid, $cmt
    535539.
    536540format STDOUT2 =
    537541@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    538542$part,
    539              @>>>>>>>>>> @>>>>>>>>>> @>>>>>>>>>> @>>>  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    540              $mstart,   $mend,   $length,  $pid, $cmt
     543           @> @>>>>>>>>>> @>>>>>>>>>> @>>>>>>>>>> @>>>  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<
     544           $mboot, $mstart,   $mend,   $length,  $pid, $cmt
    541545.
    542 #   Device Boot      Start         End      Blocks   Id  System
    543 #/dev/hda1               1       77579    39099374+  ee  EFI GPT
    544546
    545547
     
    553555
    554556# This will return MB
    555 get_parted($device,$start,$end,\%type);
    556 
    557 while (($n,$d) = each %type) {
     557get_parted($device,$start,$end,\%type,\%boot);
     558
     559foreach $n (sort keys %type) {
    558560    # Print infos fdisk like
    559561    $part = ${device}.$n;
     
    570572    # length is in 1K blocks
    571573    $length = sprintf("%d",($mend-$mstart+1)*$un/1024);
     574    pb_log(2,"type $type{$n}\n");
    572575    $pid = $pid{$type{$n}};
    573576    $cmt = $cmt{$type{$n}};
    574     pb_log(2,"$part - $mstart - $mend - $length\n");
     577    $mboot = $boot{$n};
     578    pb_log(2,"$part - $mboot - $mstart - $mend - $length\n");
    575579
    576580    if ($verbose == 1) {
     
    677681my $end = shift;
    678682my $type = shift;
     683my $boot = shift;
    679684my $void;
    680685my $d;
     
    767772        $$end{$n} = $ret;
    768773        $$type{$n} =~ s/\(..*\)$//;
    769         pb_log(2,"$n      $$start{$n}      $$end{$n}     $$type{$n}\n");
     774        $$type{$n} = "lvm" if (($$type{$n} eq "") && ($flag =~ /lvm/));
     775        $$boot{$n} = "";
     776        $$boot{$n} = "*" if ($flag =~ /boot/);
     777        pb_log(2,"$n  $$boot{$n}    $$start{$n}      $$end{$n}     $$type{$n}\n");
    770778    }
    771779} else {
     
    816824
    817825pb_log(2,"decode_Bsuf input: $size / $unit ");
    818 if ($size =~ /K[B]*$/i) {
    819     $size =~ s/K[B]*$//i;
     826# Suppress all B mention, including single B
     827if ($size =~ /B$/i) {
     828    $size =~ s/B$//i;
     829}
     830if ($size =~ /K$/i) {
     831    $size =~ s/K$//i;
    820832    $size *= $kilo;
    821 } elsif ($size =~ /M[B]*$/i) {
    822     $size =~ s/M[B]*$//i;
     833} elsif ($size =~ /M$/i) {
     834    $size =~ s/M$//i;
    823835    $size *= $kilo*$kilo;
    824 } elsif ($size =~ /G[B]*$/i) {
    825     $size =~ s/G[B]*$//i;
     836} elsif ($size =~ /G$/i) {
     837    $size =~ s/G$//i;
    826838    $size *= $kilo*$kilo*$kilo;
    827 } elsif ($size =~ /T[B]*$/i) {
    828     $size =~ s/T[B]*$//i;
     839} elsif ($size =~ /T$/i) {
     840    $size =~ s/T$//i;
    829841    $size *= $kilo*$kilo*$kilo*$kilo;
    830842} else {
Note: See TracChangeset for help on using the changeset viewer.