/usr/share/perl5/Rex/Commands/Mkfs.pm is in rex 1.4.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | =head1 NAME
Rex::Commands::Mkfs - Create filesystems
=head1 DESCRIPTION
With this module you can create filesystems on existing partitions and logical volumes.
=head1 SYNOPSIS
use Rex::Commands::Mkfs;
=head1 EXPORTED FUNCTIONS
=cut
package Rex::Commands::Mkfs;
use warnings;
use strict;
our $VERSION = '1.4.1'; # VERSION
require Rex::Exporter;
use base qw(Rex::Exporter);
use vars qw(@EXPORT);
@EXPORT = qw(mkfs);
use Rex::Commands::Run;
use Carp;
=head2 mkfs($devname, %option)
Create a filesystem on device $devname.
mkfs "sda1",
fstype => "ext2",
label => "mydisk";
mkfs "sda2",
fstype => "swap";
=cut
sub mkfs {
my ( $devname, %option ) = @_;
my $add_opts = "";
unless ( exists $option{fstype} && defined $option{fstype} ) {
croak("Missing or undefined fstype.");
}
if ( grep { $option{fstype} eq $_ } ( "non-fs", "none", "" ) ) {
Rex::Logger::debug("Skip creating a filesystem of type '$option{fstype}'");
return;
}
if ( ( exists $option{label} && $option{label} )
|| ( exists $option{lable} && $option{lable} ) )
{
my $label = $option{label} || $option{lable};
$add_opts .= " -L $label ";
}
if ( $option{fstype} eq "swap" ) {
Rex::Logger::info("Creating swap space on /dev/$devname");
run "mkswap $add_opts -f /dev/$devname";
}
elsif ( can_run("mkfs.$option{fstype}") ) {
Rex::Logger::info("Creating filesystem $option{fstype} on /dev/$devname");
run "mkfs.$option{fstype} $add_opts /dev/$devname";
}
return;
}
1;
|