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.pm40
1 files changed, 23 insertions, 17 deletions
diff --git a/perl-install/fs/format.pm b/perl-install/fs/format.pm
index fcd88a5ea..659fbad04 100644
--- a/perl-install/fs/format.pm
+++ b/perl-install/fs/format.pm
@@ -1,4 +1,4 @@
-package fs::format; # $Id: format.pm 268842 2010-05-17 06:54:44Z pterjan $
+package fs::format;
use diagnostics;
use strict;
@@ -15,16 +15,15 @@ my %cmds = (
ext3 => [ 'e2fsprogs', 'mkfs.ext3', '-F' ],
ext4 => [ 'e2fsprogs', 'mkfs.ext4', '-F' ],
reiserfs => [ 'reiserfsprogs', 'mkfs.reiserfs', '-ff' ],
- reiser4 => [ 'reiser4progs', 'mkfs.reiser4', '-f', '-y' ],
xfs => [ 'xfsprogs', 'mkfs.xfs', '-f', '-q' ],
jfs => [ 'jfsutils', 'mkfs.jfs', '-f' ],
hfs => [ 'hfsutils', 'hformat' ],
dos => [ 'dosfstools', 'mkdosfs' ],
vfat => [ 'dosfstools', 'mkdosfs', '-F', '32' ],
- swap => [ 'util-linux-ng', 'mkswap' ],
+ swap => [ 'util-linux', 'mkswap' ],
ntfs => [ 'ntfsprogs', 'mkntfs', '--fast' ],
'ntfs-3g' => [ 'ntfsprogs', 'mkntfs', '--fast' ],
- btrfs => [ 'btrfs-progs', 'mkfs.btrfs' ],
+ btrfs => [ 'btrfs-progs', 'mkfs.btrfs', '-f' ],
nilfs2 => [ 'nilfs-utils', 'mkfs.nilfs2' ],
);
@@ -33,7 +32,6 @@ my %LABELs = ( #- option, length, handled_by_mount
ext3 => [ '-L', 16, 1 ],
ext4 => [ '-L', 16, 1 ],
reiserfs => [ '-l', 16, 1 ],
- reiser4 => [ '-L', 16, 1 ],
xfs => [ '-L', 12, 1 ],
jfs => [ '-L', 16, 1 ],
hfs => [ '-l', 27, 0 ],
@@ -43,7 +41,7 @@ my %LABELs = ( #- option, length, handled_by_mount
ntfs => [ '-L', 128, 0 ],
'ntfs-3g' => [ '-L', 128, 0 ],
btrfs => [ '-L', 256, 1 ],
- nilfs2 => [ '-L', 16, 1],
+ nilfs2 => [ '-L', 16, 1 ],
);
my %edit_LABEL = ( # package, command, option
@@ -53,19 +51,26 @@ my %edit_LABEL = ( # package, command, option
ext3 => [ 'e2fsprogs', 'tune2fs', '-L' ],
ext4 => [ 'e2fsprogs', 'tune2fs', '-L' ],
reiserfs => [ 'reiserfsprogs', 'reiserfstune', '-l' ],
-# reiser4
xfs => [ 'xfsprogs', 'xfs_admin', '-L' ],
jfs => [ 'jfsutils', 'jfs_tune', '-L' ],
# hfs
dos => [ 'mtools', 'mlabel', '-i' ],
vfat => [ 'mtools', 'mlabel', '-i' ],
-# swap => [ 'util-linux-ng', 'mkswap' ],
+ swap => [ 'util-linux', 'swaplabel', '-L' ],
ntfs => [ 'ntfsprogs', 'ntfslabel' ],
'ntfs-3g' => [ 'ntfsprogs', 'ntfslabel' ],
-# btrfs
-# nilfs2
+ btrfs => [ 'btrfs-progs', 'btrfs', 'filesystem', 'label' ],
+ nilfs2 => [ 'nilfs-utils', 'nilfs-tune', '-L' ],
);
+# Preserve UUID on fs where we couldn't enforce it while formatting
+my %preserve_UUID = ( # package, command
+ #btrfs => [ 'btrfs-progs', 'FIXME' ],
+ jfs => [ 'jfsutils', 'jfs_tune', ],
+ xfs => [ 'xfsprogs', 'xfs_admin' ],
+ nilfs2 => [ 'nilfs-utils', 'nilfs-tune' ],
+);
+
sub package_needed_for_partition_type {
my ($part) = @_;
my $l = $cmds{$part->{fs_type}} or return;
@@ -109,6 +114,7 @@ sub part {
$wait_message->(N("Formatting partition %s", $part->{device})) if $wait_message;
part_raw($part, $wait_message);
}
+ undef $part->{toFormat};
}
sub write_label {
@@ -126,6 +132,9 @@ sub write_label {
my @args;
if ($cmd eq 'mlabel') {
@args = ($cmd, @first_options, devices::make($dev), '::' . $part->{device_LABEL});
+ } elsif ($cmd eq 'btrfs') {
+ # btrfs needs reverse ordering
+ @args = ($cmd, @first_options, devices::make($dev), $part->{device_LABEL});
} elsif (defined $first_options[0]) {
@args = ($cmd, @first_options, $part->{device_LABEL}, devices::make($dev));
} else {
@@ -185,12 +194,9 @@ sub part_raw {
delete $part->{device_LABEL_changed};
# Preserve UUID on fs where we couldn't enforce it while formatting
- if ($fs_type eq 'jfs') {
- run_program::raw('jfs_tune', '-U', devices::make($dev));
- } elsif ($fs_type eq 'xfs') {
- run_program::raw('xfs_admin', '-U', devices::make($dev));
- } elsif ($fs_type eq 'btrfs') {
- #FIXME
+ if (my $uuid_cmd = $preserve_UUID{$fs_type}) {
+ (undef, $cmd) = @$uuid_cmd;
+ run_program::raw({}, $cmd, '-U', devices::make($dev)) if $cmd;
}
if (member($fs_type, qw(ext3 ext4))) {
@@ -235,7 +241,7 @@ sub clean_label {
if ($part->{device_LABEL}) {
my $fs_type = $part->{fs_type};
if ($LABELs{$fs_type}) {
- my ($option, $length, $handled_by_mount) = @{$LABELs{$fs_type}};
+ my ($_option, $length, $handled_by_mount) = @{$LABELs{$fs_type}};
if (length $part->{device_LABEL} > $length) {
my $short = substr($part->{device_LABEL}, 0, $length);
log::l("shortening LABEL $part->{device_LABEL} to $short");