Changeset 3370 in MondoRescue
- Timestamp:
- Apr 18, 2015, 7:15:29 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi/parted2fdisk.pl
r3367 r3370 14 14 use strict; 15 15 use File::Basename; 16 16 use Getopt::Long qw(:config auto_abbrev no_ignore_case); 17 use Carp qw/confess cluck/; 18 use Data::Dumper; 19 use English; 20 use MondoRescue::Version; 21 use MondoRescue::Base; 22 use MondoRescue::Disk; 23 use ProjectBuilder::Base; 17 24 18 25 =pod … … 20 27 =head1 NAME 21 28 22 parted2fdisk is a fdisk like command using parted internally .29 parted2fdisk is a fdisk like command using parted internally for analysing GPT labelled disks 23 30 24 31 =head1 DESCRIPTION … … 29 36 30 37 parted2fdisk -s partition 38 31 39 parted2fdisk -l [device] 40 32 41 parted2fdisk [-n] device 33 42 … … 40 49 Print the size (in blocks) of the given partition. 41 50 51 =item B<-l> 52 53 List the partition tables for the specified device (or all if none specified) and then exit. 54 42 55 =item B<-n> 43 56 44 57 Fake mode. Doesn't pass the commands just simulate. 45 46 =item B<-l>47 48 List the partition tables for the specified device (or all if none specified) and then exit.49 58 50 59 =item B<no option> … … 95 104 my $flog = "/var/log/parted2fdisk.log"; 96 105 open(FLOG, "> $flog") || die "Unable to open $flog"; 97 98 my $fdisk = "/sbin/fdisk";99 $fdisk = "/usr/sbin/fdisk" if (not -x "/sbin/fdisk");100 my $parted = "/sbin/parted";101 $parted = "/usr/sbin/parted" if (not -x "/sbin/parted");102 106 103 107 my $i; … … 114 118 my $fake = 0; 115 119 my $mega = 1048576; 120 my %opts; 116 121 117 122 # Immediate flushing to avoids read error from mondorestore in log files 118 123 $| = 1; 119 124 120 #121 # Looking for fdisk122 #123 $fdisk = is_lsb($fdisk);124 125 # 125 126 # We always use fdisk except with GPT types of … … 130 131 my $un; 131 132 my $type; 132 my $args = ""; 133 my $device = ""; 133 my $device; 134 134 my $endmax = ""; 135 my $appname = "parted2fdisk"; 136 my ($mrver,$mrrev) = mr_version_init(); 137 138 pb_syntax_init("$appname Version $mrver-$mrrev\n"); 135 139 136 140 if ($#ARGV < 0) { 137 printf FLOG "No arguments given exiting ...\n"; 138 mysyn(); 139 } 141 pb_syntax(-1,0); 142 } 143 144 GetOptions("help|?|h+" => \$opts{'h'}, 145 "device|d|s=s" => \$opts{'s'}, 146 "list|l" => \$opts{'l'}, 147 "Log-File|L=s" => \$opts{'L'}, 148 "man" => \$opts{'man'}, 149 "noop|n" => \$opts{'n'}, 150 "quiet|q" => \$opts{'q'}, 151 "version|V=s" => \$opts{'V'}, 152 "verbose|v+" => \$opts{'v'}, 153 "stop-on-error!" => \$Global::pb_stop_on_error, 154 ) || pb_syntax(-1,0); 155 156 if (defined $opts{'L'}) { 157 open(pbLOG,"> $opts{'L'}") || die "Unable to log to $opts{'L'}: $!"; 158 $pbLOG = \*pbLOG; 159 } 160 pb_log_init($opts{'v'}, $pbLOG); 161 162 # We support at most one option and one device 163 if ((defined $opts{'l'}) && (defined $opts{'s'})) { 164 pb_syntax(-1,0); 165 } 166 167 # Create a device var which will be the devide or partition on which to work 168 # whatever the option used. 169 $device = $ARGV[0] if (defined $opts{'l'}); 170 $device = $opts{'s'} if (defined $opts{'s'}); 171 $device = $ARGV[0] if (defined $ARGV[0]); 172 $device = "" if ((not defined $device) || ($device =~ /^-/)); 173 174 # -s takes a partition as arg 175 # so create a correct device from that 176 if (defined $opts{'s'}) { 177 $wpart = $device; 178 # To support dev like cciss/c0d0p1 179 if ($device =~ /([0-9]+)p[0-9]+$/) { 180 $device =~ s/([0-9]+)p[0-9]+$/$1/; 181 } else { 182 $device =~ s/[0-9]+$//; 183 } 184 } 185 186 if (defined $opts{'n'}) { 187 print FLOG "Fake mode. Nothing will be really done\n"; 188 $fake = 1; 189 } 190 191 pb_log(1,"Called with device: $device\n"); 140 192 141 193 my %pid = ( "FAT" => "6", … … 161 213 } 162 214 163 foreach $i (@ARGV) {164 # We support at most one option and one device165 print FLOG "Parameter found : $i\n";166 if ($i =~ /^\/dev\//) {167 $device = $i;168 next;169 } elsif ($i =~ /^-/) {170 $args = $i;171 next;172 } else {173 mysyn();174 }175 }176 177 if (($args ne "") && ($args ne "-l") && ($device eq "")) {178 mysyn();179 }180 181 # -s takes a partition as arg182 if ($args =~ /-s/) {183 $wpart = $device;184 # To support dev like cciss/c0d0p1185 if ($device =~ /([0-9]+)p[0-9]+$/) {186 $device =~ s/([0-9]+)p[0-9]+$/$1/;187 } else {188 $device =~ s/[0-9]+$//;189 }190 }191 192 if ($args =~ /-n/) {193 print FLOG "Fake mode. Nothing will be really done\n";194 $fake = 1;195 }196 197 print FLOG "Called with device $device and arg $args\n";198 199 if (($args =~ /-l/) && ($device eq "")) {200 # Pass to real fdisk directly201 local_fdisk($args,$device);202 myexit(0);203 }204 205 215 # util-linux/fdisk version 216 my $fdisk = pb_check_req("fdisk",0); 206 217 open(CMD,"$fdisk -v |") || die "Unable to execute $fdisk"; 207 218 my $version = <CMD>; … … 223 234 } 224 235 225 if (($v == 1) || (($v == 2) && ($maj < 22))) { 226 # Check partition table type 227 print FLOG "We use an old fdisk, activating replacement code...\n"; 228 $parted = is_lsb($parted); 229 $type = which_type($device); 230 if ($type ne "msdos") { 231 print FLOG "Not an msdos type of disk label\n"; 232 if ($args =~ /-l/) { 233 fdisk_list($device,undef,\%start,\%end, 1); 234 } elsif ($args =~ /-s/) { 235 fdisk_list($device,$wpart,\%start,\%end, 1); 236 } elsif (($args =~ /-/) and ($fake == 0)) { 237 printf FLOG "Option not supported ($args) ...\n"; 238 printf FLOG "Please report to the author\n"; 239 mysyn(); 240 } else { 241 # Read fdisk orders on stdin and pass them to parted 242 # on the command line as parted doesn't read on stdin 243 print FLOG "Translating fdisk command to parted\n"; 244 while ($i = <STDIN>) { 245 if ($i =~ /^p$/) { 246 fdisk_list($device,undef,\%start,\%end, 1); 247 print "command (m for help) send back to fake fdisk for mondorestore\n"; 248 } elsif ($i =~ /^n$/) { 249 fdisk_list($device,undef,\%start,\%end, 0); 250 if ($type ne "gpt") { 251 print FLOG "Forcing GPT type of disk label\n"; 252 print FLOG "mklabel gpt\n"; 253 system "$parted -s $device mklabel gpt\n" if ($fake == 0); 254 $type = "gpt"; 236 # Check partition table type 237 $type = mr_disk_type($device); 238 # Replacement code only for GPT disks 239 if ((($v == 1) || (($v == 2) && ($maj < 22))) && ($type ne "msdos")) { 240 pb_log(1,"This distribution uses an old fdisk, activating replacement code for GPT disk label...\n"); 241 my $parted = pb_check_req("parted",0); 242 if (defined $opts{'l'}) { 243 fdisk_list($device,undef,\%start,\%end, 1); 244 } elsif (defined $opts{'s'}) { 245 fdisk_list($device,$wpart,\%start,\%end, 1); 246 } else { 247 # Read fdisk orders on stdin and pass them to parted 248 # on the command line as parted doesn't read on stdin 249 pb_log(1,"Translating fdisk command to parted\n"); 250 while ($i = <STDIN>) { 251 if ($i =~ /^p$/) { 252 fdisk_list($device,undef,\%start,\%end, 1); 253 print "command (m for help) sent back to fake fdisk for mondorestore\n"; 254 } elsif ($i =~ /^n$/) { 255 fdisk_list($device,undef,\%start,\%end, 0); 256 if ($type ne "gpt") { 257 pb_log(1,"Forcing GPT type of disk label\n"); 258 pb_log(1,"mklabel gpt\n"); 259 pb_system("$parted -s $device mklabel gpt\n") if ($fake == 0); 260 $type = "gpt"; 261 } 262 $l = <STDIN>; 263 if (not defined $l) { 264 pb_log(1,"no primary/extended arg given for creation... assuming primary\n"); 265 $l = "p"; 266 } 267 chomp($l); 268 $part = <STDIN>; 269 if ((not defined $part) || ($part eq "")) { 270 pb_log(1,"no partition given for creation... skipping\n"); 271 next; 272 } 273 chomp($part); 274 $cylstart = <STDIN>; 275 chomp($cylstart); 276 if ((not defined $cylstart) || ($cylstart eq "")) { 277 if (defined $start{$part-1}) { 278 # in MB => cyl 279 $cylstart = sprintf("%d",$end{$part-1}*$mega/$un + 1); 280 } else { 281 $cylstart = 1; 255 282 } 283 pb_log(1,"no start cyl given for creation... assuming the following: $cylstart\n"); 284 } else { 285 pb_log(1,"start cyl: $cylstart\n"); 286 } 287 $cylstart = 1 if ($cylstart < 1); 288 $un = get_un($device, "", 0); 289 # parted needs MB 290 if ($cylstart == 1) { 291 $start = 0.01; 292 } else { 293 $start = $cylstart* $un / $mega + 0.001; 294 } 295 # this is a size in B/KB/MB/GB 296 297 $endmax = get_max($device); 298 $cylend = <STDIN>; 299 chomp($cylend); 300 if ((not defined $cylend) || ($cylend eq "")) { 301 pb_log(1,"no end cyl given for creation... assuming full disk)\n"); 302 $cylend = $endmax; 303 } 304 # Handles end syntaxes (+, K, M, ...) 305 # to give cylinders 306 if ($cylend =~ /^\+/) { 307 $cylend =~ s/^\+//; 308 # Handles suffixes; return bytes 309 $cylend = decode_Bsuf($cylend,1); 310 # This gives the number of cyl 311 $cylend /= $un; 312 $cylend = sprintf("%d",$cylend); 313 $cylend += $cylstart - 0.001; 314 # We now have the end cyl 315 } 316 $cylend = $endmax if ($cylend > $endmax); 317 pb_log(1,"end cyl: $cylend\n"); 318 # parted needs MB 319 $end = $cylend * $un / $mega; 320 pb_log(1,"n $l $part $cylstart $cylend => mkpart primary $start $end\n"); 321 pb_system("$parted -s $device mkpart primary ext2 $start $end\n") if ($fake == 0); 322 print "command (m for help) sent back to fake fdisk for mondorestore\n"; 323 } elsif ($i =~ /^d$/) { 324 $part = <STDIN>; 325 if (not defined $part) { 326 pb_log(1,"no partition given for deletion... skipping\n"); 327 next; 328 } 329 chomp($part); 330 pb_log(1,"d $part => rm $part\n"); 331 pb_system("$parted -s $device rm $part\n") if ($fake == 0); 332 get_parted($device,undef,\%start,\%end,undef); 333 print "command (m for help) sent back to fake fdisk for mondorestore\n"; 334 } elsif ($i =~ /^w$/) { 335 pb_log(1,"w => quit\n"); 336 } elsif ($i =~ /^t$/) { 337 $part = <STDIN>; 338 if (not defined $part) { 339 pb_log(1,"no partition given for tagging... skipping\n"); 340 next; 341 } 342 chomp($part); 343 # If no partition number given it's 1, and we received the type 344 if ($part !~ /\d+/) { 345 $l = $part; 346 $part = 1 347 } else { 256 348 $l = <STDIN>; 257 if (not (defined $l)) { 258 print FLOG "no primary/extended arg given for creation... assuming primary\n"; 259 $l = "p"; 260 } 261 chomp($l); 262 $part = <STDIN>; 263 if ((not (defined $part)) || ($part eq "")) { 264 print FLOG "no partition given for creation... skipping\n"; 265 next; 266 } 267 chomp($part); 268 $cylstart = <STDIN>; 269 chomp($cylstart); 270 if ((not (defined $cylstart)) || ($cylstart eq "")) { 271 if (defined $start{$part-1}) { 272 # in MB => cyl 273 $cylstart = sprintf("%d",$end{$part-1}*$mega/$un + 1); 274 print FLOG "no start cyl given for creation... assuming the following $cylstart\n"; 275 } else { 276 print FLOG "no start cyl given for creation... assuming the following 1\n"; 277 $cylstart = 1; 278 } 279 } 280 $cylstart = 1 if ($cylstart < 1); 281 print FLOG "start cyl : $cylstart\n"; 282 $un = get_un($device, "", 0); 283 # parted needs MB 284 if ($cylstart == 1) { 285 $start = 0.01; 286 } else { 287 $start = $cylstart* $un / $mega + 0.001; 288 } 289 # this is a size in B/KB/MB/GB 290 291 $endmax = get_max($device); 292 $cylend = <STDIN>; 293 chomp($cylend); 294 if ((not (defined $cylend)) || ($cylend eq "")) { 295 print FLOG "no end cyl given for creation... assuming full disk)\n"; 296 $cylend = $endmax; 297 } 298 # Handles end syntaxes (+, K, M, ...) 299 # to give cylinders 300 if ($cylend =~ /^\+/) { 301 $cylend =~ s/^\+//; 302 # Handles suffixes; return bytes 303 $cylend = decode_Bsuf($cylend,1); 304 # This gives the number of cyl 305 $cylend /= $un; 306 $cylend = sprintf("%d",$cylend); 307 $cylend += $cylstart - 0.001; 308 # We now have the end cyl 309 } 310 $cylend = $endmax if ($cylend > $endmax); 311 print FLOG "end cyl : $cylend\n"; 312 # parted needs MB 313 $end = $cylend * $un / $mega; 314 print FLOG "n $l $part $cylstart $cylend => mkpart primary $start $end\n"; 315 system "$parted -s $device mkpart primary ext2 $start $end\n" if ($fake == 0); 316 print "command (m for help) send back to fake fdisk for mondorestore\n"; 317 } elsif ($i =~ /^d$/) { 318 $part = <STDIN>; 319 if (not (defined $part)) { 320 print FLOG "no partition given for deletion... skipping\n"; 321 next; 322 } 323 chomp($part); 324 print FLOG "d $part => rm $part\n"; 325 system "$parted -s $device rm $part\n" if ($fake == 0); 326 get_parted($device,undef,\%start,\%end,undef); 327 print "command (m for help) send back to fake fdisk for mondorestore\n"; 328 } elsif ($i =~ /^w$/) { 329 print FLOG "w => quit\n"; 330 } elsif ($i =~ /^t$/) { 331 $part = <STDIN>; 332 if (not (defined $part)) { 333 print FLOG "no partition given for tagging... skipping\n"; 334 next; 335 } 336 chomp($part); 337 # If no partition number given it's 1, and we received the type 338 if ($part !~ /\d+/) { 339 $l = $part; 340 $part = 1 341 } else { 342 $l = <STDIN>; 343 } 344 if (not (defined $l)) { 345 print FLOG "no type given for tagging partition $part... skipping\n"; 346 next; 347 } 348 chomp($l); 349 if (not (defined $pnum{$l})) { 350 print FLOG "no partition number given for $l... please report to the author\n"; 351 next; 352 } 353 354 if ($pnum{$l} eq "lvm") { 355 # In that case this is a flag set, not a mkfs 356 print FLOG "t $part $l => set $part $pnum{$l} on\n"; 357 system "$parted -s $device set $part $pnum{$l} on\n" if ($fake == 0); 358 } else { 359 print FLOG "t $part $l => mkfs $part $pnum{$l}\n"; 360 system "$parted -s $device mkfs $part $pnum{$l}\n" if ($fake == 0); 361 } 362 print "command (m for help) send back to fake fdisk for mondorestore\n"; 363 } elsif ($i =~ /^a$/) { 364 $part = <STDIN>; 365 if (not (defined $part)) { 366 print FLOG "no partition given for tagging... skipping\n"; 367 next; 368 } 369 chomp($part); 370 371 # Partition shouldn't be negative or null. Then take the first one. 372 $part = 1 if ($part le 0); 373 374 print FLOG "a $part => set $part boot on\n"; 375 system "$parted -s $device set $part boot on\n" if ($fake == 0); 376 print "command (m for help) send back to fake fdisk for mondorestore\n"; 377 } elsif ($i =~ /^q$/) { 378 print FLOG "q => quit\n"; 349 } 350 if (not defined $l) { 351 pb_log(1,"no type given for tagging partition $part... skipping\n"); 352 next; 353 } 354 chomp($l); 355 if (not defined $pnum{$l}) { 356 pb_log(1,"no partition number given for $l... please report to the author\n"); 357 next; 358 } 359 360 if ($pnum{$l} eq "lvm") { 361 # In that case this is a flag set, not a mkfs 362 pb_log(1,"t $part $l => set $part $pnum{$l} on\n"); 363 pb_system("$parted -s $device set $part $pnum{$l} on\n") if ($fake == 0); 379 364 } else { 380 print FLOG "Unknown command: $i\n"; 381 print "command (m for help) send back to fake fdisk for mondorestore\n"; 365 pb_log(1,"t $part $l => mkfs $part $pnum{$l}\n"); 366 pb_system("$parted -s $device mkfs $part $pnum{$l}\n") if ($fake == 0); 367 } 368 print "command (m for help) sent back to fake fdisk for mondorestore\n"; 369 } elsif ($i =~ /^a$/) { 370 $part = <STDIN>; 371 if (not defined $part) { 372 pb_log(1,"no partition given for tagging... skipping\n"); 382 373 next; 383 374 } 384 375 chomp($part); 376 377 # Partition shouldn't be negative or null. Then take the first one. 378 $part = 1 if ($part le 0); 379 380 pb_log(1,"a $part => set $part boot on\n"); 381 pb_system("$parted -s $device set $part boot on\n") if ($fake == 0); 382 print "command (m for help) sent back to fake fdisk for mondorestore\n"; 383 } elsif ($i =~ /^q$/) { 384 pb_log(1,"q => quit\n"); 385 } else { 386 pb_log(1,"Unknown command: $i\n"); 387 print "command (m for help) sent back to fake fdisk for mondorestore\n"; 388 next; 385 389 } 390 386 391 } 387 myexit(0);388 }392 } 393 exit(0); 389 394 } 390 395 … … 393 398 # 394 399 # Print only mode 395 local_fdisk($args,$device); 396 myexit(0); 400 local_fdisk(\%opts,$device); 401 exit(0); 402 403 # End of main 404 397 405 398 406 sub local_fdisk { 399 407 400 my $ args=shift;408 my $opts=shift; 401 409 my $device=shift; 402 410 403 print FLOG "Passing everything to the real fdisk with $args $device\n"; 404 405 if ($args =~ /^-/) { 406 # -l or -s 407 open (FDISK, "$fdisk $args $device 2>/dev/null |") || die "Unable to read from $fdisk"; 411 pb_log(1,"Passing everything to the real fdisk with device: $device\n"); 412 pb_log(1,"and the -s $wpart option\n") if (defined $opts{'s'}); 413 414 if ((defined $opts->{'l'}) || (defined $opts->{'s'})) { 415 my $args = "-l $device" if (defined $opts->{'l'}); 416 $args = "-s $wpart" if (defined $opts->{'s'}); 417 open (FDISK, "$fdisk $args 2>/dev/null |") || die "Unable to read from $fdisk"; 408 418 while (<FDISK>) { 409 419 print $_; … … 412 422 } else { 413 423 # Modification mode 414 open (FDISK, "| $fdisk $ args $device 2>/dev/null") || die "Unable to modify through $fdisk";424 open (FDISK, "| $fdisk $device 2>/dev/null") || die "Unable to modify through $fdisk"; 415 425 while (<STDIN>) { 416 426 print FDISK $_; … … 422 432 } 423 433 424 # Is your system LSB ?425 sub is_lsb {426 427 my $cmd = shift;428 my $basename = basename($cmd);429 430 if (not (-x $cmd)) {431 print FLOG "Your system is not LSB/mondo compliant: $basename was not found as $cmd\n";432 print FLOG "Searching elswhere...";433 foreach $i (split(':',$ENV{PATH})) {434 if (-x "$i/$basename") {435 $cmd = "$i/$basename";436 print FLOG "Found $cmd, using it !\n";437 last;438 }439 }440 if (not (-x $cmd)) {441 print FLOG "Your system doesn't provide $basename in the PATH\n";442 print FLOG "Please correct it before relaunching\n";443 myexit(-1);444 }445 }446 return($cmd);447 }448 449 434 # Unused for now - Kept for reference in case there is a need later on 450 435 sub fdisk_list_all { 436 451 437 my $device = shift; 452 438 my $wpart = shift; … … 555 541 556 542 if ($verbose == 1) { 557 if (not (defined $wpart)) {543 if (not defined $wpart) { 558 544 if (length($part) > 13) { 559 545 open(STDOUT2,">&STDOUT") || die "Unable to open STDOUT2"; … … 580 566 # manage the -s option of fdisk here 581 567 print "$length\n" if ($part eq $wpart); 582 p rint FLOG "$part has $length KBytes\n"if ($part eq $wpart);568 pb_log(1,"$part has $length KBytes\n") if ($part eq $wpart); 583 569 } 584 570 } … … 606 592 } 607 593 close(FDISK); 608 p rint FLOG "get_max returns $max\n";594 pb_log(2,"get_max returns $max\n"); 609 595 return($max); 610 596 } … … 631 617 } 632 618 close(FDISK); 633 p rint FLOG "get_un returns $un\n";619 pb_log(2,"get_un returns $un\n"); 634 620 return($un); 635 621 } … … 653 639 my $unit; 654 640 641 my $parted = pb_check_req("parted",0); 655 642 open (PARTED, "$parted -v |") || die "Unable to read from $parted"; 656 643 $d = <PARTED>; 657 p rint FLOG "$d";644 pb_log(2,"$d"); 658 645 close(PARTED); 659 646 chomp($d); … … 677 664 $mode=-1; 678 665 } 679 p rint FLOG "mode: $mode\n";680 681 open 666 pb_log(2,"parted mode: $mode\n"); 667 668 open(PARTED, "$parted -s $device print |") || die "Unable to read from $parted"; 682 669 # Skip 3 first lines 683 670 $d = <PARTED>; … … 690 677 $d = <PARTED>; 691 678 } 692 p rint FLOG "Got from parted: \n";693 p rint FLOG "Minor Start End Filesystem\n";679 pb_log(2,"Got from parted: \n"); 680 pb_log(2,"Minor Start End Filesystem\n"); 694 681 # Get info from each partition line 695 682 while (($n,$d) = split(/\s/, <PARTED>,2)) { … … 722 709 $ret = decode_Bsuf($$end{$n},$unit); 723 710 $$end{$n} = $ret; 724 p rint FLOG "$n $$start{$n} $$end{$n} $$type{$n}\n";711 pb_log(2,"$n $$start{$n} $$end{$n} $$type{$n}\n"); 725 712 } 726 713 close(PARTED); … … 733 720 my $ret = 0; 734 721 735 #print FLOG "decode_Bsuf input: $size / $unit ";722 pb_log(2,"decode_Bsuf input: $size / $unit "); 736 723 if ($size =~ /K[B]*$/i) { 737 724 $size =~ s/K[B]*$//i; … … 750 737 } 751 738 $ret = $size / $unit; 752 #print FLOG " - output : $size => $ret\n";739 pb_log(2," - output : $size => $ret\n"); 753 740 return($ret); 754 741 } 755 756 sub myexit {757 758 my $val=shift;759 760 close(FLOG);761 exit($val);762 }763 764 sub which_type {765 766 my $device = shift;767 my $type = "";768 769 open (FDISK, "$fdisk -l $device 2>/dev/null |") || die "Unable to read from $fdisk";770 while (<FDISK>) {771 if ($_ =~ /EFI GPT/) {772 $type= "gpt";773 print FLOG "Found a GPT partition format\n";774 last;775 }776 }777 close(FDISK);778 open (PARTED, "$parted -s $device print|") || die "Unable to read from $fdisk";779 while (<PARTED>) {780 if (($_ =~ /Disk label type: msdos/) || ($_ =~ /Partition Table: msdos/)) {781 $type= "msdos";782 print FLOG "Found a msdos partition format\n";783 last;784 }785 }786 close(FDISK);787 return ($type);788 }789 790 sub mysyn {791 print "Syntax: $0 [-l] device | [-s] partition\n";792 myexit(-1);793 }
Note:
See TracChangeset
for help on using the changeset viewer.