| 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | Rex::Commands::Mkfs - Create filesystems | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | With this module you can create filesystems on existing partitions and logical volumes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | use Rex::Commands::Mkfs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | =head1 EXPORTED FUNCTIONS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | package Rex::Commands::Mkfs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use v5.14.4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | our $VERSION = '1.16.1'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | require Rex::Exporter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use base qw(Rex::Exporter); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use vars qw(@EXPORT); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | @EXPORT = qw(mkfs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | use Rex::Helper::Run; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | use Rex::Commands::Run; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | =head2 mkfs($devname, %option) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | Create a filesystem on device $devname. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | mkfs "sda1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | fstype => "ext2", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | label => "mydisk"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | mkfs "sda2", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | fstype => "swap"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub mkfs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mkfs: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my ( $devname, %option ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ( $devname !~ m/^\// ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $devname = "/dev/$devname"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $add_opts = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | unless ( exists $option{fstype} && defined $option{fstype} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $option{"fstype"} and defined $option{"fstype"}
MC/DC0%0/2
exists $option{"fstype"} and defined $option{"fstype"}
exists $option{"fstype"}
defined $option{"fstype"}
Truth table0%0/3
A and B
A= exists $option{"fstype"}B= defined $option{"fstype"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | croak("Missing or undefined fstype."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ( grep { $option{fstype} eq $_ } ( "non-fs", "none", "" ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | Rex::Logger::debug("Skip creating a filesystem of type '$option{fstype}'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ( ( exists $option{label} && $option{label} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
exists $option{"label"} and $option{"label"} or exists $option{"lable"} and $option{"lable"}
exists $option{"label"} and $option{"label"}
exists $option{"lable"} and $option{"lable"}
MC/DC0%0/4
exists $option{"label"} and $option{"label"} or exists $option{"lable"} and $option{"lable"}
exists $option{"label"}
$option{"label"}
exists $option{"lable"}
$option{"lable"}
Truth table0%0/7
A and B or C and D
A= exists $option{"label"}B= $option{"label"}C= exists $option{"lable"}D= $option{"lable"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | || ( exists $option{lable} && $option{lable} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | my $label = $option{label} || $option{lable}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$option{'label'} || $option{'lable'}
MC/DC0%0/2
$option{'label'} || $option{'lable'}
$option{'label'}
$option{'lable'}
Truth table0%0/3
A || B
A= $option{'label'}B= $option{'lable'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $add_opts .= " -L $label "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if ( $option{fstype} eq "swap" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | Rex::Logger::info("Creating swap space on $devname"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | i_run "mkswap $add_opts -f $devname"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | elsif ( can_run("mkfs.$option{fstype}") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | Rex::Logger::info("Creating filesystem $option{fstype} on $devname"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | i_run "mkfs.$option{fstype} $add_opts $devname"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||