Last change
on this file since 3369 was 3369, checked in by Bruno Cornec, 9 years ago |
- Fix syntax errors in module Disk.pm
|
File size:
1.2 KB
|
Rev | Line | |
---|
[3365] | 1 | #!/usr/bin/perl -w
|
---|
| 2 | #
|
---|
| 3 | # Disk subroutines brought by the MondoRescue project
|
---|
| 4 | #
|
---|
| 5 | # $Id$
|
---|
| 6 | #
|
---|
| 7 | # Copyright B. Cornec 2008-2015
|
---|
| 8 | # Provided under the GPL v2
|
---|
| 9 |
|
---|
| 10 | package MondoRescue::Disk;
|
---|
| 11 |
|
---|
| 12 | use strict 'vars';
|
---|
| 13 | use ProjectBuilder::Base;
|
---|
| 14 | use English;
|
---|
| 15 |
|
---|
| 16 | # Inherit from the "Exporter" module which handles exporting functions.
|
---|
| 17 |
|
---|
| 18 | use Exporter;
|
---|
| 19 |
|
---|
| 20 | # Export, by default, all the functions into the namespace of
|
---|
| 21 | # any code which uses this module.
|
---|
| 22 |
|
---|
| 23 | our @ISA = qw(Exporter);
|
---|
| 24 | our @EXPORT = qw(mr_disk_type);
|
---|
| 25 |
|
---|
| 26 | =pod
|
---|
| 27 |
|
---|
| 28 | =head1 NAME
|
---|
| 29 |
|
---|
| 30 | MondoRescue::Disk, part of the mondorescue.org
|
---|
| 31 |
|
---|
| 32 | =head1 DESCRIPTION
|
---|
| 33 |
|
---|
| 34 | This modules provides disk related functions for the Mondorescue project
|
---|
| 35 |
|
---|
| 36 | =head1 USAGE
|
---|
| 37 |
|
---|
| 38 | =over 4
|
---|
| 39 |
|
---|
| 40 | =item B<mr_disk_type>
|
---|
| 41 |
|
---|
| 42 | This function uses fdisk to determine the type of disk whose device is passed as a parameter
|
---|
| 43 | It returns either msdos for MBR type or gpt for GPT type
|
---|
| 44 |
|
---|
| 45 | =cut
|
---|
| 46 |
|
---|
| 47 | sub mr_disk_type {
|
---|
| 48 |
|
---|
| 49 | my $device = shift;
|
---|
| 50 | # MBR by default
|
---|
| 51 | my $type = "msdos";
|
---|
| 52 |
|
---|
| 53 | my $fdisk = pb_check_req("fdisk",0);
|
---|
| 54 |
|
---|
| 55 | open(FDISK, "$fdisk -l $device 2>/dev/null |") || die "Unable to read from $fdisk";
|
---|
| 56 | while (<FDISK>) {
|
---|
[3369] | 57 | if (($_ =~ /EFI GPT/) || ($_ =~ / GPT /)) {
|
---|
[3365] | 58 | $type= "gpt";
|
---|
| 59 | last;
|
---|
| 60 | }
|
---|
| 61 | }
|
---|
| 62 | close(FDISK);
|
---|
[3369] | 63 | pb_log(2,"Found a $type partition format\n");
|
---|
[3365] | 64 | return ($type);
|
---|
| 65 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.