summaryrefslogtreecommitdiffstats
path: root/perl-install/fs.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/fs.pm')
-rw-r--r--perl-install/fs.pm79
1 files changed, 41 insertions, 38 deletions
diff --git a/perl-install/fs.pm b/perl-install/fs.pm
index a5b24edab..76cce10e7 100644
--- a/perl-install/fs.pm
+++ b/perl-install/fs.pm
@@ -1,4 +1,4 @@
-package fs; # $Id$
+package fs;
use diagnostics;
use strict;
@@ -49,32 +49,12 @@ sub read_fstab {
$options = 'defaults' if $options eq 'rw'; # clean-up for mtab read
- if ($fs_type eq 'supermount') {
- log::l("dropping supermount");
- $options = join(",", grep {
- if (/fs=(.*)/) {
- $fs_type = $1;
-
- #- with supermount, the type could be something like ext2:vfat
- #- but this can not be done without supermount, so switching to "auto"
- $fs_type = 'auto' if $fs_type =~ /:/;
-
- 0;
- } elsif (/dev=(.*)/) {
- $dev = $1;
- 0;
- } elsif ($_ eq '--') {
- 0;
- } else {
- 1;
- }
- } split(',', $options));
- } elsif ($fs_type eq 'smb') {
- # prefering type "smbfs" over "smb"
- $fs_type = 'smbfs';
- }
s/\\040/ /g foreach $mntpoint, $dev, $options;
+ if ($fs_type eq 'ext4') {
+ $options = join(",", grep { !/extents/ } split(',', $options)) || 'defaults';
+ }
+
my $h = {
mntpoint => $mntpoint, fs_type => $fs_type,
options => $options, comment => $comment,
@@ -102,6 +82,13 @@ sub read_fstab {
$options->{"$_="} = $credentials->{$_} foreach qw(username password domain);
fs::mount_options::pack($h, $options, $unknown);
}
+ } elsif ($h->{fs_type} eq 'davfs2' && !member('verbatim_credentials', @reading_options)) {
+ require fs::remote::davfs;
+ if (my $credentials = fs::remote::davfs::read_credentials($h->{mntpoint})) {
+ my ($options, $unknown) = fs::mount_options::unpack($h);
+ $options->{"$_="} = $credentials->{$_} foreach qw(username password);
+ fs::mount_options::pack($h, $options, $unknown);
+ }
}
$h;
@@ -143,7 +130,7 @@ sub add2all_hds {
foreach (@l) {
my $s =
$_->{fs_type} eq 'nfs' ? 'nfss' :
- $_->{fs_type} eq 'smbfs' ? 'smbs' :
+ $_->{fs_type} eq 'cifs' ? 'smbs' :
$_->{fs_type} eq 'davfs2' ? 'davs' :
isTrueLocalFS($_) || isSwap($_) || isOtherAvailableFS($_) ? '' :
'special';
@@ -157,7 +144,7 @@ sub get_major_minor {
eval {
my (undef, $major, $minor) = devices::entry($_->{device});
($_->{major}, $_->{minor}) = ($major, $minor);
- } if !$_->{major};
+ };
}
}
@@ -190,7 +177,7 @@ sub merge_info_from_fstab {
my @l = grep {
if ($uniq) {
my $part = fs::get::mntpoint2part($_->{mntpoint}, $fstab);
- !$part || fs::get::is_same_hd($part, $_); #- keep it only if it is the mountpoint AND the same device
+ !$part || fs::get::is_same_hd($part, $_); #- keep it only if it is the mount point AND the same device
} else {
1;
}
@@ -206,11 +193,11 @@ sub get_info_from_fstab {
}
sub prepare_write_fstab {
- my ($fstab, $o_prefix, $b_keep_smb_credentials) = @_;
+ my ($fstab, $o_prefix, $b_keep_credentials) = @_;
$o_prefix ||= '';
my %new;
- my @smb_credentials;
+ my (@smb_credentials, @davfs_credentials);
my @l = map {
my $device =
isLoopback($_) ?
@@ -222,13 +209,16 @@ sub prepare_write_fstab {
$comment ||= "# Entry for /dev/$_->{device} :\n" if $device =~ /^(UUID|LABEL)=/;
my $real_mntpoint = $_->{mntpoint} || ${{ '/tmp/hdimage' => '/mnt/hd' }}{$_->{real_mntpoint}};
- mkdir_p("$o_prefix$real_mntpoint") if $real_mntpoint =~ m|^/|;
+ if (!member('bind', split(',', $_->{options}))) {
+ mkdir_p("$o_prefix$real_mntpoint") if $real_mntpoint =~ m|^/|;
+ }
my $mntpoint = fs::type::carry_root_loopback($_) ? '/initrd/loopfs' : $real_mntpoint;
+ my $needed_to_boot = member($_->{mntpoint}, fs::type::directories_needed_to_boot());
my ($freq, $passno) =
exists $_->{freq} ?
($_->{freq}, $_->{passno}) :
- isTrueLocalFS($_) && $_->{options} !~ /encryption=/ && (!$_->{is_removable} || member($_->{mntpoint}, fs::type::directories_needed_to_boot())) ?
+ isTrueLocalFS($_) && !$_->{dmcrypt_name} && $_->{options} !~ /encryption=/ && (!$_->{is_removable} || $needed_to_boot) ?
(1, $_->{mntpoint} eq '/' ? 1 : fs::type::carry_root_loopback($_) ? 0 : 2) :
(0, 0);
@@ -238,13 +228,22 @@ sub prepare_write_fstab {
$new{$mntpoint} = 1;
my $options = $_->{options} || 'defaults';
+ if (($_->{is_removable} || member($_->{fs_type}, qw(ntfs ntfs-3g))) && !$needed_to_boot && $_->{options} !~ /nofail/) {
+ $options .= ',nofail';
+ }
- if ($_->{fs_type} eq 'smbfs' && $options =~ /password=/ && !$b_keep_smb_credentials) {
+ if ($_->{fs_type} eq 'cifs' && $options =~ /password=/ && !$b_keep_credentials) {
require fs::remote::smb;
if (my ($opts, $smb_credentials) = fs::remote::smb::fstab_entry_to_credentials($_)) {
$options = $opts;
push @smb_credentials, $smb_credentials;
}
+ } elsif ($_->{fs_type} eq 'davfs2' && !$b_keep_credentials) {
+ require fs::remote::davfs;
+ if (my ($opts, $davfs_credentials) = fs::remote::davfs::fstab_entry_to_credentials($_)) {
+ $options = $opts || 'defaults';
+ push @davfs_credentials, $davfs_credentials;
+ }
}
my $fs_type = $_->{fs_type} || 'auto';
@@ -276,13 +275,13 @@ sub prepare_write_fstab {
}
@l = sort_it(@l);
- join('', map { $_->[2] } @l), \@smb_credentials;
+ join('', map { $_->[2] } @l), \@smb_credentials, \@davfs_credentials;
}
sub fstab_to_string {
my ($all_hds, $o_prefix) = @_;
my $fstab = [ fs::get::really_all_fstab($all_hds), @{$all_hds->{special}} ];
- my ($s, undef) = prepare_write_fstab($fstab, $o_prefix, 'keep_smb_credentials');
+ my ($s, undef) = prepare_write_fstab($fstab, $o_prefix, 'keep_credentials');
$s;
}
@@ -290,9 +289,13 @@ sub write_fstab {
my ($all_hds, $o_prefix) = @_;
log::l("writing $o_prefix/etc/fstab");
my $fstab = [ fs::get::really_all_fstab($all_hds), @{$all_hds->{special}} ];
- my ($s, $smb_credentials) = prepare_write_fstab($fstab, $o_prefix, '');
+ my ($s, $smb_credentials, $davfs_credentials) = prepare_write_fstab($fstab, $o_prefix, '');
+ renamef("$o_prefix/etc/fstab", "$o_prefix/etc/fstab.old");
output("$o_prefix/etc/fstab", $s);
+ require fs::remote::davfs;
fs::remote::smb::save_credentials($_) foreach @$smb_credentials;
+ fs::remote::davfs::save_credentials($davfs_credentials);
+ fs::dmcrypt::save_crypttab($all_hds) if @{$all_hds->{dmcrypts}};
}
sub set_removable_mntpoints {
@@ -301,7 +304,7 @@ sub set_removable_mntpoints {
my %names;
foreach (@{$all_hds->{raw_hds}}) {
my $name = detect_devices::suggest_mount_point($_) or next;
- $name eq 'zip' || $name eq 'cdrom' and next;
+ member($name, qw(zip cdrom)) and next;
my $s = ++$names{$name};
$_->{mntpoint} ||= "/media/$name" . ($s == 1 ? '' : $s);
@@ -318,7 +321,7 @@ sub get_raw_hds {
my @fstab = read_fstab($prefix, '/etc/fstab', 'keep_default');
$all_hds->{nfss} = [ grep { $_->{fs_type} eq 'nfs' } @fstab ];
- $all_hds->{smbs} = [ grep { $_->{fs_type} eq 'smbfs' } @fstab ];
+ $all_hds->{smbs} = [ grep { $_->{fs_type} eq 'cifs' } @fstab ];
$all_hds->{davs} = [ grep { $_->{fs_type} eq 'davfs2' } @fstab ];
$all_hds->{special} = [
(grep { $_->{fs_type} eq 'tmpfs' } @fstab),