summaryrefslogtreecommitdiffstats
path: root/perl-install/fs/format.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/fs/format.pm')
-rw-r--r--perl-install/fs/format.pm95
1 files changed, 89 insertions, 6 deletions
diff --git a/perl-install/fs/format.pm b/perl-install/fs/format.pm
index 1e1175b3e..b75ed54a6 100644
--- a/perl-install/fs/format.pm
+++ b/perl-install/fs/format.pm
@@ -10,6 +10,20 @@ use fs::type;
use fs::loopback;
use log;
+=head1 SYNOPSYS
+
+B<fs::format> enables to format filesystems.
+
+=head1 Variables
+
+=over
+
+=item %cmds
+
+For each filesystem, list: [ package_name, command_to_use, options_to_use ]
+
+=cut
+
my %cmds = (
ext2 => [ 'e2fsprogs', 'mkfs.ext2', '-F' ],
ext3 => [ 'e2fsprogs', 'mkfs.ext3', '-F' ],
@@ -27,7 +41,14 @@ my %cmds = (
nilfs2 => [ 'nilfs-utils', 'mkfs.nilfs2', '-f' ],
);
-my %LABELs = ( #- option, length, handled_by_mount
+
+=item %LABELs
+
+For each filesystem, list: [ option, max_length, handled_by_mount ]
+
+=cut
+
+my %LABELs = (
ext2 => [ '-L', 16, 1 ],
ext3 => [ '-L', 16, 1 ],
ext4 => [ '-L', 16, 1 ],
@@ -44,9 +65,17 @@ my %LABELs = ( #- option, length, handled_by_mount
nilfs2 => [ '-L', 16, 1 ],
);
-my %edit_LABEL = ( # package, command, option
-# If option is defined, run <command> <option> <label> <device>
-# If no option, run <command> <device> <label>
+=item %edit_LABEL
+
+For each filesystem, list: [ package, command, option ]
+
+If option is defined, run <command> <option> <label> <device>
+
+If no option, run <command> <device> <label>
+
+=cut
+
+my %edit_LABEL = ( #
ext2 => [ 'e2fsprogs', 'tune2fs', '-L' ],
ext3 => [ 'e2fsprogs', 'tune2fs', '-L' ],
ext4 => [ 'e2fsprogs', 'tune2fs', '-L' ],
@@ -63,13 +92,33 @@ my %edit_LABEL = ( # package, command, option
nilfs2 => [ 'nilfs-utils', 'nilfs-tune', '-L' ],
);
-# Preserve UUID on fs where we couldn't enforce it while formatting
+=item %preserve_UUID
+
+For each filesystem, list: [ option, max_length, handled_by_mount ]
+
+Those are used in order to preserve UUID on fs where we couldn't enforce it while formatting.
+
+=cut
+
my %preserve_UUID = ( # package, command
jfs => [ 'jfsutils', 'jfs_tune', ],
xfs => [ 'xfsprogs', 'xfs_admin' ],
nilfs2 => [ 'nilfs-utils', 'nilfs-tune' ],
);
-
+
+
+=back
+
+=head1 Functions
+
+=over
+
+=item package_needed_for_partition_type($part)
+
+Return the package needed for that partition's type.
+
+=cut
+
sub package_needed_for_partition_type {
my ($part) = @_;
my $l = $cmds{$part->{fs_type}} or return;
@@ -100,6 +149,12 @@ sub canEditLabel {
to_bool($edit_LABEL{$part->{fs_type}});
}
+=item part($all_hds, $part, $wait_message)
+
+Frontend to part_raw()
+
+=cut
+
sub part {
my ($all_hds, $part, $wait_message) = @_;
if (isRAID($part)) {
@@ -116,6 +171,12 @@ sub part {
undef $part->{toFormat};
}
+=item write_label($part)
+
+Set the label on the filesystem hold in $part.
+
+=cut
+
sub write_label {
my ($part) = @_;
@@ -150,6 +211,13 @@ sub write_btrfs_uuid {
die "failed to set UUID to '$UUID' on $dev (status=$status)" if !$status;
}
+=item part_raw($part, $wait_message)
+
+Actually format the $part partition disk. $wait_message is only used when formating ext3/4.
+If not set, ext[3-4] will be formated without any progression bar, like other fses...
+
+=cut
+
sub part_raw {
my ($part, $wait_message) = @_;
@@ -223,6 +291,12 @@ sub after_formatting {
set_isFormatted($part, 1);
}
+=item mkfs_ext3($wait_message, @args)
+
+Display a progression bar whike formating ext3/4
+
+=cut
+
sub mkfs_ext3 {
my ($wait_message, @args) = @_;
@@ -239,6 +313,12 @@ sub mkfs_ext3 {
return close($F);
}
+=item disable_forced_fsck($dev)
+
+Disable automatic fsck on extX (infinite number of mounts & duration between 2 fsck runs)
+
+=cut
+
sub disable_forced_fsck {
my ($dev) = @_;
run_program::run("tune2fs", "-c0", "-i0", devices::make($dev));
@@ -310,5 +390,8 @@ sub formatMount_all {
};
}
+=back
+
+=cut
1;