- Timestamp:
- Mar 5, 2015, 1:25:41 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi/parted2fdisk.pl
r3344 r3355 7 7 # 8 8 # Aims to be architecture independant (i386/ia64) 9 # Tested on ia64 with RHAS 2.1 - Mandrake 9.0 - RHEL 3.0 - SLES 10 9 # Tested on ia64 with RHAS 2.1 - Mandrake 9.0 - RHEL 3.0 - SLES 10 - RHEL 5 - 10 10 # 11 11 # Copyright B. Cornec 2000-2015 … … 29 29 30 30 parted2fdisk -s partition 31 parted2fdisk -l device31 parted2fdisk -l [device] 32 32 parted2fdisk [-n] device 33 33 … … 46 46 =item B<-l> 47 47 48 List the partition tables for the specified device and then exit.48 List the partition tables for the specified device (or all if none specified) and then exit. 49 49 50 50 =item B<no option> … … 175 175 } 176 176 177 if (($args ne "") and($device eq "")) {177 if (($args ne "") && ($args ne "-l") && ($device eq "")) { 178 178 mysyn(); 179 179 } … … 191 191 192 192 print FLOG "Called with device $device and arg $args\n"; 193 194 if (($args =~ /-l/) && ($device eq "")) { 195 # Pass to real fdisk directly 196 local_fdisk($args,$device); 197 myexit(0); 198 } 193 199 194 200 # util-linux/fdisk version … … 197 203 close(CMD); 198 204 chomp($version); 199 $version =~ s/[^0-9\.]*([0-9\.]+)[\)]*$/$1/; 205 # RHEL 5 has fdisk (util-linux 2.13-pre7) 206 # Mageia 4 has fdisk from util-linux 2.24.2 207 $version =~ s/[^0-9\.]*([0-9a-z\.-]+)[\)]*$/$1/; 200 208 my ($v,$maj,$min) = split(/\./,$version); 209 210 # Consider pre version the same as the following for formats 211 if ((defined $maj) && ($maj =~ /-pre/)) { 212 $maj =~ s/-pre.*$//; 213 $maj++; 214 } 215 if ((defined $min) && ($min =~ /-pre/)) { 216 $min =~ s/-pre.*$//; 217 $min++; 218 } 201 219 202 220 if (($v == 1) || (($v == 2) && ($maj < 22))) { … … 370 388 # 371 389 # Print only mode 390 local_fdisk($args,$device); 391 myexit(0); 392 393 sub local_fdisk { 394 395 my $args=shift; 396 my $device=shift; 397 372 398 print FLOG "Passing everything to the real fdisk with $args $device\n"; 373 399 … … 388 414 close(STDIN); 389 415 } 390 myexit(0);391 416 return; 417 } 392 418 393 419 # Is your system LSB ? … … 415 441 return($cmd); 416 442 } 443 444 # Unused for now - Kept for reference in case there is a need later on 445 sub fdisk_list_all { 446 my $device = shift; 447 my $wpart = shift; 448 my $start = shift; 449 my $end = shift; 450 my $verbose = shift; 451 452 return fdisk_list($device,$wpart,$start,$end,$verbose) if ((defined $device) && ($device ne "")); 453 454 # If no device given loop on the list of devices found in /proc/partitions 455 open(PART,"/proc/partitions") || die "Unable to open /proc/partitions"; 456 while (<PART>) { 457 my ($maj,$min,$blocks,$dev) = split(/\s+/); 458 next if ($dev =~ /^fd|^sr/); 459 next if ($min != 0); 460 fdisk_list("/dev/$dev",$wpart,$start,$end,$verbose); 461 } 462 close(PART); 463 } 464 417 465 418 466 sub fdisk_list { … … 482 530 483 531 # This will return MB 484 get_parted 532 get_parted($device,$start,$end,\%type); 485 533 486 534 while (($n,$d) = each %type) {
Note:
See TracChangeset
for help on using the changeset viewer.