1 | #!/usr/bin/perl -w
|
---|
2 | #
|
---|
3 | # parted2fdisk: fdisk like interface for parted
|
---|
4 | # [developped for mindi/mondo http://www.mondorescue.org]
|
---|
5 | #
|
---|
6 | # Aims to be architecture independant (i386/ia64)
|
---|
7 | # Tested on RHAS 2.1 ia64 - Mandrake 9.0 ia64 - RHAS 3.0 ia64
|
---|
8 | #
|
---|
9 | # (c) Bruno Cornec <Bruno.Cornec@hp.com>
|
---|
10 | # Licensed under the GPL
|
---|
11 |
|
---|
12 | use strict;
|
---|
13 |
|
---|
14 | $ENV{LANG} = "C";
|
---|
15 | $ENV{LANGUAGE} = "C";
|
---|
16 | $ENV{LC_ALL} = "C";
|
---|
17 |
|
---|
18 | # Log
|
---|
19 | my $flog = "/tmp/parted2fdisk.log";
|
---|
20 | open(FLOG, "> $flog") || die "Unable to open $flog";
|
---|
21 |
|
---|
22 | my $fdisk = "/sbin/fdisk";
|
---|
23 | my $parted = "/sbin/parted";
|
---|
24 |
|
---|
25 | my $i;
|
---|
26 | my $l;
|
---|
27 | my $part;
|
---|
28 | my $wpart;
|
---|
29 | my $start = "";
|
---|
30 | my $end = "";
|
---|
31 | my %start;
|
---|
32 | my %end;
|
---|
33 | my %type;
|
---|
34 | my %flags;
|
---|
35 | my $arch;
|
---|
36 |
|
---|
37 | # Determine on which arch we're running
|
---|
38 | if (defined ($ENV{ARCH})) {
|
---|
39 | $arch = $ENV{ARCH};
|
---|
40 | } else {
|
---|
41 | $arch = `"/bin/arch"`;
|
---|
42 | chomp($arch);
|
---|
43 | }
|
---|
44 |
|
---|
45 | #
|
---|
46 | # Looking for fdisk
|
---|
47 | #
|
---|
48 | $fdisk = is_lsb($fdisk);
|
---|
49 | #
|
---|
50 | # We always use fdisk except on ia64 with GPT types of
|
---|
51 | # partition tables where we need parted
|
---|
52 | # All should return fdisk like format so that callers
|
---|
53 | # think they have called fdisk directly
|
---|
54 | #
|
---|
55 | my $un;
|
---|
56 | my $type;
|
---|
57 | my $args = "";
|
---|
58 | my $device = "";
|
---|
59 |
|
---|
60 | if ($#ARGV < 0) {
|
---|
61 | printf FLOG "No arguments given exiting ...\n";
|
---|
62 | mysyn();
|
---|
63 | }
|
---|
64 |
|
---|
65 | my %pid = ( "FAT" => "6",
|
---|
66 | "fat32" => "b",
|
---|
67 | "fat16" => "e",
|
---|
68 | "ext2" => "83",
|
---|
69 | "ext3" => "83",
|
---|
70 | "linux-swap" => "82",
|
---|
71 | "LVM" => "8e",
|
---|
72 | "" => "",
|
---|
73 | );
|
---|
74 | my %pnum;
|
---|
75 |
|
---|
76 | # Reverse table of pid
|
---|
77 | while (($i,$l) = each %pid) {
|
---|
78 | next if ($i eq "ext2");
|
---|
79 | $pnum{$l} = $i;
|
---|
80 | }
|
---|
81 |
|
---|
82 | foreach $i (@ARGV) {
|
---|
83 | # We support at most one option and one device
|
---|
84 | print FLOG "Parameter found : $i\n";
|
---|
85 | if ($i =~ /^\/dev\//) {
|
---|
86 | $device = $i;
|
---|
87 | next;
|
---|
88 | } elsif ($i =~ /^-/) {
|
---|
89 | $args = $i;
|
---|
90 | next;
|
---|
91 | } else {
|
---|
92 | mysyn();
|
---|
93 | }
|
---|
94 | }
|
---|
95 |
|
---|
96 | if (($args ne "") and ($device eq "")) {
|
---|
97 | mysyn();
|
---|
98 | }
|
---|
99 |
|
---|
100 | # -s takes a partition as arg
|
---|
101 | if ($args =~ /-s/) {
|
---|
102 | $wpart = $device;
|
---|
103 | $device =~ s/[0-9]+$//;
|
---|
104 | }
|
---|
105 |
|
---|
106 | print FLOG "Called with device $device and arg $args\n";
|
---|
107 |
|
---|
108 | if ($arch =~ /^ia64/) {
|
---|
109 | # Check partition table type
|
---|
110 | print FLOG "We're on ia64 ...\n";
|
---|
111 | $parted = is_lsb($parted);
|
---|
112 | $type = which_type($device);
|
---|
113 | if ($type ne "msdos") {
|
---|
114 | print FLOG "Not an msdos type of disk label\n";
|
---|
115 | if ($args =~ /-l/) {
|
---|
116 | fdisk_list($device,undef,\%start,\%end);
|
---|
117 | } elsif ($args =~ /-s/) {
|
---|
118 | fdisk_list($device,$wpart,\%start,\%end);
|
---|
119 | } elsif ($args =~ /-/) {
|
---|
120 | printf FLOG "Option not supported ($args) ...\n";
|
---|
121 | printf FLOG "Please report to the author\n";
|
---|
122 | mysyn();
|
---|
123 | } else {
|
---|
124 | # Read fdisk orders on stdin and pass them to parted
|
---|
125 | # on the command line as parted doesn't read on stdin
|
---|
126 | print FLOG "Translating fdisk command to parted\n";
|
---|
127 | while ($i = <STDIN>) {
|
---|
128 | if ($i =~ /^p$/) {
|
---|
129 | fdisk_list($device,undef,\%start,\%end);
|
---|
130 | }
|
---|
131 | elsif ($i =~ /^n$/) {
|
---|
132 | fdisk_list($device,undef,\%start,\%end);
|
---|
133 | if ($type ne "gpt") {
|
---|
134 | print FLOG "Forcing GPT type of disk label\n";
|
---|
135 | print FLOG "mklabel gpt\n";
|
---|
136 | system "$parted -s $device mklabel gpt\n";
|
---|
137 | $type = "gpt";
|
---|
138 | }
|
---|
139 | $l = <STDIN>;
|
---|
140 | if (not (defined $l)) {
|
---|
141 | print FLOG "no primary/extended arg given for creation... assuming primary\n";
|
---|
142 | $l = "p";
|
---|
143 | }
|
---|
144 | chomp($l);
|
---|
145 | $part = <STDIN>;
|
---|
146 | if ((not (defined $part)) || ($part eq "")) {
|
---|
147 | print FLOG "no partition given for creation... skipping\n";
|
---|
148 | next;
|
---|
149 | }
|
---|
150 | chomp($part);
|
---|
151 | $start = <STDIN>;
|
---|
152 | chomp($start);
|
---|
153 | if ((not (defined $start)) || ($start eq "")) {
|
---|
154 | if (defined $start{$part-1}) {
|
---|
155 | $start = scalar $end{$part-1} + 0.001;
|
---|
156 | print FLOG "no start cyl given for creation... assuming the following $start\n";
|
---|
157 | } else {
|
---|
158 | print FLOG "no start cyl given for creation... assuming the following 1\n";
|
---|
159 | $start = 1;
|
---|
160 | }
|
---|
161 | }
|
---|
162 | print FLOG "start cyl : $start\n";
|
---|
163 | $end = <STDIN>;
|
---|
164 | chomp($end);
|
---|
165 | if ((not (defined $end)) || ($end eq "")) {
|
---|
166 | print FLOG "no end cyl given for creation... assuming full disk)\n";
|
---|
167 | $end = get_max($device);
|
---|
168 | }
|
---|
169 | $un = get_un($device);
|
---|
170 | # Handles end syntaxes (+, K, M, ...)
|
---|
171 | if ($end =~ /^\+/) {
|
---|
172 | $end =~ s/^\+//;
|
---|
173 | if ($end =~ /K$/) {
|
---|
174 | $end =~ s/K$//;
|
---|
175 | $end *= 1000;
|
---|
176 | } elsif ($end =~ /M$/) {
|
---|
177 | $end =~ s/M$//;
|
---|
178 | $end *= 1000000;
|
---|
179 | } elsif ($end =~ /G$/) {
|
---|
180 | $end =~ s/G$//;
|
---|
181 | $end *= 1000000000;
|
---|
182 | }
|
---|
183 | $end /= $un;
|
---|
184 | $end = int($end)+1;
|
---|
185 | $end += $start - 0.001;
|
---|
186 | }
|
---|
187 | print FLOG "end cyl : $end\n";
|
---|
188 | print FLOG "n $l $part $start $end => mkpart primary $start $end\n";
|
---|
189 | system "$parted -s $device mkpart primary ext2 $start $end\n";
|
---|
190 | }
|
---|
191 | elsif ($i =~ /^d$/) {
|
---|
192 | $part = <STDIN>;
|
---|
193 | if (not (defined $part)) {
|
---|
194 | print FLOG "no partition given for deletion... skipping\n";
|
---|
195 | next;
|
---|
196 | }
|
---|
197 | chomp($part);
|
---|
198 | print FLOG "d $part => rm $part\n";
|
---|
199 | system "$parted -s $device rm $part\n";
|
---|
200 | get_parted($device,undef,\%start,\%end,undef,undef);
|
---|
201 | }
|
---|
202 | elsif ($i =~ /^w$/) {
|
---|
203 | print FLOG "w => quit\n";
|
---|
204 | }
|
---|
205 | elsif ($i =~ /^t$/) {
|
---|
206 | $part = <STDIN>;
|
---|
207 | if (not (defined $part)) {
|
---|
208 | print FLOG "no partition given for tagging... skipping\n";
|
---|
209 | next;
|
---|
210 | }
|
---|
211 | chomp($part);
|
---|
212 | $l = <STDIN>;
|
---|
213 | if (not (defined $l)) {
|
---|
214 | print FLOG "no type given for tagging partition $part... skipping\n";
|
---|
215 | next;
|
---|
216 | }
|
---|
217 | chomp($l);
|
---|
218 | if (not (defined $pnum{$l})) {
|
---|
219 | print FLOG "no partition number given for $l... please report to the author\n";
|
---|
220 | next;
|
---|
221 | }
|
---|
222 | print FLOG "t $part => mkfs $part $pnum{$l}\n";
|
---|
223 | system "$parted -s $device mkfs $part $pnum{$l}\n";
|
---|
224 | }
|
---|
225 | elsif ($i =~ /^a$/) {
|
---|
226 | $part = <STDIN>;
|
---|
227 | if (not (defined $part)) {
|
---|
228 | print FLOG "no partition given for tagging... skipping\n";
|
---|
229 | next;
|
---|
230 | }
|
---|
231 | chomp($part);
|
---|
232 | print FLOG "a $part => set $part boot on\n";
|
---|
233 | system "$parted -s $device set $part boot on\n";
|
---|
234 | }
|
---|
235 | elsif ($i =~ /^q$/) {
|
---|
236 | print FLOG "q => quit\n";
|
---|
237 | }
|
---|
238 | else {
|
---|
239 | print FLOG "Unknown command: $i\n";
|
---|
240 | next;
|
---|
241 | }
|
---|
242 |
|
---|
243 | }
|
---|
244 | }
|
---|
245 | myexit(0);
|
---|
246 | }
|
---|
247 | }
|
---|
248 |
|
---|
249 | #
|
---|
250 | # Else everything is for fdisk
|
---|
251 | #
|
---|
252 | # Print only mode
|
---|
253 | print FLOG "Passing everything to the real fdisk\n";
|
---|
254 | my $fargs = join(@ARGV);
|
---|
255 |
|
---|
256 | if ($args =~ /^-/) {
|
---|
257 | # -l or -s
|
---|
258 | open (FDISK, "$fdisk $fargs |") || die "Unable to read from $fdisk";
|
---|
259 | while (<FDISK>) {
|
---|
260 | print;
|
---|
261 | }
|
---|
262 | close(FDISK);
|
---|
263 | } else {
|
---|
264 | # Modification mode
|
---|
265 | open (FDISK, "| $fdisk $fargs") || die "Unable to modify through $fdisk";
|
---|
266 | while (<STDIN>) {
|
---|
267 | print FDISK;
|
---|
268 | }
|
---|
269 | close(FDISK);
|
---|
270 | close(STDIN);
|
---|
271 | }
|
---|
272 | myexit(0);
|
---|
273 |
|
---|
274 |
|
---|
275 | # Is your system LSB ?
|
---|
276 | sub is_lsb {
|
---|
277 |
|
---|
278 | my $cmd = shift;
|
---|
279 | my $basename = basename($cmd);
|
---|
280 | my $mindifdisk="/usr/local/bin/fdisk";
|
---|
281 |
|
---|
282 | if ($cmd =~ /fdisk/) {
|
---|
283 | if ($arch =~ /^ia64/) {
|
---|
284 | if (-l $cmd) {
|
---|
285 | print FLOG "Your system is ready for mondo-archive on ia64\n";
|
---|
286 | } else {
|
---|
287 | print FLOG "Your system is ready for mondo-restore on ia64\n";
|
---|
288 | }
|
---|
289 | if (-x $mindifdisk) {
|
---|
290 | $cmd = $mindifdisk;
|
---|
291 | } else {
|
---|
292 | print FLOG "Your system doesn't provide $mindifdisk\n";
|
---|
293 | print FLOG "Please use mindi-x.yz-ia64.rpm on the system to backup\n";
|
---|
294 | myexit(-1);
|
---|
295 | }
|
---|
296 | }
|
---|
297 | }
|
---|
298 | if (not (-x $cmd)) {
|
---|
299 | print FLOG "Your system is not LSB/mondo compliant: $basename was not found as $cmd\n";
|
---|
300 | print FLOG "Searching elswhere...";
|
---|
301 | foreach $i (split(':',$ENV{PATH})) {
|
---|
302 | if (-x "$i/$basename") {
|
---|
303 | $cmd = "$i/$basename";
|
---|
304 | print FLOG "Found $cmd, using it !\n";
|
---|
305 | last;
|
---|
306 | }
|
---|
307 | }
|
---|
308 | if (not (-x $cmd)) {
|
---|
309 | print FLOG "Your system doesn't provide $basename in the PATH\n";
|
---|
310 | print FLOG "Please correct it before relaunching\n";
|
---|
311 | myexit(-1);
|
---|
312 | }
|
---|
313 | }
|
---|
314 | return($cmd);
|
---|
315 | }
|
---|
316 |
|
---|
317 | sub fdisk_list {
|
---|
318 |
|
---|
319 | my $device = shift;
|
---|
320 | my $wpart = shift;
|
---|
321 | my $start = shift;
|
---|
322 | my $end = shift;
|
---|
323 |
|
---|
324 | my $un;
|
---|
325 | my $d;
|
---|
326 | my $n;
|
---|
327 |
|
---|
328 | my %cmt = ( "FAT" => "FAT",
|
---|
329 | "ext2" => "Linux",
|
---|
330 | "ext3" => "Linux",
|
---|
331 | "linux-swap" => "Linux swap",
|
---|
332 | "LVM" => "Linux LVM",
|
---|
333 | "fat16" => "fat16",
|
---|
334 | "fat32" => "fat32",
|
---|
335 | "" => "Linux",
|
---|
336 | );
|
---|
337 |
|
---|
338 | my $part;
|
---|
339 | my $mstart;
|
---|
340 | my $mend;
|
---|
341 | my $length;
|
---|
342 | my $pid;
|
---|
343 | my $cmt;
|
---|
344 | format FLOG1 =
|
---|
345 | @<<<<<<<<<<<< @>>>>>>>> @>>>>>>>> @>>>>>>>> @>>> @<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
---|
346 | $part, $mstart, $mend, $length, $pid, $cmt
|
---|
347 | .
|
---|
348 | format FLOG2 =
|
---|
349 | @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
---|
350 | $part,
|
---|
351 | @>>>>>>>> @>>>>>>>> @>>>>>>>> @>>> @<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
---|
352 | $mstart, $mend, $length, $pid, $cmt
|
---|
353 | .
|
---|
354 | format STDOUT1 =
|
---|
355 | @<<<<<<<<<<<< @>>>>>>>> @>>>>>>>> @>>>>>>>> @>>> @<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
---|
356 | $part, $mstart, $mend, $length, $pid, $cmt
|
---|
357 | .
|
---|
358 | format STDOUT2 =
|
---|
359 | @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
---|
360 | $part,
|
---|
361 | @>>>>>>>> @>>>>>>>> @>>>>>>>> @>>> @<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
---|
362 | $mstart, $mend, $length, $pid, $cmt
|
---|
363 | .
|
---|
364 | #/dev/hda1 1 77579 39099374+ ee EFI GPT
|
---|
365 |
|
---|
366 | #
|
---|
367 | # Keep Fdisk headers
|
---|
368 | #
|
---|
369 | $un = get_un ($device,$wpart);
|
---|
370 | get_parted ($device,$start,$end,\%type,\%flags);
|
---|
371 |
|
---|
372 | while (($n,$d) = each %type) {
|
---|
373 | # Print infos fdisk like
|
---|
374 | $part = ${device}.$n;
|
---|
375 | $mstart = sprintf("%d",int($$start{$n}));
|
---|
376 | $mend = sprintf("%d",int($$end{$n}));
|
---|
377 | $length = sprintf("%d",($mend-$mstart+1)*$un/1048576);
|
---|
378 | $pid = $pid{$type{$n}};
|
---|
379 | $cmt = $cmt{$type{$n}};
|
---|
380 | print FLOG "$part - $mstart - $mend - $length\n";
|
---|
381 |
|
---|
382 | if (not (defined $wpart)) {
|
---|
383 | if (length($part) > 13) {
|
---|
384 | open(STDOUT2,">&STDOUT") || die "Unable to open STDOUT2";
|
---|
385 | select(STDOUT2);
|
---|
386 | write;
|
---|
387 | open(FLOG2,">&FLOG") || die "Unable to open FLOG2";
|
---|
388 | select(FLOG2);
|
---|
389 | write;
|
---|
390 | select(STDOUT);
|
---|
391 | close(FLOG2);
|
---|
392 | close(STDOUT2);
|
---|
393 | } else {
|
---|
394 | open(STDOUT1,">&STDOUT") || die "Unable to open STDOUT1";
|
---|
395 | select(STDOUT1);
|
---|
396 | write;
|
---|
397 | open(FLOG1,">&FLOG") || die "Unable to open FLOG1";
|
---|
398 | select(FLOG1);
|
---|
399 | write;
|
---|
400 | select(STDOUT);
|
---|
401 | close(FLOG1);
|
---|
402 | close(STDOUT1);
|
---|
403 | }
|
---|
404 | } else {
|
---|
405 | # manage the -s option of fdisk here
|
---|
406 | my $s = int(eval("$length/1048576*$un*1024"));
|
---|
407 | print "$s\n" if ($part eq $wpart);
|
---|
408 | print FLOG "$part has $s Bytes\n" if ($part eq $wpart);
|
---|
409 | }
|
---|
410 | }
|
---|
411 | close(FDISK);
|
---|
412 | close(PARTED);
|
---|
413 | }
|
---|
414 |
|
---|
415 | #
|
---|
416 | # Get max size from fdisk
|
---|
417 | #
|
---|
418 | sub get_max {
|
---|
419 |
|
---|
420 | my $device = shift;
|
---|
421 | my $max = 0;
|
---|
422 | my $foo;
|
---|
423 |
|
---|
424 | open (FDISK, "$fdisk -l $device |") || die "Unable to read from $fdisk";
|
---|
425 | while (<FDISK>) {
|
---|
426 | if ($_ =~ /^Disk/) {
|
---|
427 | ($foo, $un , $foo) = split /=/;
|
---|
428 | $max =~ s/.*sectors,([0-9]+) cylinders/$1/g;
|
---|
429 | $max = eval($max);
|
---|
430 | }
|
---|
431 | }
|
---|
432 | close(FDISK);
|
---|
433 | print FLOG "get_max returns $max\n";
|
---|
434 | return($max);
|
---|
435 | }
|
---|
436 |
|
---|
437 | #
|
---|
438 | # Get units from fdisk
|
---|
439 | #
|
---|
440 | sub get_un {
|
---|
441 |
|
---|
442 | my $device = shift;
|
---|
443 | my $wpart = shift;
|
---|
444 | my $un = 0;
|
---|
445 | my $foo;
|
---|
446 |
|
---|
447 | open (FDISK, "$fdisk -l $device |") || die "Unable to read from $fdisk";
|
---|
448 | while (<FDISK>) {
|
---|
449 | print if (($_ !~ /^\/dev\//) and (not (defined $wpart)));
|
---|
450 | if ($_ =~ /^Units/) {
|
---|
451 | ($foo, $un , $foo) = split /=/;
|
---|
452 | $un =~ s/[A-z\s=]//g;
|
---|
453 | $un = eval($un);
|
---|
454 | }
|
---|
455 | }
|
---|
456 | close(FDISK);
|
---|
457 | print FLOG "get_un returns $un\n";
|
---|
458 | return($un);
|
---|
459 | }
|
---|
460 |
|
---|
461 | sub get_parted {
|
---|
462 |
|
---|
463 | my $device = shift;
|
---|
464 | my $start = shift;
|
---|
465 | my $end = shift;
|
---|
466 | my $type = shift;
|
---|
467 | my $flags = shift;
|
---|
468 | my $d;
|
---|
469 | my $n;
|
---|
470 |
|
---|
471 | open (PARTED, "$parted -s $device print |") || die "Unable to read from $parted";
|
---|
472 | # Skip 3 first lines
|
---|
473 | $d = <PARTED>;
|
---|
474 | $d = <PARTED>;
|
---|
475 | $d = <PARTED>;
|
---|
476 | print FLOG "Got from parted: \n";
|
---|
477 | print FLOG "Minor Start End Filesystem Flags\n";
|
---|
478 | # Get info from each partition line
|
---|
479 | while (($n,$d) = split(/\s/, <PARTED>,2)) {
|
---|
480 | chomp($d);
|
---|
481 | next if ($n !~ /^[1-9]/);
|
---|
482 | $d =~ s/^\s*//;
|
---|
483 | $d =~ s/\s+/ /g;
|
---|
484 | ($$start{$n},$$end{$n},$$type{$n},$$flags{$n}) = split(/ /,$d);
|
---|
485 | $$start{$n} = "" if (not defined $$start{$n});
|
---|
486 | $$end{$n} = "" if (not defined $$end{$n});
|
---|
487 | $$type{$n} = "" if (not defined $$type{$n});
|
---|
488 | $$flags{$n} = "" if (not defined $$flags{$n});
|
---|
489 | print FLOG "$n $$start{$n} $$end{$n} $$type{$n} $$flags{$n}\n";
|
---|
490 | }
|
---|
491 | close(PARTED);
|
---|
492 | }
|
---|
493 |
|
---|
494 | # Based on Version 2.4 27-Sep-1996 Charles Bailey bailey@genetics.upenn.edu
|
---|
495 | # in Basename.pm
|
---|
496 |
|
---|
497 | sub basename {
|
---|
498 |
|
---|
499 | my($fullname) = shift;
|
---|
500 |
|
---|
501 | my($dirpath,$basename);
|
---|
502 |
|
---|
503 | ($dirpath,$basename) = ($fullname =~ m#^(.*/)?(.*)#s);
|
---|
504 |
|
---|
505 | return($basename);
|
---|
506 | }
|
---|
507 |
|
---|
508 | sub myexit {
|
---|
509 |
|
---|
510 | my $val=shift;
|
---|
511 |
|
---|
512 | close(FLOG);
|
---|
513 | exit($val);
|
---|
514 | }
|
---|
515 |
|
---|
516 | sub which_type {
|
---|
517 |
|
---|
518 | my $device = shift;
|
---|
519 | my $type = "";
|
---|
520 |
|
---|
521 | open (FDISK, "$fdisk -l $device |") || die "Unable to read from $fdisk";
|
---|
522 | while (<FDISK>) {
|
---|
523 | if ($_ =~ /EFI GPT/) {
|
---|
524 | $type= "gpt";
|
---|
525 | print FLOG "Found a GPT partition format\n";
|
---|
526 | last;
|
---|
527 | }
|
---|
528 | }
|
---|
529 | close(FDISK);
|
---|
530 | open (PARTED, "$parted -s $device print|") || die "Unable to read from $fdisk";
|
---|
531 | while (<PARTED>) {
|
---|
532 | if ($_ =~ /Disk label type: msdos/) {
|
---|
533 | $type= "msdos";
|
---|
534 | print FLOG "Found a msdos partition format\n";
|
---|
535 | last;
|
---|
536 | }
|
---|
537 | }
|
---|
538 | close(FDISK);
|
---|
539 | return ($type);
|
---|
540 | }
|
---|
541 |
|
---|
542 | sub mysyn {
|
---|
543 | print "Syntax: $0 [-l] device | [-s] partition\n";
|
---|
544 | myexit(-1);
|
---|
545 | }
|
---|