diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2002-07-05 12:08:22 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2002-07-05 12:08:22 +0000 |
commit | 8f864558a144c9994f3d0131096bbd7e26147704 (patch) | |
tree | 64dc396cc0e2275570cca81956f1f473715f9a33 | |
parent | ff8a5ac388f202e40a3e2723c5ae1688e54c0080 (diff) | |
download | drakx-backup-do-not-use-8f864558a144c9994f3d0131096bbd7e26147704.tar drakx-backup-do-not-use-8f864558a144c9994f3d0131096bbd7e26147704.tar.gz drakx-backup-do-not-use-8f864558a144c9994f3d0131096bbd7e26147704.tar.bz2 drakx-backup-do-not-use-8f864558a144c9994f3d0131096bbd7e26147704.tar.xz drakx-backup-do-not-use-8f864558a144c9994f3d0131096bbd7e26147704.zip |
handle comments in fstab
-rw-r--r-- | perl-install/diskdrake/interactive.pm | 1 | ||||
-rw-r--r-- | perl-install/fs.pm | 30 |
2 files changed, 26 insertions, 5 deletions
diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm index 72f001d31..27fd96d45 100644 --- a/perl-install/diskdrake/interactive.pm +++ b/perl-install/diskdrake/interactive.pm @@ -31,6 +31,7 @@ struct part { string options # 'defaults', 'noauto' string device_windobe # 'C', 'D' ... string encrypt_key # [0-9A-Za-z./]{20,} + string comment # comment to have in fstab bool isMounted diff --git a/perl-install/fs.pm b/perl-install/fs.pm index cb8d751cd..e6a50a6e0 100644 --- a/perl-install/fs.pm +++ b/perl-install/fs.pm @@ -20,8 +20,25 @@ use loopback; sub read_fstab { my ($prefix, $file, $all_options) = @_; + my %comments; + my $comment; + my @l = grep { + if (/^\s*#/) { + $comment .= chomp_($_) . "\n"; + 0; + } else { + $comments{$_} = $comment if $comment; + $comment = ''; + 1; + } + } cat_("$prefix$file"); + + #- attach comments at the end of fstab to the previous line + $comments{$l[-1]} = $comment if $comment; + map { my ($dev, $mntpoint, $type, $options, $freq, $passno) = split; + my $comment = $comments{$_}; $options = 'defaults' if $options eq 'rw'; # clean-up for mtab read @@ -48,7 +65,11 @@ sub read_fstab { $mntpoint =~ s/\\040/ /g; $dev =~ s/\\040/ /g; - my $h = { device => $dev, mntpoint => $mntpoint, type => $type, options => $options, if_($all_options, freq => $freq, passno => $passno) }; + my $h = { + device => $dev, mntpoint => $mntpoint, type => $type, + options => $options, comment => $comment, + if_($all_options, freq => $freq, passno => $passno), + }; ($h->{major}, $h->{minor}) = unmakedev((stat "$prefix$dev")[6]); @@ -77,9 +98,8 @@ sub read_fstab { } } - $h; - } cat_("$prefix$file"); + } @l; } sub merge_fstabs { @@ -231,13 +251,13 @@ sub prepare_write_fstab { ($dev, $type) = ($mntpoint, 'supermount'); } - [ $dev, $mntpoint, $type, $options || 'defaults', $freq, $passno ]; + [ $mntpoint, $_->{comment} . join(' ', $dev, $mntpoint, $type, $options || 'defaults', $freq, $passno) . "\n" ]; } else { () } } grep { $_->{device} && ($_->{mntpoint} || $_->{real_mntpoint}) && $_->{type} } (@l1, @l2); - join('', map { join(' ', @$_) . "\n" } sort { $a->[1] cmp $b->[1] } @l), \@smb_credentials; + join('', map { $_->[1] } sort { $a->[0] cmp $b->[0] } @l), \@smb_credentials; } sub fstab_to_string { |